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,7 +5,6 @@ use {
|
|||
ifs::wl_surface::wp_viewport::{WpViewport, WpViewportError},
|
||||
leaks::Tracker,
|
||||
object::{Object, Version},
|
||||
utils::buffd::{MsgParser, MsgParserError},
|
||||
wire::{wp_viewporter::*, WpViewporterId},
|
||||
},
|
||||
std::rc::Rc,
|
||||
|
|
@ -25,12 +24,13 @@ impl WpViewporterGlobal {
|
|||
self: Rc<Self>,
|
||||
id: WpViewporterId,
|
||||
client: &Rc<Client>,
|
||||
_version: Version,
|
||||
version: Version,
|
||||
) -> Result<(), WpViewporterError> {
|
||||
let obj = Rc::new(WpViewporter {
|
||||
id,
|
||||
client: client.clone(),
|
||||
tracker: Default::default(),
|
||||
version,
|
||||
});
|
||||
track!(client, obj);
|
||||
client.add_client_obj(&obj)?;
|
||||
|
|
@ -56,19 +56,20 @@ pub struct WpViewporter {
|
|||
pub id: WpViewporterId,
|
||||
pub client: Rc<Client>,
|
||||
pub tracker: Tracker<Self>,
|
||||
pub version: Version,
|
||||
}
|
||||
|
||||
impl WpViewporter {
|
||||
fn destroy(&self, msg: MsgParser<'_, '_>) -> Result<(), WpViewporterError> {
|
||||
let _req: Destroy = self.client.parse(self, msg)?;
|
||||
impl WpViewporterRequestHandler for WpViewporter {
|
||||
type Error = WpViewporterError;
|
||||
|
||||
fn destroy(&self, _req: Destroy, _slf: &Rc<Self>) -> Result<(), Self::Error> {
|
||||
self.client.remove_obj(self)?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn get_viewport(&self, msg: MsgParser<'_, '_>) -> Result<(), WpViewporterError> {
|
||||
let req: GetViewport = self.client.parse(self, msg)?;
|
||||
fn get_viewport(&self, req: GetViewport, _slf: &Rc<Self>) -> Result<(), Self::Error> {
|
||||
let surface = self.client.lookup(req.surface)?;
|
||||
let viewport = Rc::new(WpViewport::new(req.id, &surface));
|
||||
let viewport = Rc::new(WpViewport::new(req.id, &surface, self.version));
|
||||
track!(self.client, viewport);
|
||||
viewport.install()?;
|
||||
self.client.add_client_obj(&viewport)?;
|
||||
|
|
@ -78,9 +79,7 @@ impl WpViewporter {
|
|||
|
||||
object_base! {
|
||||
self = WpViewporter;
|
||||
|
||||
DESTROY => destroy,
|
||||
GET_VIEWPORT => get_viewport,
|
||||
version = self.version;
|
||||
}
|
||||
|
||||
impl Object for WpViewporter {}
|
||||
|
|
@ -89,12 +88,9 @@ simple_add_obj!(WpViewporter);
|
|||
|
||||
#[derive(Debug, Error)]
|
||||
pub enum WpViewporterError {
|
||||
#[error("Parsing failed")]
|
||||
MsgParserError(#[source] Box<MsgParserError>),
|
||||
#[error(transparent)]
|
||||
ClientError(Box<ClientError>),
|
||||
#[error(transparent)]
|
||||
WpViewportError(#[from] WpViewportError),
|
||||
}
|
||||
efrom!(WpViewporterError, MsgParserError);
|
||||
efrom!(WpViewporterError, ClientError);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue