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,8 +5,7 @@ use {
ConstraintOwner, SeatConstraint, ZwpPointerConstraintsV1Error,
},
leaks::Tracker,
object::Object,
utils::buffd::{MsgParser, MsgParserError},
object::{Object, Version},
wire::{zwp_confined_pointer_v1::*, ZwpConfinedPointerV1Id},
},
std::rc::Rc,
@ -17,18 +16,19 @@ pub struct ZwpConfinedPointerV1 {
pub id: ZwpConfinedPointerV1Id,
pub tracker: Tracker<Self>,
pub constraint: Rc<SeatConstraint>,
pub version: Version,
}
impl ZwpConfinedPointerV1 {
fn destroy(&self, msg: MsgParser<'_, '_>) -> Result<(), ZwpConfinedPointerV1Error> {
let _req: Destroy = self.constraint.client.parse(self, msg)?;
impl ZwpConfinedPointerV1RequestHandler for ZwpConfinedPointerV1 {
type Error = ZwpConfinedPointerV1Error;
fn destroy(&self, _req: Destroy, _slf: &Rc<Self>) -> Result<(), Self::Error> {
self.constraint.detach();
self.constraint.client.remove_obj(self)?;
Ok(())
}
fn set_region(&self, msg: MsgParser<'_, '_>) -> Result<(), ZwpConfinedPointerV1Error> {
let req: SetRegion = self.constraint.client.parse(self, msg)?;
fn set_region(&self, req: SetRegion, _slf: &Rc<Self>) -> Result<(), Self::Error> {
self.constraint.set_region(req.region)?;
Ok(())
}
@ -48,9 +48,7 @@ impl ConstraintOwner for ZwpConfinedPointerV1 {
object_base! {
self = ZwpConfinedPointerV1;
DESTROY => destroy,
SET_REGION => set_region,
version = self.version;
}
impl Object for ZwpConfinedPointerV1 {
@ -65,10 +63,7 @@ simple_add_obj!(ZwpConfinedPointerV1);
pub enum ZwpConfinedPointerV1Error {
#[error(transparent)]
ClientError(Box<ClientError>),
#[error("Parsing failed")]
MsgParserError(#[source] Box<MsgParserError>),
#[error(transparent)]
ZwpPointerConstraintsV1Error(#[from] ZwpPointerConstraintsV1Error),
}
efrom!(ZwpConfinedPointerV1Error, ClientError);
efrom!(ZwpConfinedPointerV1Error, MsgParserError);

View file

@ -5,8 +5,7 @@ use {
ConstraintOwner, SeatConstraint, ZwpPointerConstraintsV1Error,
},
leaks::Tracker,
object::Object,
utils::buffd::{MsgParser, MsgParserError},
object::{Object, Version},
wire::{zwp_locked_pointer_v1::*, ZwpLockedPointerV1Id},
},
std::rc::Rc,
@ -17,11 +16,13 @@ pub struct ZwpLockedPointerV1 {
pub id: ZwpLockedPointerV1Id,
pub tracker: Tracker<Self>,
pub constraint: Rc<SeatConstraint>,
pub version: Version,
}
impl ZwpLockedPointerV1 {
fn destroy(&self, msg: MsgParser<'_, '_>) -> Result<(), ZwpLockedPointerV1Error> {
let _req: Destroy = self.constraint.client.parse(self, msg)?;
impl ZwpLockedPointerV1RequestHandler for ZwpLockedPointerV1 {
type Error = ZwpLockedPointerV1Error;
fn destroy(&self, _req: Destroy, _slf: &Rc<Self>) -> Result<(), Self::Error> {
self.constraint.detach();
self.constraint.client.remove_obj(self)?;
Ok(())
@ -29,14 +30,13 @@ impl ZwpLockedPointerV1 {
fn set_cursor_position_hint(
&self,
msg: MsgParser<'_, '_>,
) -> Result<(), ZwpLockedPointerV1Error> {
let _req: SetCursorPositionHint = self.constraint.client.parse(self, msg)?;
_req: SetCursorPositionHint,
_slf: &Rc<Self>,
) -> Result<(), Self::Error> {
Ok(())
}
fn set_region(&self, msg: MsgParser<'_, '_>) -> Result<(), ZwpLockedPointerV1Error> {
let req: SetRegion = self.constraint.client.parse(self, msg)?;
fn set_region(&self, req: SetRegion, _slf: &Rc<Self>) -> Result<(), Self::Error> {
self.constraint.set_region(req.region)?;
Ok(())
}
@ -54,10 +54,7 @@ impl ConstraintOwner for ZwpLockedPointerV1 {
object_base! {
self = ZwpLockedPointerV1;
DESTROY => destroy,
SET_CURSOR_POSITION_HINT => set_cursor_position_hint,
SET_REGION => set_region,
version = self.version;
}
impl Object for ZwpLockedPointerV1 {
@ -72,10 +69,7 @@ simple_add_obj!(ZwpLockedPointerV1);
pub enum ZwpLockedPointerV1Error {
#[error(transparent)]
ClientError(Box<ClientError>),
#[error("Parsing failed")]
MsgParserError(#[source] Box<MsgParserError>),
#[error(transparent)]
ZwpPointerConstraintsV1Error(#[from] ZwpPointerConstraintsV1Error),
}
efrom!(ZwpLockedPointerV1Error, ClientError);
efrom!(ZwpLockedPointerV1Error, MsgParserError);