-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #182 from mahkoh/jorth/transient-seat
wayland: implement ext-transient-seat-v1
- Loading branch information
Showing
9 changed files
with
178 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
request create { | ||
seat: id(ext_transient_seat_v1), | ||
} | ||
|
||
request destroy { | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
request destroy { | ||
} | ||
|
||
event ready { | ||
global_name: u32, | ||
} | ||
|
||
event denied { | ||
|
||
} |