wayland: implement wl-fixes
This commit is contained in:
parent
f36993eb6e
commit
b13dd08991
14 changed files with 183 additions and 3 deletions
90
src/ifs/wl_fixes.rs
Normal file
90
src/ifs/wl_fixes.rs
Normal file
|
|
@ -0,0 +1,90 @@
|
|||
use {
|
||||
crate::{
|
||||
client::{Client, ClientError},
|
||||
globals::{Global, GlobalName},
|
||||
leaks::Tracker,
|
||||
object::{Object, Version},
|
||||
wire::{wl_fixes::*, WlFixesId},
|
||||
},
|
||||
std::rc::Rc,
|
||||
thiserror::Error,
|
||||
};
|
||||
|
||||
pub struct WlFixesGlobal {
|
||||
pub name: GlobalName,
|
||||
}
|
||||
|
||||
impl WlFixesGlobal {
|
||||
pub fn new(name: GlobalName) -> Self {
|
||||
Self { name }
|
||||
}
|
||||
|
||||
fn bind_(
|
||||
self: Rc<Self>,
|
||||
id: WlFixesId,
|
||||
client: &Rc<Client>,
|
||||
version: Version,
|
||||
) -> Result<(), WlFixesError> {
|
||||
let mgr = Rc::new(WlFixes {
|
||||
id,
|
||||
client: client.clone(),
|
||||
tracker: Default::default(),
|
||||
version,
|
||||
});
|
||||
track!(client, mgr);
|
||||
client.add_client_obj(&mgr)?;
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
global_base!(WlFixesGlobal, WlFixes, WlFixesError);
|
||||
|
||||
simple_add_global!(WlFixesGlobal);
|
||||
|
||||
impl Global for WlFixesGlobal {
|
||||
fn singleton(&self) -> bool {
|
||||
true
|
||||
}
|
||||
|
||||
fn version(&self) -> u32 {
|
||||
1
|
||||
}
|
||||
}
|
||||
|
||||
pub struct WlFixes {
|
||||
pub id: WlFixesId,
|
||||
pub client: Rc<Client>,
|
||||
pub tracker: Tracker<Self>,
|
||||
pub version: Version,
|
||||
}
|
||||
|
||||
impl WlFixesRequestHandler for WlFixes {
|
||||
type Error = WlFixesError;
|
||||
|
||||
fn destroy(&self, _req: Destroy, _slf: &Rc<Self>) -> Result<(), Self::Error> {
|
||||
self.client.remove_obj(self)?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn destroy_registry(&self, req: DestroyRegistry, _slf: &Rc<Self>) -> Result<(), Self::Error> {
|
||||
let registry = self.client.lookup(req.registry)?;
|
||||
self.client.remove_obj(&*registry)?;
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
object_base! {
|
||||
self = WlFixes;
|
||||
version = self.version;
|
||||
}
|
||||
|
||||
impl Object for WlFixes {}
|
||||
|
||||
simple_add_obj!(WlFixes);
|
||||
|
||||
#[derive(Debug, Error)]
|
||||
pub enum WlFixesError {
|
||||
#[error(transparent)]
|
||||
ClientError(Box<ClientError>),
|
||||
}
|
||||
efrom!(WlFixesError, ClientError);
|
||||
Loading…
Add table
Add a link
Reference in a new issue