1
0
Fork 0
forked from wry/wry

wire: generate trait for request handling

This commit is contained in:
Julian Orth 2024-04-08 17:37:35 +02:00
parent e3a1a0b30f
commit acb391335b
102 changed files with 1632 additions and 2086 deletions

View file

@ -5,7 +5,6 @@ use {
ifs::{wl_region::WlRegion, wl_surface::WlSurface},
leaks::Tracker,
object::{Object, Version},
utils::buffd::{MsgParser, MsgParserError},
wire::{wl_compositor::*, WlCompositorId},
xwayland::XWaylandEvent,
},
@ -47,10 +46,11 @@ impl WlCompositorGlobal {
}
}
impl WlCompositor {
fn create_surface(&self, parser: MsgParser<'_, '_>) -> Result<(), WlCompositorError> {
let surface: CreateSurface = self.client.parse(self, parser)?;
let surface = Rc::new(WlSurface::new(surface.id, &self.client, self.version));
impl WlCompositorRequestHandler for WlCompositor {
type Error = WlCompositorError;
fn create_surface(&self, req: CreateSurface, _slf: &Rc<Self>) -> Result<(), Self::Error> {
let surface = Rc::new(WlSurface::new(req.id, &self.client, self.version));
track!(self.client, surface);
self.client.add_client_obj(&surface)?;
if self.client.is_xwayland {
@ -63,9 +63,8 @@ impl WlCompositor {
Ok(())
}
fn create_region(&self, parser: MsgParser<'_, '_>) -> Result<(), WlCompositorError> {
let region: CreateRegion = self.client.parse(self, parser)?;
let region = Rc::new(WlRegion::new(region.id, &self.client));
fn create_region(&self, req: CreateRegion, _slf: &Rc<Self>) -> Result<(), Self::Error> {
let region = Rc::new(WlRegion::new(req.id, &self.client, self.version));
track!(self.client, region);
self.client.add_client_obj(&region)?;
Ok(())
@ -88,9 +87,7 @@ simple_add_global!(WlCompositorGlobal);
object_base! {
self = WlCompositor;
CREATE_SURFACE => create_surface,
CREATE_REGION => create_region,
version = self.version;
}
impl Object for WlCompositor {}
@ -101,9 +98,6 @@ simple_add_obj!(WlCompositor);
pub enum WlCompositorError {
#[error(transparent)]
ClientError(Box<ClientError>),
#[error("Parsing failed")]
MsgParserError(#[source] Box<MsgParserError>),
}
efrom!(WlCompositorError, ClientError);
efrom!(WlCompositorError, MsgParserError);