wire: generate trait for request handling
This commit is contained in:
parent
e3a1a0b30f
commit
acb391335b
102 changed files with 1632 additions and 2086 deletions
|
|
@ -15,7 +15,6 @@ use {
|
|||
},
|
||||
leaks::Tracker,
|
||||
object::{Object, Version},
|
||||
utils::buffd::{MsgParser, MsgParserError},
|
||||
wire::{
|
||||
zwlr_data_control_device_v1::*, ZwlrDataControlDeviceV1Id, ZwlrDataControlOfferV1Id,
|
||||
ZwlrDataControlSourceV1Id,
|
||||
|
|
@ -98,16 +97,18 @@ impl ZwlrDataControlDeviceV1 {
|
|||
Ok(Some(src))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn set_selection(&self, parser: MsgParser<'_, '_>) -> Result<(), ZwlrDataControlDeviceV1Error> {
|
||||
let req: SetSelection = self.client.parse(self, parser)?;
|
||||
impl ZwlrDataControlDeviceV1RequestHandler for ZwlrDataControlDeviceV1 {
|
||||
type Error = ZwlrDataControlDeviceV1Error;
|
||||
|
||||
fn set_selection(&self, req: SetSelection, _slf: &Rc<Self>) -> Result<(), Self::Error> {
|
||||
let src = self.use_source(req.source, IpcLocation::Clipboard)?;
|
||||
self.seat.set_selection(src)?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn destroy(&self, parser: MsgParser<'_, '_>) -> Result<(), ZwlrDataControlDeviceV1Error> {
|
||||
let _req: Destroy = self.client.parse(self, parser)?;
|
||||
fn destroy(&self, _req: Destroy, _slf: &Rc<Self>) -> Result<(), Self::Error> {
|
||||
destroy_data_device::<WlrClipboardIpc>(self);
|
||||
destroy_data_device::<WlrPrimarySelectionIpc>(self);
|
||||
self.seat.remove_wlr_device(self);
|
||||
|
|
@ -117,9 +118,9 @@ impl ZwlrDataControlDeviceV1 {
|
|||
|
||||
fn set_primary_selection(
|
||||
&self,
|
||||
parser: MsgParser<'_, '_>,
|
||||
) -> Result<(), ZwlrDataControlDeviceV1Error> {
|
||||
let req: SetPrimarySelection = self.client.parse(self, parser)?;
|
||||
req: SetPrimarySelection,
|
||||
_slf: &Rc<Self>,
|
||||
) -> Result<(), Self::Error> {
|
||||
let src = self.use_source(req.source, IpcLocation::PrimarySelection)?;
|
||||
self.seat.set_primary_selection(src)?;
|
||||
Ok(())
|
||||
|
|
@ -276,10 +277,7 @@ impl<T: WlrIpc> IpcVtable for WlrIpcImpl<T> {
|
|||
|
||||
object_base! {
|
||||
self = ZwlrDataControlDeviceV1;
|
||||
|
||||
SET_SELECTION => set_selection,
|
||||
DESTROY => destroy,
|
||||
SET_PRIMARY_SELECTION => set_primary_selection if self.version >= 2,
|
||||
version = self.version;
|
||||
}
|
||||
|
||||
impl Object for ZwlrDataControlDeviceV1 {
|
||||
|
|
@ -292,8 +290,6 @@ simple_add_obj!(ZwlrDataControlDeviceV1);
|
|||
|
||||
#[derive(Debug, Error)]
|
||||
pub enum ZwlrDataControlDeviceV1Error {
|
||||
#[error("Parsing failed")]
|
||||
MsgParserError(#[source] Box<MsgParserError>),
|
||||
#[error(transparent)]
|
||||
ClientError(Box<ClientError>),
|
||||
#[error(transparent)]
|
||||
|
|
@ -301,6 +297,5 @@ pub enum ZwlrDataControlDeviceV1Error {
|
|||
#[error("The source has already been used")]
|
||||
AlreadyUsed,
|
||||
}
|
||||
efrom!(ZwlrDataControlDeviceV1Error, MsgParserError);
|
||||
efrom!(ZwlrDataControlDeviceV1Error, ClientError);
|
||||
efrom!(ZwlrDataControlDeviceV1Error, WlSeatError);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue