wire: generate trait for request handling
This commit is contained in:
parent
e3a1a0b30f
commit
acb391335b
102 changed files with 1632 additions and 2086 deletions
|
|
@ -5,11 +5,7 @@ use {
|
|||
ifs::wl_surface::wp_tearing_control_v1::{WpTearingControlV1, WpTearingControlV1Error},
|
||||
leaks::Tracker,
|
||||
object::{Object, Version},
|
||||
utils::buffd::{MsgParser, MsgParserError},
|
||||
wire::{
|
||||
wp_tearing_control_manager_v1::{GET_TEARING_CONTROL, *},
|
||||
WpTearingControlManagerV1Id,
|
||||
},
|
||||
wire::{wp_tearing_control_manager_v1::*, WpTearingControlManagerV1Id},
|
||||
},
|
||||
std::rc::Rc,
|
||||
thiserror::Error,
|
||||
|
|
@ -28,12 +24,13 @@ impl WpTearingControlManagerV1Global {
|
|||
self: Rc<Self>,
|
||||
id: WpTearingControlManagerV1Id,
|
||||
client: &Rc<Client>,
|
||||
_version: Version,
|
||||
version: Version,
|
||||
) -> Result<(), WpTearingControlManagerV1Error> {
|
||||
let obj = Rc::new(WpTearingControlManagerV1 {
|
||||
id,
|
||||
client: client.clone(),
|
||||
tracker: Default::default(),
|
||||
version,
|
||||
});
|
||||
track!(client, obj);
|
||||
client.add_client_obj(&obj)?;
|
||||
|
|
@ -63,25 +60,33 @@ pub struct WpTearingControlManagerV1 {
|
|||
pub id: WpTearingControlManagerV1Id,
|
||||
pub client: Rc<Client>,
|
||||
pub tracker: Tracker<Self>,
|
||||
pub version: Version,
|
||||
}
|
||||
|
||||
impl WpTearingControlManagerV1 {
|
||||
pub fn destroy(&self, parser: MsgParser<'_, '_>) -> Result<(), WpTearingControlManagerV1Error> {
|
||||
let _req: Destroy = self.client.parse(self, parser)?;
|
||||
object_base! {
|
||||
self = WpTearingControlManagerV1;
|
||||
version = self.version;
|
||||
}
|
||||
|
||||
impl WpTearingControlManagerV1RequestHandler for WpTearingControlManagerV1 {
|
||||
type Error = WpTearingControlManagerV1Error;
|
||||
|
||||
fn destroy(&self, _req: Destroy, _slf: &Rc<Self>) -> Result<(), Self::Error> {
|
||||
self.client.remove_obj(self)?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub fn get_tearing_control(
|
||||
fn get_tearing_control(
|
||||
&self,
|
||||
parser: MsgParser<'_, '_>,
|
||||
) -> Result<(), WpTearingControlManagerV1Error> {
|
||||
let req: GetTearingControl = self.client.parse(self, parser)?;
|
||||
req: GetTearingControl,
|
||||
_slf: &Rc<Self>,
|
||||
) -> Result<(), Self::Error> {
|
||||
let surface = self.client.lookup(req.surface)?;
|
||||
let control = Rc::new(WpTearingControlV1 {
|
||||
id: req.id,
|
||||
surface,
|
||||
tracker: Default::default(),
|
||||
version: self.version,
|
||||
});
|
||||
track!(self.client, control);
|
||||
self.client.add_client_obj(&control)?;
|
||||
|
|
@ -90,25 +95,15 @@ impl WpTearingControlManagerV1 {
|
|||
}
|
||||
}
|
||||
|
||||
object_base! {
|
||||
self = WpTearingControlManagerV1;
|
||||
|
||||
DESTROY => destroy,
|
||||
GET_TEARING_CONTROL => get_tearing_control,
|
||||
}
|
||||
|
||||
impl Object for WpTearingControlManagerV1 {}
|
||||
|
||||
simple_add_obj!(WpTearingControlManagerV1);
|
||||
|
||||
#[derive(Debug, Error)]
|
||||
pub enum WpTearingControlManagerV1Error {
|
||||
#[error("Parsing failed")]
|
||||
MsgParserError(#[source] Box<MsgParserError>),
|
||||
#[error(transparent)]
|
||||
ClientError(Box<ClientError>),
|
||||
#[error(transparent)]
|
||||
WpTearingControlV1Error(#[from] WpTearingControlV1Error),
|
||||
}
|
||||
efrom!(WpTearingControlManagerV1Error, ClientError);
|
||||
efrom!(WpTearingControlManagerV1Error, MsgParserError);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue