wire: generate trait for request handling
This commit is contained in:
parent
e3a1a0b30f
commit
acb391335b
102 changed files with 1632 additions and 2086 deletions
|
|
@ -13,7 +13,6 @@ use {
|
|||
},
|
||||
leaks::Tracker,
|
||||
object::{Object, Version},
|
||||
utils::buffd::{MsgParser, MsgParserError},
|
||||
wire::{wl_data_device::*, WlDataDeviceId, WlDataOfferId, WlSurfaceId},
|
||||
},
|
||||
std::rc::Rc,
|
||||
|
|
@ -98,9 +97,12 @@ impl WlDataDevice {
|
|||
pub fn send_drop(&self) {
|
||||
self.client.event(Drop { self_id: self.id })
|
||||
}
|
||||
}
|
||||
|
||||
fn start_drag(&self, parser: MsgParser<'_, '_>) -> Result<(), WlDataDeviceError> {
|
||||
let req: StartDrag = self.client.parse(self, parser)?;
|
||||
impl WlDataDeviceRequestHandler for WlDataDevice {
|
||||
type Error = WlDataDeviceError;
|
||||
|
||||
fn start_drag(&self, req: StartDrag, _slf: &Rc<Self>) -> Result<(), Self::Error> {
|
||||
if !self.client.valid_serial(req.serial) {
|
||||
log::warn!("Client tried to start_drag with an invalid serial");
|
||||
return Ok(());
|
||||
|
|
@ -122,8 +124,7 @@ impl WlDataDevice {
|
|||
Ok(())
|
||||
}
|
||||
|
||||
fn set_selection(&self, parser: MsgParser<'_, '_>) -> Result<(), WlDataDeviceError> {
|
||||
let req: SetSelection = self.client.parse(self, parser)?;
|
||||
fn set_selection(&self, req: SetSelection, _slf: &Rc<Self>) -> Result<(), Self::Error> {
|
||||
if !self.client.valid_serial(req.serial) {
|
||||
log::warn!("Client tried to set_selection with an invalid serial");
|
||||
return Ok(());
|
||||
|
|
@ -142,8 +143,7 @@ impl WlDataDevice {
|
|||
Ok(())
|
||||
}
|
||||
|
||||
fn release(&self, parser: MsgParser<'_, '_>) -> Result<(), WlDataDeviceError> {
|
||||
let _req: Release = self.client.parse(self, parser)?;
|
||||
fn release(&self, _req: Release, _slf: &Rc<Self>) -> Result<(), Self::Error> {
|
||||
destroy_data_device::<ClipboardIpc>(self);
|
||||
self.seat.remove_data_device(self);
|
||||
self.client.remove_obj(self)?;
|
||||
|
|
@ -224,10 +224,7 @@ impl IpcVtable for ClipboardIpc {
|
|||
|
||||
object_base! {
|
||||
self = WlDataDevice;
|
||||
|
||||
START_DRAG => start_drag,
|
||||
SET_SELECTION => set_selection,
|
||||
RELEASE => release if self.version >= 2,
|
||||
version = self.version;
|
||||
}
|
||||
|
||||
impl Object for WlDataDevice {
|
||||
|
|
@ -241,8 +238,6 @@ simple_add_obj!(WlDataDevice);
|
|||
|
||||
#[derive(Debug, Error)]
|
||||
pub enum WlDataDeviceError {
|
||||
#[error("Parsing failed")]
|
||||
MsgParserError(#[source] Box<MsgParserError>),
|
||||
#[error(transparent)]
|
||||
ClientError(Box<ClientError>),
|
||||
#[error(transparent)]
|
||||
|
|
@ -250,7 +245,6 @@ pub enum WlDataDeviceError {
|
|||
#[error(transparent)]
|
||||
WlSurfaceError(Box<WlSurfaceError>),
|
||||
}
|
||||
efrom!(WlDataDeviceError, MsgParserError);
|
||||
efrom!(WlDataDeviceError, ClientError);
|
||||
efrom!(WlDataDeviceError, WlSeatError);
|
||||
efrom!(WlDataDeviceError, WlSurfaceError);
|
||||
|
|
|
|||
|
|
@ -5,7 +5,6 @@ use {
|
|||
ifs::ipc::{wl_data_device::WlDataDevice, wl_data_source::WlDataSource},
|
||||
leaks::Tracker,
|
||||
object::{Object, Version},
|
||||
utils::buffd::{MsgParser, MsgParserError},
|
||||
wire::{wl_data_device_manager::*, WlDataDeviceManagerId},
|
||||
},
|
||||
std::rc::Rc,
|
||||
|
|
@ -55,23 +54,21 @@ impl WlDataDeviceManagerGlobal {
|
|||
}
|
||||
}
|
||||
|
||||
impl WlDataDeviceManager {
|
||||
impl WlDataDeviceManagerRequestHandler for WlDataDeviceManager {
|
||||
type Error = WlDataDeviceManagerError;
|
||||
|
||||
fn create_data_source(
|
||||
&self,
|
||||
parser: MsgParser<'_, '_>,
|
||||
) -> Result<(), WlDataDeviceManagerError> {
|
||||
let req: CreateDataSource = self.client.parse(self, parser)?;
|
||||
req: CreateDataSource,
|
||||
_slf: &Rc<Self>,
|
||||
) -> Result<(), Self::Error> {
|
||||
let res = Rc::new(WlDataSource::new(req.id, &self.client, self.version));
|
||||
track!(self.client, res);
|
||||
self.client.add_client_obj(&res)?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn get_data_device(
|
||||
self: &Rc<Self>,
|
||||
parser: MsgParser<'_, '_>,
|
||||
) -> Result<(), WlDataDeviceManagerError> {
|
||||
let req: GetDataDevice = self.client.parse(&**self, parser)?;
|
||||
fn get_data_device(&self, req: GetDataDevice, _slf: &Rc<Self>) -> Result<(), Self::Error> {
|
||||
let seat = self.client.lookup(req.seat)?;
|
||||
let dev = Rc::new(WlDataDevice::new(
|
||||
req.id,
|
||||
|
|
@ -106,9 +103,7 @@ simple_add_global!(WlDataDeviceManagerGlobal);
|
|||
|
||||
object_base! {
|
||||
self = WlDataDeviceManager;
|
||||
|
||||
CREATE_DATA_SOURCE => create_data_source,
|
||||
GET_DATA_DEVICE => get_data_device,
|
||||
version = self.version;
|
||||
}
|
||||
|
||||
impl Object for WlDataDeviceManager {}
|
||||
|
|
@ -119,8 +114,5 @@ simple_add_obj!(WlDataDeviceManager);
|
|||
pub enum WlDataDeviceManagerError {
|
||||
#[error(transparent)]
|
||||
ClientError(Box<ClientError>),
|
||||
#[error("Parsing failed")]
|
||||
MsgParserError(#[source] Box<MsgParserError>),
|
||||
}
|
||||
efrom!(WlDataDeviceManagerError, ClientError);
|
||||
efrom!(WlDataDeviceManagerError, MsgParserError);
|
||||
|
|
|
|||
|
|
@ -14,10 +14,7 @@ use {
|
|||
},
|
||||
leaks::Tracker,
|
||||
object::Object,
|
||||
utils::{
|
||||
bitflags::BitflagsExt,
|
||||
buffd::{MsgParser, MsgParserError},
|
||||
},
|
||||
utils::bitflags::BitflagsExt,
|
||||
wire::{wl_data_offer::*, WlDataOfferId, WlSurfaceId},
|
||||
},
|
||||
std::rc::Rc,
|
||||
|
|
@ -113,9 +110,12 @@ impl WlDataOffer {
|
|||
dnd_action,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
fn accept(&self, parser: MsgParser<'_, '_>) -> Result<(), WlDataOfferError> {
|
||||
let req: Accept = self.client.parse(self, parser)?;
|
||||
impl WlDataOfferRequestHandler for WlDataOffer {
|
||||
type Error = WlDataOfferError;
|
||||
|
||||
fn accept(&self, req: Accept, _slf: &Rc<Self>) -> Result<(), Self::Error> {
|
||||
let _ = req.serial; // unused
|
||||
let mut state = self.data.shared.state.get();
|
||||
if state.contains(OFFER_STATE_FINISHED) {
|
||||
|
|
@ -133,8 +133,7 @@ impl WlDataOffer {
|
|||
Ok(())
|
||||
}
|
||||
|
||||
fn receive(&self, parser: MsgParser<'_, '_>) -> Result<(), WlDataOfferError> {
|
||||
let req: Receive = self.client.parse(self, parser)?;
|
||||
fn receive(&self, req: Receive, _slf: &Rc<Self>) -> Result<(), Self::Error> {
|
||||
if self.data.shared.state.get().contains(OFFER_STATE_FINISHED) {
|
||||
return Err(WlDataOfferError::AlreadyFinished);
|
||||
}
|
||||
|
|
@ -142,15 +141,13 @@ impl WlDataOffer {
|
|||
Ok(())
|
||||
}
|
||||
|
||||
fn destroy(&self, parser: MsgParser<'_, '_>) -> Result<(), WlDataOfferError> {
|
||||
let _req: Destroy = self.client.parse(self, parser)?;
|
||||
fn destroy(&self, _req: Destroy, _slf: &Rc<Self>) -> Result<(), Self::Error> {
|
||||
destroy_data_offer::<ClipboardIpc>(self);
|
||||
self.client.remove_obj(self)?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn finish(&self, parser: MsgParser<'_, '_>) -> Result<(), WlDataOfferError> {
|
||||
let _req: Finish = self.client.parse(self, parser)?;
|
||||
fn finish(&self, _req: Finish, _slf: &Rc<Self>) -> Result<(), Self::Error> {
|
||||
if self.data.shared.role.get() != Role::Dnd {
|
||||
return Err(WlDataOfferError::NotDnd);
|
||||
}
|
||||
|
|
@ -175,8 +172,7 @@ impl WlDataOffer {
|
|||
Ok(())
|
||||
}
|
||||
|
||||
fn set_actions(&self, parser: MsgParser<'_, '_>) -> Result<(), WlDataOfferError> {
|
||||
let req: SetActions = self.client.parse(self, parser)?;
|
||||
fn set_actions(&self, req: SetActions, _slf: &Rc<Self>) -> Result<(), Self::Error> {
|
||||
let state = self.data.shared.state.get();
|
||||
if state.contains(OFFER_STATE_FINISHED) {
|
||||
return Err(WlDataOfferError::AlreadyFinished);
|
||||
|
|
@ -201,12 +197,7 @@ impl WlDataOffer {
|
|||
|
||||
object_base! {
|
||||
self = WlDataOffer;
|
||||
|
||||
ACCEPT => accept,
|
||||
RECEIVE => receive,
|
||||
DESTROY => destroy,
|
||||
FINISH => finish if self.device.version >= 3,
|
||||
SET_ACTIONS => set_actions if self.device.version >= 3,
|
||||
version = self.device.version;
|
||||
}
|
||||
|
||||
impl Object for WlDataOffer {
|
||||
|
|
@ -221,8 +212,6 @@ simple_add_obj!(WlDataOffer);
|
|||
pub enum WlDataOfferError {
|
||||
#[error(transparent)]
|
||||
ClientError(Box<ClientError>),
|
||||
#[error("Parsing failed")]
|
||||
MsgParserError(#[source] Box<MsgParserError>),
|
||||
#[error("`finish` was already called")]
|
||||
AlreadyFinished,
|
||||
#[error("The drag operation is still ongoing")]
|
||||
|
|
@ -237,4 +226,3 @@ pub enum WlDataOfferError {
|
|||
MultiplePreferred,
|
||||
}
|
||||
efrom!(WlDataOfferError, ClientError);
|
||||
efrom!(WlDataOfferError, MsgParserError);
|
||||
|
|
|
|||
|
|
@ -19,12 +19,7 @@ use {
|
|||
},
|
||||
leaks::Tracker,
|
||||
object::{Object, Version},
|
||||
utils::{
|
||||
bitflags::BitflagsExt,
|
||||
buffd::{MsgParser, MsgParserError},
|
||||
cell_ext::CellExt,
|
||||
clonecell::CloneCell,
|
||||
},
|
||||
utils::{bitflags::BitflagsExt, cell_ext::CellExt, clonecell::CloneCell},
|
||||
wire::{wl_data_source::*, WlDataSourceId},
|
||||
},
|
||||
std::rc::Rc,
|
||||
|
|
@ -208,22 +203,23 @@ impl WlDataSource {
|
|||
.client
|
||||
.event(DndDropPerformed { self_id: self.id })
|
||||
}
|
||||
}
|
||||
|
||||
fn offer(&self, parser: MsgParser<'_, '_>) -> Result<(), WlDataSourceError> {
|
||||
let req: Offer = self.data.client.parse(self, parser)?;
|
||||
impl WlDataSourceRequestHandler for WlDataSource {
|
||||
type Error = WlDataSourceError;
|
||||
|
||||
fn offer(&self, req: Offer, _slf: &Rc<Self>) -> Result<(), Self::Error> {
|
||||
add_data_source_mime_type::<ClipboardIpc>(self, req.mime_type);
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn destroy(&self, parser: MsgParser<'_, '_>) -> Result<(), WlDataSourceError> {
|
||||
let _req: Destroy = self.data.client.parse(self, parser)?;
|
||||
fn destroy(&self, _req: Destroy, _slf: &Rc<Self>) -> Result<(), Self::Error> {
|
||||
destroy_data_source::<ClipboardIpc>(self);
|
||||
self.data.client.remove_obj(self)?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn set_actions(&self, parser: MsgParser<'_, '_>) -> Result<(), WlDataSourceError> {
|
||||
let req: SetActions = self.data.client.parse(self, parser)?;
|
||||
fn set_actions(&self, req: SetActions, _slf: &Rc<Self>) -> Result<(), Self::Error> {
|
||||
if self.data.actions.is_some() {
|
||||
return Err(WlDataSourceError::AlreadySet);
|
||||
}
|
||||
|
|
@ -237,10 +233,7 @@ impl WlDataSource {
|
|||
|
||||
object_base! {
|
||||
self = WlDataSource;
|
||||
|
||||
OFFER => offer,
|
||||
DESTROY => destroy,
|
||||
SET_ACTIONS => set_actions if self.version >= 3,
|
||||
version = self.version;
|
||||
}
|
||||
|
||||
impl Object for WlDataSource {
|
||||
|
|
@ -254,8 +247,6 @@ dedicated_add_obj!(WlDataSource, WlDataSourceId, wl_data_source);
|
|||
|
||||
#[derive(Debug, Error)]
|
||||
pub enum WlDataSourceError {
|
||||
#[error("Parsing failed")]
|
||||
MsgParserError(#[source] Box<MsgParserError>),
|
||||
#[error(transparent)]
|
||||
ClientError(Box<ClientError>),
|
||||
#[error("The set of actions is invalid")]
|
||||
|
|
@ -264,4 +255,3 @@ pub enum WlDataSourceError {
|
|||
AlreadySet,
|
||||
}
|
||||
efrom!(WlDataSourceError, ClientError);
|
||||
efrom!(WlDataSourceError, MsgParserError);
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -8,7 +8,6 @@ use {
|
|||
},
|
||||
leaks::Tracker,
|
||||
object::{Object, Version},
|
||||
utils::buffd::{MsgParser, MsgParserError},
|
||||
wire::{zwlr_data_control_manager_v1::*, ZwlrDataControlManagerV1Id},
|
||||
},
|
||||
std::rc::Rc,
|
||||
|
|
@ -49,12 +48,14 @@ impl ZwlrDataControlManagerV1Global {
|
|||
}
|
||||
}
|
||||
|
||||
impl ZwlrDataControlManagerV1 {
|
||||
impl ZwlrDataControlManagerV1RequestHandler for ZwlrDataControlManagerV1 {
|
||||
type Error = ZwlrDataControlManagerV1Error;
|
||||
|
||||
fn create_data_source(
|
||||
&self,
|
||||
parser: MsgParser<'_, '_>,
|
||||
) -> Result<(), ZwlrDataControlManagerV1Error> {
|
||||
let req: CreateDataSource = self.client.parse(self, parser)?;
|
||||
req: CreateDataSource,
|
||||
_slf: &Rc<Self>,
|
||||
) -> Result<(), Self::Error> {
|
||||
let res = Rc::new(ZwlrDataControlSourceV1::new(
|
||||
req.id,
|
||||
&self.client,
|
||||
|
|
@ -65,11 +66,7 @@ impl ZwlrDataControlManagerV1 {
|
|||
Ok(())
|
||||
}
|
||||
|
||||
fn get_data_device(
|
||||
self: &Rc<Self>,
|
||||
parser: MsgParser<'_, '_>,
|
||||
) -> Result<(), ZwlrDataControlManagerV1Error> {
|
||||
let req: GetDataDevice = self.client.parse(&**self, parser)?;
|
||||
fn get_data_device(&self, req: GetDataDevice, _slf: &Rc<Self>) -> Result<(), Self::Error> {
|
||||
let seat = self.client.lookup(req.seat)?;
|
||||
let dev = Rc::new(ZwlrDataControlDeviceV1::new(
|
||||
req.id,
|
||||
|
|
@ -93,8 +90,7 @@ impl ZwlrDataControlManagerV1 {
|
|||
Ok(())
|
||||
}
|
||||
|
||||
fn destroy(&self, parser: MsgParser<'_, '_>) -> Result<(), ZwlrDataControlManagerV1Error> {
|
||||
let _req: Destroy = self.client.parse(self, parser)?;
|
||||
fn destroy(&self, _req: Destroy, _slf: &Rc<Self>) -> Result<(), Self::Error> {
|
||||
self.client.remove_obj(self)?;
|
||||
Ok(())
|
||||
}
|
||||
|
|
@ -124,10 +120,7 @@ simple_add_global!(ZwlrDataControlManagerV1Global);
|
|||
|
||||
object_base! {
|
||||
self = ZwlrDataControlManagerV1;
|
||||
|
||||
CREATE_DATA_SOURCE => create_data_source,
|
||||
GET_DATA_DEVICE => get_data_device,
|
||||
DESTROY => destroy,
|
||||
version = self.version;
|
||||
}
|
||||
|
||||
impl Object for ZwlrDataControlManagerV1 {}
|
||||
|
|
@ -138,8 +131,5 @@ simple_add_obj!(ZwlrDataControlManagerV1);
|
|||
pub enum ZwlrDataControlManagerV1Error {
|
||||
#[error(transparent)]
|
||||
ClientError(Box<ClientError>),
|
||||
#[error("Parsing failed")]
|
||||
MsgParserError(#[source] Box<MsgParserError>),
|
||||
}
|
||||
efrom!(ZwlrDataControlManagerV1Error, ClientError);
|
||||
efrom!(ZwlrDataControlManagerV1Error, MsgParserError);
|
||||
|
|
|
|||
|
|
@ -13,7 +13,6 @@ use {
|
|||
},
|
||||
leaks::Tracker,
|
||||
object::Object,
|
||||
utils::buffd::{MsgParser, MsgParserError},
|
||||
wire::{zwlr_data_control_offer_v1::*, ZwlrDataControlOfferV1Id},
|
||||
},
|
||||
std::rc::Rc,
|
||||
|
|
@ -81,9 +80,12 @@ impl ZwlrDataControlOfferV1 {
|
|||
mime_type,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
fn receive(&self, parser: MsgParser<'_, '_>) -> Result<(), ZwlrDataControlOfferV1Error> {
|
||||
let req: Receive = self.client.parse(self, parser)?;
|
||||
impl ZwlrDataControlOfferV1RequestHandler for ZwlrDataControlOfferV1 {
|
||||
type Error = ZwlrDataControlOfferV1Error;
|
||||
|
||||
fn receive(&self, req: Receive, _slf: &Rc<Self>) -> Result<(), Self::Error> {
|
||||
match self.location {
|
||||
IpcLocation::Clipboard => {
|
||||
receive_data_offer::<WlrClipboardIpc>(self, req.mime_type, req.fd)
|
||||
|
|
@ -95,8 +97,7 @@ impl ZwlrDataControlOfferV1 {
|
|||
Ok(())
|
||||
}
|
||||
|
||||
fn destroy(&self, parser: MsgParser<'_, '_>) -> Result<(), ZwlrDataControlOfferV1Error> {
|
||||
let _req: Destroy = self.client.parse(self, parser)?;
|
||||
fn destroy(&self, _req: Destroy, _slf: &Rc<Self>) -> Result<(), Self::Error> {
|
||||
match self.location {
|
||||
IpcLocation::Clipboard => destroy_data_offer::<WlrClipboardIpc>(self),
|
||||
IpcLocation::PrimarySelection => destroy_data_offer::<WlrPrimarySelectionIpc>(self),
|
||||
|
|
@ -108,9 +109,7 @@ impl ZwlrDataControlOfferV1 {
|
|||
|
||||
object_base! {
|
||||
self = ZwlrDataControlOfferV1;
|
||||
|
||||
RECEIVE => receive,
|
||||
DESTROY => destroy,
|
||||
version = self.device.version;
|
||||
}
|
||||
|
||||
impl Object for ZwlrDataControlOfferV1 {
|
||||
|
|
@ -128,8 +127,5 @@ simple_add_obj!(ZwlrDataControlOfferV1);
|
|||
pub enum ZwlrDataControlOfferV1Error {
|
||||
#[error(transparent)]
|
||||
ClientError(Box<ClientError>),
|
||||
#[error("Parsing failed")]
|
||||
MsgParserError(#[source] Box<MsgParserError>),
|
||||
}
|
||||
efrom!(ZwlrDataControlOfferV1Error, ClientError);
|
||||
efrom!(ZwlrDataControlOfferV1Error, MsgParserError);
|
||||
|
|
|
|||
|
|
@ -18,7 +18,6 @@ use {
|
|||
},
|
||||
leaks::Tracker,
|
||||
object::{Object, Version},
|
||||
utils::buffd::{MsgParser, MsgParserError},
|
||||
wire::{zwlr_data_control_source_v1::*, ZwlrDataControlSourceV1Id},
|
||||
},
|
||||
std::{cell::Cell, rc::Rc},
|
||||
|
|
@ -113,9 +112,12 @@ impl ZwlrDataControlSourceV1 {
|
|||
pub fn send_cancelled(&self) {
|
||||
self.data.client.event(Cancelled { self_id: self.id })
|
||||
}
|
||||
}
|
||||
|
||||
fn offer(&self, parser: MsgParser<'_, '_>) -> Result<(), ZwlrDataControlSourceV1Error> {
|
||||
let req: Offer = self.data.client.parse(self, parser)?;
|
||||
impl ZwlrDataControlSourceV1RequestHandler for ZwlrDataControlSourceV1 {
|
||||
type Error = ZwlrDataControlSourceV1Error;
|
||||
|
||||
fn offer(&self, req: Offer, _slf: &Rc<Self>) -> Result<(), Self::Error> {
|
||||
if self.used.get() {
|
||||
return Err(ZwlrDataControlSourceV1Error::AlreadyUsed);
|
||||
}
|
||||
|
|
@ -123,8 +125,7 @@ impl ZwlrDataControlSourceV1 {
|
|||
Ok(())
|
||||
}
|
||||
|
||||
fn destroy(&self, parser: MsgParser<'_, '_>) -> Result<(), ZwlrDataControlSourceV1Error> {
|
||||
let _req: Destroy = self.data.client.parse(self, parser)?;
|
||||
fn destroy(&self, _req: Destroy, _slf: &Rc<Self>) -> Result<(), Self::Error> {
|
||||
match self.location.get() {
|
||||
IpcLocation::Clipboard => destroy_data_source::<WlrClipboardIpc>(self),
|
||||
IpcLocation::PrimarySelection => destroy_data_source::<WlrPrimarySelectionIpc>(self),
|
||||
|
|
@ -136,9 +137,7 @@ impl ZwlrDataControlSourceV1 {
|
|||
|
||||
object_base! {
|
||||
self = ZwlrDataControlSourceV1;
|
||||
|
||||
OFFER => offer,
|
||||
DESTROY => destroy,
|
||||
version = self.version;
|
||||
}
|
||||
|
||||
impl Object for ZwlrDataControlSourceV1 {
|
||||
|
|
@ -158,12 +157,9 @@ dedicated_add_obj!(
|
|||
|
||||
#[derive(Debug, Error)]
|
||||
pub enum ZwlrDataControlSourceV1Error {
|
||||
#[error("Parsing failed")]
|
||||
MsgParserError(#[source] Box<MsgParserError>),
|
||||
#[error(transparent)]
|
||||
ClientError(Box<ClientError>),
|
||||
#[error("The source has already been used")]
|
||||
AlreadyUsed,
|
||||
}
|
||||
efrom!(ZwlrDataControlSourceV1Error, ClientError);
|
||||
efrom!(ZwlrDataControlSourceV1Error, MsgParserError);
|
||||
|
|
|
|||
|
|
@ -8,7 +8,6 @@ use {
|
|||
},
|
||||
leaks::Tracker,
|
||||
object::{Object, Version},
|
||||
utils::buffd::{MsgParser, MsgParserError},
|
||||
wire::{zwp_primary_selection_device_manager_v1::*, ZwpPrimarySelectionDeviceManagerV1Id},
|
||||
},
|
||||
std::rc::Rc,
|
||||
|
|
@ -49,23 +48,21 @@ impl ZwpPrimarySelectionDeviceManagerV1Global {
|
|||
}
|
||||
}
|
||||
|
||||
impl ZwpPrimarySelectionDeviceManagerV1 {
|
||||
fn create_source(
|
||||
&self,
|
||||
parser: MsgParser<'_, '_>,
|
||||
) -> Result<(), ZwpPrimarySelectionDeviceManagerV1Error> {
|
||||
let req: CreateSource = self.client.parse(self, parser)?;
|
||||
let res = Rc::new(ZwpPrimarySelectionSourceV1::new(req.id, &self.client));
|
||||
impl ZwpPrimarySelectionDeviceManagerV1RequestHandler for ZwpPrimarySelectionDeviceManagerV1 {
|
||||
type Error = ZwpPrimarySelectionDeviceManagerV1Error;
|
||||
|
||||
fn create_source(&self, req: CreateSource, _slf: &Rc<Self>) -> Result<(), Self::Error> {
|
||||
let res = Rc::new(ZwpPrimarySelectionSourceV1::new(
|
||||
req.id,
|
||||
&self.client,
|
||||
self.version,
|
||||
));
|
||||
track!(self.client, res);
|
||||
self.client.add_client_obj(&res)?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn get_data_device(
|
||||
self: &Rc<Self>,
|
||||
parser: MsgParser<'_, '_>,
|
||||
) -> Result<(), ZwpPrimarySelectionDeviceManagerV1Error> {
|
||||
let req: GetDevice = self.client.parse(&**self, parser)?;
|
||||
fn get_device(&self, req: GetDevice, _slf: &Rc<Self>) -> Result<(), Self::Error> {
|
||||
let seat = self.client.lookup(req.seat)?;
|
||||
let dev = Rc::new(ZwpPrimarySelectionDeviceV1::new(
|
||||
req.id,
|
||||
|
|
@ -79,11 +76,7 @@ impl ZwpPrimarySelectionDeviceManagerV1 {
|
|||
Ok(())
|
||||
}
|
||||
|
||||
fn destroy(
|
||||
&self,
|
||||
parser: MsgParser<'_, '_>,
|
||||
) -> Result<(), ZwpPrimarySelectionDeviceManagerV1Error> {
|
||||
let _req: Destroy = self.client.parse(self, parser)?;
|
||||
fn destroy(&self, _req: Destroy, _slf: &Rc<Self>) -> Result<(), Self::Error> {
|
||||
self.client.remove_obj(self)?;
|
||||
Ok(())
|
||||
}
|
||||
|
|
@ -109,10 +102,7 @@ simple_add_global!(ZwpPrimarySelectionDeviceManagerV1Global);
|
|||
|
||||
object_base! {
|
||||
self = ZwpPrimarySelectionDeviceManagerV1;
|
||||
|
||||
CREATE_SOURCE => create_source,
|
||||
GET_DEVICE => get_data_device,
|
||||
DESTROY => destroy,
|
||||
version = self.version;
|
||||
}
|
||||
|
||||
impl Object for ZwpPrimarySelectionDeviceManagerV1 {}
|
||||
|
|
@ -121,10 +111,7 @@ simple_add_obj!(ZwpPrimarySelectionDeviceManagerV1);
|
|||
|
||||
#[derive(Debug, Error)]
|
||||
pub enum ZwpPrimarySelectionDeviceManagerV1Error {
|
||||
#[error("Parsing failed")]
|
||||
MsgParserError(#[source] Box<MsgParserError>),
|
||||
#[error(transparent)]
|
||||
ClientError(Box<ClientError>),
|
||||
}
|
||||
efrom!(ZwpPrimarySelectionDeviceManagerV1Error, ClientError);
|
||||
efrom!(ZwpPrimarySelectionDeviceManagerV1Error, MsgParserError);
|
||||
|
|
|
|||
|
|
@ -12,7 +12,6 @@ use {
|
|||
},
|
||||
leaks::Tracker,
|
||||
object::{Object, Version},
|
||||
utils::buffd::{MsgParser, MsgParserError},
|
||||
wire::{
|
||||
zwp_primary_selection_device_v1::*, ZwpPrimarySelectionDeviceV1Id,
|
||||
ZwpPrimarySelectionOfferV1Id,
|
||||
|
|
@ -64,12 +63,12 @@ impl ZwpPrimarySelectionDeviceV1 {
|
|||
id,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
fn set_selection(
|
||||
&self,
|
||||
parser: MsgParser<'_, '_>,
|
||||
) -> Result<(), ZwpPrimarySelectionDeviceV1Error> {
|
||||
let req: SetSelection = self.client.parse(self, parser)?;
|
||||
impl ZwpPrimarySelectionDeviceV1RequestHandler for ZwpPrimarySelectionDeviceV1 {
|
||||
type Error = ZwpPrimarySelectionDeviceV1Error;
|
||||
|
||||
fn set_selection(&self, req: SetSelection, _slf: &Rc<Self>) -> Result<(), Self::Error> {
|
||||
if !self.client.valid_serial(req.serial) {
|
||||
log::warn!("Client tried to set_selection with an invalid serial");
|
||||
return Ok(());
|
||||
|
|
@ -90,8 +89,7 @@ impl ZwpPrimarySelectionDeviceV1 {
|
|||
Ok(())
|
||||
}
|
||||
|
||||
fn destroy(&self, parser: MsgParser<'_, '_>) -> Result<(), ZwpPrimarySelectionDeviceV1Error> {
|
||||
let _req: Destroy = self.client.parse(self, parser)?;
|
||||
fn destroy(&self, _req: Destroy, _slf: &Rc<Self>) -> Result<(), Self::Error> {
|
||||
destroy_data_device::<PrimarySelectionIpc>(self);
|
||||
self.seat.remove_primary_selection_device(self);
|
||||
self.client.remove_obj(self)?;
|
||||
|
|
@ -144,6 +142,7 @@ impl IpcVtable for PrimarySelectionIpc {
|
|||
client: device.client.clone(),
|
||||
data: offer_data,
|
||||
tracker: Default::default(),
|
||||
version: device.version,
|
||||
});
|
||||
track!(device.client, rc);
|
||||
device.client.add_server_obj(&rc);
|
||||
|
|
@ -169,9 +168,7 @@ impl IpcVtable for PrimarySelectionIpc {
|
|||
|
||||
object_base! {
|
||||
self = ZwpPrimarySelectionDeviceV1;
|
||||
|
||||
SET_SELECTION => set_selection,
|
||||
DESTROY => destroy,
|
||||
version = self.version;
|
||||
}
|
||||
|
||||
impl Object for ZwpPrimarySelectionDeviceV1 {
|
||||
|
|
@ -187,11 +184,8 @@ simple_add_obj!(ZwpPrimarySelectionDeviceV1);
|
|||
pub enum ZwpPrimarySelectionDeviceV1Error {
|
||||
#[error(transparent)]
|
||||
ClientError(Box<ClientError>),
|
||||
#[error("Parsing failed")]
|
||||
MsgParserError(#[source] Box<MsgParserError>),
|
||||
#[error(transparent)]
|
||||
WlSeatError(Box<WlSeatError>),
|
||||
}
|
||||
efrom!(ZwpPrimarySelectionDeviceV1Error, ClientError);
|
||||
efrom!(ZwpPrimarySelectionDeviceV1Error, MsgParserError);
|
||||
efrom!(ZwpPrimarySelectionDeviceV1Error, WlSeatError);
|
||||
|
|
|
|||
|
|
@ -12,8 +12,7 @@ use {
|
|||
wl_seat::WlSeatGlobal,
|
||||
},
|
||||
leaks::Tracker,
|
||||
object::Object,
|
||||
utils::buffd::{MsgParser, MsgParserError},
|
||||
object::{Object, Version},
|
||||
wire::{zwp_primary_selection_offer_v1::*, ZwpPrimarySelectionOfferV1Id},
|
||||
},
|
||||
std::rc::Rc,
|
||||
|
|
@ -27,6 +26,7 @@ pub struct ZwpPrimarySelectionOfferV1 {
|
|||
pub client: Rc<Client>,
|
||||
pub data: OfferData<ZwpPrimarySelectionDeviceV1>,
|
||||
pub tracker: Tracker<Self>,
|
||||
pub version: Version,
|
||||
}
|
||||
|
||||
impl DataOffer for ZwpPrimarySelectionOfferV1 {
|
||||
|
|
@ -70,15 +70,17 @@ impl ZwpPrimarySelectionOfferV1 {
|
|||
mime_type,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
fn receive(&self, parser: MsgParser<'_, '_>) -> Result<(), ZwpPrimarySelectionOfferV1Error> {
|
||||
let req: Receive = self.client.parse(self, parser)?;
|
||||
impl ZwpPrimarySelectionOfferV1RequestHandler for ZwpPrimarySelectionOfferV1 {
|
||||
type Error = ZwpPrimarySelectionOfferV1Error;
|
||||
|
||||
fn receive(&self, req: Receive, _slf: &Rc<Self>) -> Result<(), Self::Error> {
|
||||
receive_data_offer::<PrimarySelectionIpc>(self, req.mime_type, req.fd);
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn destroy(&self, parser: MsgParser<'_, '_>) -> Result<(), ZwpPrimarySelectionOfferV1Error> {
|
||||
let _req: Destroy = self.client.parse(self, parser)?;
|
||||
fn destroy(&self, _req: Destroy, _slf: &Rc<Self>) -> Result<(), Self::Error> {
|
||||
destroy_data_offer::<PrimarySelectionIpc>(self);
|
||||
self.client.remove_obj(self)?;
|
||||
Ok(())
|
||||
|
|
@ -87,9 +89,7 @@ impl ZwpPrimarySelectionOfferV1 {
|
|||
|
||||
object_base! {
|
||||
self = ZwpPrimarySelectionOfferV1;
|
||||
|
||||
RECEIVE => receive,
|
||||
DESTROY => destroy,
|
||||
version = self.version;
|
||||
}
|
||||
|
||||
impl Object for ZwpPrimarySelectionOfferV1 {
|
||||
|
|
@ -102,10 +102,7 @@ simple_add_obj!(ZwpPrimarySelectionOfferV1);
|
|||
|
||||
#[derive(Debug, Error)]
|
||||
pub enum ZwpPrimarySelectionOfferV1Error {
|
||||
#[error("Parsing failed")]
|
||||
MsgParserError(#[source] Box<MsgParserError>),
|
||||
#[error(transparent)]
|
||||
ClientError(Box<ClientError>),
|
||||
}
|
||||
efrom!(ZwpPrimarySelectionOfferV1Error, ClientError);
|
||||
efrom!(ZwpPrimarySelectionOfferV1Error, MsgParserError);
|
||||
|
|
|
|||
|
|
@ -14,8 +14,7 @@ use {
|
|||
wl_seat::WlSeatGlobal,
|
||||
},
|
||||
leaks::Tracker,
|
||||
object::Object,
|
||||
utils::buffd::{MsgParser, MsgParserError},
|
||||
object::{Object, Version},
|
||||
wire::{zwp_primary_selection_source_v1::*, ZwpPrimarySelectionSourceV1Id},
|
||||
},
|
||||
std::rc::Rc,
|
||||
|
|
@ -27,6 +26,7 @@ pub struct ZwpPrimarySelectionSourceV1 {
|
|||
pub id: ZwpPrimarySelectionSourceV1Id,
|
||||
pub data: SourceData,
|
||||
pub tracker: Tracker<Self>,
|
||||
pub version: Version,
|
||||
}
|
||||
|
||||
impl DataSource for ZwpPrimarySelectionSourceV1 {
|
||||
|
|
@ -66,11 +66,12 @@ impl DynDataSource for ZwpPrimarySelectionSourceV1 {
|
|||
}
|
||||
|
||||
impl ZwpPrimarySelectionSourceV1 {
|
||||
pub fn new(id: ZwpPrimarySelectionSourceV1Id, client: &Rc<Client>) -> Self {
|
||||
pub fn new(id: ZwpPrimarySelectionSourceV1Id, client: &Rc<Client>, version: Version) -> Self {
|
||||
Self {
|
||||
id,
|
||||
data: SourceData::new(client),
|
||||
tracker: Default::default(),
|
||||
version,
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -85,15 +86,17 @@ impl ZwpPrimarySelectionSourceV1 {
|
|||
fd,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
fn offer(&self, parser: MsgParser<'_, '_>) -> Result<(), ZwpPrimarySelectionSourceV1Error> {
|
||||
let req: Offer = self.data.client.parse(self, parser)?;
|
||||
impl ZwpPrimarySelectionSourceV1RequestHandler for ZwpPrimarySelectionSourceV1 {
|
||||
type Error = ZwpPrimarySelectionSourceV1Error;
|
||||
|
||||
fn offer(&self, req: Offer, _slf: &Rc<Self>) -> Result<(), Self::Error> {
|
||||
add_data_source_mime_type::<PrimarySelectionIpc>(self, req.mime_type);
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn destroy(&self, parser: MsgParser<'_, '_>) -> Result<(), ZwpPrimarySelectionSourceV1Error> {
|
||||
let _req: Destroy = self.data.client.parse(self, parser)?;
|
||||
fn destroy(&self, _req: Destroy, _slf: &Rc<Self>) -> Result<(), Self::Error> {
|
||||
destroy_data_source::<PrimarySelectionIpc>(self);
|
||||
self.data.client.remove_obj(self)?;
|
||||
Ok(())
|
||||
|
|
@ -102,9 +105,7 @@ impl ZwpPrimarySelectionSourceV1 {
|
|||
|
||||
object_base! {
|
||||
self = ZwpPrimarySelectionSourceV1;
|
||||
|
||||
OFFER => offer,
|
||||
DESTROY => destroy,
|
||||
version = self.version;
|
||||
}
|
||||
|
||||
impl Object for ZwpPrimarySelectionSourceV1 {
|
||||
|
|
@ -123,8 +124,5 @@ dedicated_add_obj!(
|
|||
pub enum ZwpPrimarySelectionSourceV1Error {
|
||||
#[error(transparent)]
|
||||
ClientError(Box<ClientError>),
|
||||
#[error("Parsing failed")]
|
||||
MsgParserError(#[source] Box<MsgParserError>),
|
||||
}
|
||||
efrom!(ZwpPrimarySelectionSourceV1Error, ClientError);
|
||||
efrom!(ZwpPrimarySelectionSourceV1Error, MsgParserError);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue