xwayland: implement copy/paste
This commit is contained in:
parent
c8068ee2e7
commit
d6fabcb2b5
22 changed files with 1565 additions and 380 deletions
|
|
@ -1,14 +1,18 @@
|
|||
use {
|
||||
crate::{
|
||||
client::{Client, ClientError},
|
||||
ifs::ipc::{
|
||||
break_offer_loops, destroy_offer, receive,
|
||||
zwp_primary_selection_device_v1::ZwpPrimarySelectionDeviceV1, OfferData,
|
||||
ifs::{
|
||||
ipc::{
|
||||
break_offer_loops, destroy_data_offer, receive_data_offer,
|
||||
zwp_primary_selection_device_v1::PrimarySelectionIpc, OfferData,
|
||||
},
|
||||
wl_seat::WlSeatGlobal,
|
||||
},
|
||||
leaks::Tracker,
|
||||
object::Object,
|
||||
utils::buffd::{MsgParser, MsgParserError},
|
||||
wire::{zwp_primary_selection_offer_v1::*, ZwpPrimarySelectionOfferV1Id},
|
||||
xwayland::XWaylandEvent,
|
||||
},
|
||||
std::rc::Rc,
|
||||
thiserror::Error,
|
||||
|
|
@ -16,28 +20,43 @@ use {
|
|||
|
||||
pub struct ZwpPrimarySelectionOfferV1 {
|
||||
pub id: ZwpPrimarySelectionOfferV1Id,
|
||||
pub u64_id: u64,
|
||||
pub seat: Rc<WlSeatGlobal>,
|
||||
pub client: Rc<Client>,
|
||||
pub offer_data: OfferData<ZwpPrimarySelectionDeviceV1>,
|
||||
pub data: OfferData<PrimarySelectionIpc>,
|
||||
pub tracker: Tracker<Self>,
|
||||
}
|
||||
|
||||
impl ZwpPrimarySelectionOfferV1 {
|
||||
pub fn send_offer(&self, mime_type: &str) {
|
||||
self.client.event(Offer {
|
||||
self_id: self.id,
|
||||
mime_type,
|
||||
})
|
||||
pub fn send_offer(self: &Rc<Self>, mime_type: &str) {
|
||||
if self.data.is_xwm {
|
||||
if let Some(src) = self.data.source.get() {
|
||||
if !src.data.is_xwm {
|
||||
self.client.state.xwayland.queue.push(
|
||||
XWaylandEvent::PrimarySelectionAddOfferMimeType(
|
||||
self.clone(),
|
||||
mime_type.to_string(),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
self.client.event(Offer {
|
||||
self_id: self.id,
|
||||
mime_type,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
fn receive(&self, parser: MsgParser<'_, '_>) -> Result<(), ZwpPrimarySelectionOfferV1Error> {
|
||||
let req: Receive = self.client.parse(self, parser)?;
|
||||
receive::<ZwpPrimarySelectionDeviceV1>(self, req.mime_type, req.fd);
|
||||
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)?;
|
||||
destroy_offer::<ZwpPrimarySelectionDeviceV1>(self);
|
||||
destroy_data_offer::<PrimarySelectionIpc>(self);
|
||||
self.client.remove_obj(self)?;
|
||||
Ok(())
|
||||
}
|
||||
|
|
@ -56,7 +75,7 @@ impl Object for ZwpPrimarySelectionOfferV1 {
|
|||
}
|
||||
|
||||
fn break_loops(&self) {
|
||||
break_offer_loops::<ZwpPrimarySelectionDeviceV1>(self);
|
||||
break_offer_loops::<PrimarySelectionIpc>(self);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue