Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

wayland: implement ext-transient-seat-v1 #182

Merged
merged 1 commit into from
Apr 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions docs/features.md
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,7 @@ Jay supports the following wayland protocols:
| ext_foreign_toplevel_list_v1 | 1 | Yes |
| ext_idle_notifier_v1 | 1 | Yes |
| ext_session_lock_manager_v1 | 1 | Yes |
| ext_transient_seat_manager_v1 | 1[^ts_rejected] | Yes |
| org_kde_kwin_server_decoration_manager | 1 | |
| wl_compositor | 6[^no_touch] | |
| wl_data_device_manager | 3 | |
Expand Down Expand Up @@ -167,6 +168,7 @@ Jay supports the following wayland protocols:
[^no_tearing]: Tearing screen updates are not supported.
[^no_exclusive]: Exclusive zones are not supported.
[^lsaccess]: Sandboxes can restrict access to this protocol.
[^ts_rejected]: Seat creation is always rejected.

## Missing Features

Expand Down
1 change: 1 addition & 0 deletions release-notes.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

- Add support for wp-security-manager-v1.
- Add support for xdg-dialog-v1.
- Add support for ext-transient-seat-v1.

# 1.1.0 (2024-04-22)

Expand Down
1 change: 1 addition & 0 deletions src/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ bitflags! {
CAP_JAY_COMPOSITOR = 1 << 5,
CAP_LAYER_SHELL = 1 << 6,
CAP_SCREENCOPY_MANAGER = 1 << 7,
CAP_SEAT_MANAGER = 1 << 8,
}

#[derive(Debug, Copy, Clone, Hash, Ord, PartialOrd, Eq, PartialEq)]
Expand Down
2 changes: 2 additions & 0 deletions src/globals.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ use {
wl_output::WlOutputGlobal,
wl_registry::WlRegistry,
wl_seat::{
ext_transient_seat_manager_v1::ExtTransientSeatManagerV1Global,
text_input::{
zwp_input_method_manager_v2::ZwpInputMethodManagerV2Global,
zwp_text_input_manager_v3::ZwpTextInputManagerV3Global,
Expand Down Expand Up @@ -188,6 +189,7 @@ impl Globals {
add_singleton!(ZwpTextInputManagerV3Global);
add_singleton!(WpSecurityContextManagerV1Global);
add_singleton!(XdgWmDialogV1Global);
add_singleton!(ExtTransientSeatManagerV1Global);
}

pub fn add_backend_singletons(&self, backend: &Rc<dyn Backend>) {
Expand Down
2 changes: 2 additions & 0 deletions src/ifs/wl_seat.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
mod event_handling;
pub mod ext_transient_seat_manager_v1;
pub mod ext_transient_seat_v1;
mod kb_owner;
mod pointer_owner;
pub mod text_input;
Expand Down
106 changes: 106 additions & 0 deletions src/ifs/wl_seat/ext_transient_seat_manager_v1.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
use {
crate::{
client::{Client, ClientCaps, ClientError, CAP_SEAT_MANAGER},
globals::{Global, GlobalName},
ifs::wl_seat::ext_transient_seat_v1::ExtTransientSeatV1,
leaks::Tracker,
object::{Object, Version},
wire::{ext_transient_seat_manager_v1::*, ExtTransientSeatManagerV1Id},
},
std::rc::Rc,
thiserror::Error,
};

pub struct ExtTransientSeatManagerV1Global {
pub name: GlobalName,
}

pub struct ExtTransientSeatManagerV1 {
pub id: ExtTransientSeatManagerV1Id,
pub client: Rc<Client>,
pub tracker: Tracker<Self>,
pub version: Version,
}

impl ExtTransientSeatManagerV1Global {
pub fn new(name: GlobalName) -> Self {
Self { name }
}

fn bind_(
self: Rc<Self>,
id: ExtTransientSeatManagerV1Id,
client: &Rc<Client>,
version: Version,
) -> Result<(), ExtTransientSeatManagerV1Error> {
let obj = Rc::new(ExtTransientSeatManagerV1 {
id,
client: client.clone(),
tracker: Default::default(),
version,
});
track!(client, obj);
client.add_client_obj(&obj)?;
Ok(())
}
}

global_base!(
ExtTransientSeatManagerV1Global,
ExtTransientSeatManagerV1,
ExtTransientSeatManagerV1Error
);

impl Global for ExtTransientSeatManagerV1Global {
fn singleton(&self) -> bool {
true
}

fn version(&self) -> u32 {
1
}

fn required_caps(&self) -> ClientCaps {
CAP_SEAT_MANAGER
}
}

simple_add_global!(ExtTransientSeatManagerV1Global);

impl ExtTransientSeatManagerV1RequestHandler for ExtTransientSeatManagerV1 {
type Error = ExtTransientSeatManagerV1Error;

fn destroy(&self, _req: Destroy, _slf: &Rc<Self>) -> Result<(), Self::Error> {
self.client.remove_obj(self)?;
Ok(())
}

fn create(&self, req: Create, _slf: &Rc<Self>) -> Result<(), Self::Error> {
let obj = Rc::new(ExtTransientSeatV1 {
id: req.seat,
client: self.client.clone(),
tracker: Default::default(),
version: self.version,
});
track!(self.client, obj);
self.client.add_client_obj(&obj)?;
obj.send_denied();
Ok(())
}
}

object_base! {
self = ExtTransientSeatManagerV1;
version = self.version;
}

impl Object for ExtTransientSeatManagerV1 {}

simple_add_obj!(ExtTransientSeatManagerV1);

#[derive(Debug, Error)]
pub enum ExtTransientSeatManagerV1Error {
#[error(transparent)]
ClientError(Box<ClientError>),
}
efrom!(ExtTransientSeatManagerV1Error, ClientError);
48 changes: 48 additions & 0 deletions src/ifs/wl_seat/ext_transient_seat_v1.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
use {
crate::{
client::{Client, ClientError},
leaks::Tracker,
object::{Object, Version},
wire::{ext_transient_seat_v1::*, ExtTransientSeatV1Id},
},
std::rc::Rc,
thiserror::Error,
};

pub struct ExtTransientSeatV1 {
pub id: ExtTransientSeatV1Id,
pub client: Rc<Client>,
pub tracker: Tracker<Self>,
pub version: Version,
}

impl ExtTransientSeatV1 {
pub fn send_denied(&self) {
self.client.event(Denied { self_id: self.id });
}
}

impl ExtTransientSeatV1RequestHandler for ExtTransientSeatV1 {
type Error = ExtTransientSeatV1Error;

fn destroy(&self, _req: Destroy, _slf: &Rc<Self>) -> Result<(), Self::Error> {
self.client.remove_obj(self)?;
Ok(())
}
}

object_base! {
self = ExtTransientSeatV1;
version = self.version;
}

impl Object for ExtTransientSeatV1 {}

simple_add_obj!(ExtTransientSeatV1);

#[derive(Debug, Error)]
pub enum ExtTransientSeatV1Error {
#[error(transparent)]
ClientError(Box<ClientError>),
}
efrom!(ExtTransientSeatV1Error, ClientError);
6 changes: 6 additions & 0 deletions wire/ext_transient_seat_manager_v1.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
request create {
seat: id(ext_transient_seat_v1),
}

request destroy {
}
10 changes: 10 additions & 0 deletions wire/ext_transient_seat_v1.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
request destroy {
}

event ready {
global_name: u32,
}

event denied {

}
Loading