ipc: use trait objects for source/offer
This commit is contained in:
parent
7cbe5720c6
commit
4e9dacce1a
11 changed files with 418 additions and 220 deletions
|
|
@ -5,8 +5,7 @@ use {
|
|||
ifs::{
|
||||
ipc::{
|
||||
break_device_loops, destroy_data_device, wl_data_offer::WlDataOffer,
|
||||
wl_data_source::WlDataSource, DataOfferId, DeviceData, IpcVtable, OfferData, Role,
|
||||
SourceData,
|
||||
wl_data_source::WlDataSource, DeviceData, IpcVtable, OfferData, Role, XIpcVtable,
|
||||
},
|
||||
wl_seat::{WlSeatError, WlSeatGlobal},
|
||||
wl_surface::{SurfaceRole, WlSurfaceError},
|
||||
|
|
@ -19,7 +18,6 @@ use {
|
|||
},
|
||||
std::rc::Rc,
|
||||
thiserror::Error,
|
||||
uapi::OwnedFd,
|
||||
};
|
||||
|
||||
#[allow(dead_code)]
|
||||
|
|
@ -30,7 +28,7 @@ pub struct WlDataDevice {
|
|||
pub client: Rc<Client>,
|
||||
pub version: u32,
|
||||
pub seat: Rc<WlSeatGlobal>,
|
||||
pub data: DeviceData<ClipboardIpc>,
|
||||
pub data: DeviceData<WlDataOffer>,
|
||||
pub tracker: Tracker<Self>,
|
||||
}
|
||||
|
||||
|
|
@ -171,7 +169,8 @@ impl WlDataDevice {
|
|||
} else {
|
||||
Some(self.client.lookup(req.source)?)
|
||||
};
|
||||
self.seat.set_selection(src, Some(req.serial))?;
|
||||
self.seat
|
||||
.set_wl_data_source_selection(src, Some(req.serial))?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
|
|
@ -186,12 +185,22 @@ impl WlDataDevice {
|
|||
|
||||
pub struct ClipboardIpc;
|
||||
|
||||
impl XIpcVtable for ClipboardIpc {
|
||||
fn create_xwm_source(client: &Rc<Client>) -> Self::Source {
|
||||
WlDataSource::new(WlDataSourceId::NONE, client, true, 3)
|
||||
}
|
||||
|
||||
fn remove_from_seat(device: &Self::Device) {
|
||||
device.seat.remove_data_device(device);
|
||||
}
|
||||
}
|
||||
|
||||
impl IpcVtable for ClipboardIpc {
|
||||
type Device = WlDataDevice;
|
||||
type Source = WlDataSource;
|
||||
type Offer = WlDataOffer;
|
||||
|
||||
fn get_device_data(dd: &Self::Device) -> &DeviceData<Self> {
|
||||
fn get_device_data(dd: &Self::Device) -> &DeviceData<Self::Offer> {
|
||||
&dd.data
|
||||
}
|
||||
|
||||
|
|
@ -199,24 +208,12 @@ impl IpcVtable for ClipboardIpc {
|
|||
dd.seat.clone()
|
||||
}
|
||||
|
||||
fn create_xwm_source(client: &Rc<Client>) -> Self::Source {
|
||||
WlDataSource::new(WlDataSourceId::NONE, client, true, 3)
|
||||
}
|
||||
|
||||
fn set_seat_selection(
|
||||
seat: &Rc<WlSeatGlobal>,
|
||||
source: &Rc<Self::Source>,
|
||||
serial: Option<u32>,
|
||||
) -> Result<(), WlSeatError> {
|
||||
seat.set_selection(Some(source.clone()), serial)
|
||||
}
|
||||
|
||||
fn get_offer_data(offer: &Self::Offer) -> &OfferData<Self> {
|
||||
&offer.data
|
||||
}
|
||||
|
||||
fn get_source_data(src: &Self::Source) -> &SourceData<Self> {
|
||||
&src.data
|
||||
seat.set_wl_data_source_selection(Some(source.clone()), serial)
|
||||
}
|
||||
|
||||
fn for_each_device<C>(seat: &WlSeatGlobal, client: ClientId, f: C)
|
||||
|
|
@ -229,7 +226,7 @@ impl IpcVtable for ClipboardIpc {
|
|||
fn create_offer(
|
||||
client: &Rc<Client>,
|
||||
device: &Rc<WlDataDevice>,
|
||||
offer_data: OfferData<Self>,
|
||||
offer_data: OfferData<Self::Device>,
|
||||
) -> Result<Rc<Self::Offer>, ClientError> {
|
||||
let rc = Rc::new(WlDataOffer {
|
||||
id: client.new_id()?,
|
||||
|
|
@ -247,40 +244,16 @@ impl IpcVtable for ClipboardIpc {
|
|||
dd.send_selection(offer);
|
||||
}
|
||||
|
||||
fn send_cancelled(source: &Rc<Self::Source>, seat: &Rc<WlSeatGlobal>) {
|
||||
source.send_cancelled(seat);
|
||||
}
|
||||
|
||||
fn get_offer_id(offer: &Self::Offer) -> DataOfferId {
|
||||
offer.offer_id
|
||||
}
|
||||
|
||||
fn send_offer(dd: &Self::Device, offer: &Rc<Self::Offer>) {
|
||||
dd.send_data_offer(offer);
|
||||
}
|
||||
|
||||
fn send_mime_type(offer: &Rc<Self::Offer>, mime_type: &str) {
|
||||
offer.send_offer(mime_type);
|
||||
}
|
||||
|
||||
fn unset(seat: &Rc<WlSeatGlobal>, role: Role) {
|
||||
match role {
|
||||
Role::Selection => seat.unset_selection(),
|
||||
Role::Dnd => seat.cancel_dnd(),
|
||||
}
|
||||
}
|
||||
|
||||
fn send_send(src: &Rc<Self::Source>, mime_type: &str, fd: Rc<OwnedFd>) {
|
||||
src.send_send(mime_type, fd);
|
||||
}
|
||||
|
||||
fn remove_from_seat(device: &Self::Device) {
|
||||
device.seat.remove_data_device(device);
|
||||
}
|
||||
|
||||
fn get_offer_seat(offer: &Self::Offer) -> Rc<WlSeatGlobal> {
|
||||
offer.device.seat.clone()
|
||||
}
|
||||
}
|
||||
|
||||
object_base! {
|
||||
|
|
|
|||
|
|
@ -1,12 +1,16 @@
|
|||
use {
|
||||
crate::{
|
||||
client::{Client, ClientError},
|
||||
ifs::ipc::{
|
||||
break_offer_loops, destroy_data_offer, receive_data_offer,
|
||||
wl_data_device::{ClipboardIpc, WlDataDevice},
|
||||
wl_data_device_manager::DND_ALL,
|
||||
DataOfferId, OfferData, Role, OFFER_STATE_ACCEPTED, OFFER_STATE_DROPPED,
|
||||
OFFER_STATE_FINISHED, SOURCE_STATE_FINISHED,
|
||||
client::{Client, ClientError, ClientId},
|
||||
fixed::Fixed,
|
||||
ifs::{
|
||||
ipc::{
|
||||
break_offer_loops, cancel_offer, destroy_data_offer, receive_data_offer,
|
||||
wl_data_device::{ClipboardIpc, WlDataDevice},
|
||||
wl_data_device_manager::DND_ALL,
|
||||
DataOffer, DataOfferId, DynDataOffer, OfferData, Role, OFFER_STATE_ACCEPTED,
|
||||
OFFER_STATE_DROPPED, OFFER_STATE_FINISHED, SOURCE_STATE_FINISHED,
|
||||
},
|
||||
wl_seat::WlSeatGlobal,
|
||||
},
|
||||
leaks::Tracker,
|
||||
object::Object,
|
||||
|
|
@ -14,7 +18,7 @@ use {
|
|||
bitflags::BitflagsExt,
|
||||
buffd::{MsgParser, MsgParserError},
|
||||
},
|
||||
wire::{wl_data_offer::*, WlDataOfferId},
|
||||
wire::{wl_data_offer::*, WlDataOfferId, WlSurfaceId},
|
||||
xwayland::XWaylandEvent,
|
||||
},
|
||||
std::rc::Rc,
|
||||
|
|
@ -35,15 +39,61 @@ pub struct WlDataOffer {
|
|||
pub offer_id: DataOfferId,
|
||||
pub client: Rc<Client>,
|
||||
pub device: Rc<WlDataDevice>,
|
||||
pub data: OfferData<ClipboardIpc>,
|
||||
pub data: OfferData<WlDataDevice>,
|
||||
pub tracker: Tracker<Self>,
|
||||
}
|
||||
|
||||
impl DataOffer for WlDataOffer {
|
||||
type Device = WlDataDevice;
|
||||
|
||||
fn offer_data(&self) -> &OfferData<Self::Device> {
|
||||
&self.data
|
||||
}
|
||||
}
|
||||
|
||||
impl DynDataOffer for WlDataOffer {
|
||||
fn offer_id(&self) -> DataOfferId {
|
||||
self.offer_id
|
||||
}
|
||||
|
||||
fn client_id(&self) -> ClientId {
|
||||
self.client.id
|
||||
}
|
||||
|
||||
fn send_action(&self, action: u32) {
|
||||
WlDataOffer::send_action(self, action);
|
||||
}
|
||||
|
||||
fn send_offer(self: Rc<Self>, mime_type: &str) {
|
||||
WlDataOffer::send_offer(&self, mime_type);
|
||||
}
|
||||
|
||||
fn destroy(&self) {
|
||||
destroy_data_offer::<ClipboardIpc>(self);
|
||||
}
|
||||
|
||||
fn cancel(&self) {
|
||||
cancel_offer::<ClipboardIpc>(self);
|
||||
}
|
||||
|
||||
fn send_enter(&self, surface: WlSurfaceId, x: Fixed, y: Fixed, serial: u32) {
|
||||
self.device.send_enter(surface, x, y, self.id, serial);
|
||||
}
|
||||
|
||||
fn send_source_actions(&self) {
|
||||
WlDataOffer::send_source_actions(self);
|
||||
}
|
||||
|
||||
fn get_seat(&self) -> Rc<WlSeatGlobal> {
|
||||
self.device.seat.clone()
|
||||
}
|
||||
}
|
||||
|
||||
impl WlDataOffer {
|
||||
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 {
|
||||
if !src.source_data().is_xwm {
|
||||
self.client.state.xwayland.queue.push(
|
||||
XWaylandEvent::ClipboardAddOfferMimeType(
|
||||
self.clone(),
|
||||
|
|
@ -63,7 +113,7 @@ impl WlDataOffer {
|
|||
pub fn send_source_actions(&self) {
|
||||
if !self.data.is_xwm {
|
||||
if let Some(src) = self.data.source.get() {
|
||||
if let Some(source_actions) = src.data.actions.get() {
|
||||
if let Some(source_actions) = src.source_data().actions.get() {
|
||||
self.client.event(SourceActions {
|
||||
self_id: self.id,
|
||||
source_actions,
|
||||
|
|
@ -134,7 +184,7 @@ impl WlDataOffer {
|
|||
}
|
||||
state |= OFFER_STATE_FINISHED;
|
||||
if let Some(src) = self.data.source.get() {
|
||||
src.data.state.or_assign(SOURCE_STATE_FINISHED);
|
||||
src.source_data().state.or_assign(SOURCE_STATE_FINISHED);
|
||||
src.send_dnd_finished();
|
||||
} else {
|
||||
log::error!("no source");
|
||||
|
|
|
|||
|
|
@ -4,11 +4,12 @@ use {
|
|||
ifs::{
|
||||
ipc::{
|
||||
add_data_source_mime_type, break_source_loops, cancel_offers, destroy_data_source,
|
||||
detach_seat, offer_source_to,
|
||||
wl_data_device::ClipboardIpc,
|
||||
wl_data_device_manager::{DND_ALL, DND_NONE},
|
||||
wl_data_offer::WlDataOffer,
|
||||
SharedState, SourceData, OFFER_STATE_ACCEPTED, OFFER_STATE_DROPPED,
|
||||
SOURCE_STATE_CANCELLED, SOURCE_STATE_DROPPED,
|
||||
DataSource, DynDataOffer, DynDataSource, SharedState, SourceData,
|
||||
OFFER_STATE_ACCEPTED, OFFER_STATE_DROPPED, SOURCE_STATE_CANCELLED,
|
||||
SOURCE_STATE_DROPPED,
|
||||
},
|
||||
wl_seat::WlSeatGlobal,
|
||||
xdg_toplevel_drag_v1::XdgToplevelDragV1,
|
||||
|
|
@ -36,12 +37,52 @@ const INVALID_SOURCE: u32 = 1;
|
|||
|
||||
pub struct WlDataSource {
|
||||
pub id: WlDataSourceId,
|
||||
pub data: SourceData<ClipboardIpc>,
|
||||
pub data: SourceData,
|
||||
pub version: u32,
|
||||
pub tracker: Tracker<Self>,
|
||||
pub toplevel_drag: CloneCell<Option<Rc<XdgToplevelDragV1>>>,
|
||||
}
|
||||
|
||||
impl DataSource for WlDataSource {
|
||||
fn send_cancelled(self: &Rc<Self>, seat: &Rc<WlSeatGlobal>) {
|
||||
WlDataSource::send_cancelled(self, seat);
|
||||
}
|
||||
}
|
||||
|
||||
impl DynDataSource for WlDataSource {
|
||||
fn source_data(&self) -> &SourceData {
|
||||
&self.data
|
||||
}
|
||||
|
||||
fn send_send(self: Rc<Self>, mime_type: &str, fd: Rc<OwnedFd>) {
|
||||
WlDataSource::send_send(&self, mime_type, fd);
|
||||
}
|
||||
|
||||
fn offer_to(self: Rc<Self>, client: &Rc<Client>) {
|
||||
offer_source_to::<ClipboardIpc, Self>(&self, client);
|
||||
}
|
||||
|
||||
fn detach_seat(self: Rc<Self>, seat: &Rc<WlSeatGlobal>) {
|
||||
detach_seat::<ClipboardIpc>(&self, seat);
|
||||
}
|
||||
|
||||
fn cancel_offers(&self) {
|
||||
cancel_offers::<ClipboardIpc>(self);
|
||||
}
|
||||
|
||||
fn send_target(&self, mime_type: Option<&str>) {
|
||||
WlDataSource::send_target(self, mime_type);
|
||||
}
|
||||
|
||||
fn send_dnd_finished(&self) {
|
||||
WlDataSource::send_dnd_finished(self);
|
||||
}
|
||||
|
||||
fn update_selected_action(&self) {
|
||||
WlDataSource::update_selected_action(self);
|
||||
}
|
||||
}
|
||||
|
||||
impl WlDataSource {
|
||||
pub fn new(id: WlDataSourceId, client: &Rc<Client>, is_xwm: bool, version: u32) -> Self {
|
||||
Self {
|
||||
|
|
@ -97,9 +138,9 @@ impl WlDataSource {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn for_each_data_offer<C: FnMut(&WlDataOffer)>(&self, mut f: C) {
|
||||
pub fn for_each_data_offer<C: FnMut(&dyn DynDataOffer)>(&self, mut f: C) {
|
||||
for (_, offer) in &self.data.offers {
|
||||
f(&offer);
|
||||
f(&*offer);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -5,8 +5,8 @@ use {
|
|||
ipc::{
|
||||
break_device_loops, destroy_data_device,
|
||||
zwp_primary_selection_offer_v1::ZwpPrimarySelectionOfferV1,
|
||||
zwp_primary_selection_source_v1::ZwpPrimarySelectionSourceV1, DataOfferId,
|
||||
DeviceData, IpcVtable, OfferData, Role, SourceData,
|
||||
zwp_primary_selection_source_v1::ZwpPrimarySelectionSourceV1, DeviceData,
|
||||
IpcVtable, OfferData, Role, XIpcVtable,
|
||||
},
|
||||
wl_seat::{WlSeatError, WlSeatGlobal},
|
||||
},
|
||||
|
|
@ -21,7 +21,6 @@ use {
|
|||
},
|
||||
std::rc::Rc,
|
||||
thiserror::Error,
|
||||
uapi::OwnedFd,
|
||||
};
|
||||
|
||||
pub struct ZwpPrimarySelectionDeviceV1 {
|
||||
|
|
@ -29,7 +28,7 @@ pub struct ZwpPrimarySelectionDeviceV1 {
|
|||
pub client: Rc<Client>,
|
||||
pub version: u32,
|
||||
pub seat: Rc<WlSeatGlobal>,
|
||||
data: DeviceData<PrimarySelectionIpc>,
|
||||
data: DeviceData<ZwpPrimarySelectionOfferV1>,
|
||||
pub tracker: Tracker<Self>,
|
||||
}
|
||||
|
||||
|
|
@ -112,7 +111,7 @@ impl ZwpPrimarySelectionDeviceV1 {
|
|||
} else {
|
||||
Some(self.client.lookup(req.source)?)
|
||||
};
|
||||
self.seat.set_primary_selection(src, Some(req.serial))?;
|
||||
self.seat.set_zwp_primary_selection(src, Some(req.serial))?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
|
|
@ -127,12 +126,22 @@ impl ZwpPrimarySelectionDeviceV1 {
|
|||
|
||||
pub struct PrimarySelectionIpc;
|
||||
|
||||
impl XIpcVtable for PrimarySelectionIpc {
|
||||
fn create_xwm_source(client: &Rc<Client>) -> Self::Source {
|
||||
ZwpPrimarySelectionSourceV1::new(ZwpPrimarySelectionSourceV1Id::NONE, client, true)
|
||||
}
|
||||
|
||||
fn remove_from_seat(device: &Self::Device) {
|
||||
device.seat.remove_primary_selection_device(device);
|
||||
}
|
||||
}
|
||||
|
||||
impl IpcVtable for PrimarySelectionIpc {
|
||||
type Device = ZwpPrimarySelectionDeviceV1;
|
||||
type Source = ZwpPrimarySelectionSourceV1;
|
||||
type Offer = ZwpPrimarySelectionOfferV1;
|
||||
|
||||
fn get_device_data(dd: &Self::Device) -> &DeviceData<Self> {
|
||||
fn get_device_data(dd: &Self::Device) -> &DeviceData<Self::Offer> {
|
||||
&dd.data
|
||||
}
|
||||
|
||||
|
|
@ -140,24 +149,12 @@ impl IpcVtable for PrimarySelectionIpc {
|
|||
dd.seat.clone()
|
||||
}
|
||||
|
||||
fn create_xwm_source(client: &Rc<Client>) -> Self::Source {
|
||||
ZwpPrimarySelectionSourceV1::new(ZwpPrimarySelectionSourceV1Id::NONE, client, true)
|
||||
}
|
||||
|
||||
fn set_seat_selection(
|
||||
seat: &Rc<WlSeatGlobal>,
|
||||
source: &Rc<Self::Source>,
|
||||
serial: Option<u32>,
|
||||
) -> Result<(), WlSeatError> {
|
||||
seat.set_primary_selection(Some(source.clone()), serial)
|
||||
}
|
||||
|
||||
fn get_offer_data(offer: &Self::Offer) -> &OfferData<Self> {
|
||||
&offer.data
|
||||
}
|
||||
|
||||
fn get_source_data(src: &Self::Source) -> &SourceData<Self> {
|
||||
&src.data
|
||||
seat.set_zwp_primary_selection(Some(source.clone()), serial)
|
||||
}
|
||||
|
||||
fn for_each_device<C>(seat: &WlSeatGlobal, client: ClientId, f: C)
|
||||
|
|
@ -170,7 +167,7 @@ impl IpcVtable for PrimarySelectionIpc {
|
|||
fn create_offer(
|
||||
client: &Rc<Client>,
|
||||
device: &Rc<ZwpPrimarySelectionDeviceV1>,
|
||||
offer_data: OfferData<Self>,
|
||||
offer_data: OfferData<Self::Device>,
|
||||
) -> Result<Rc<Self::Offer>, ClientError> {
|
||||
let id = if device.data.is_xwm {
|
||||
ZwpPrimarySelectionOfferV1Id::NONE
|
||||
|
|
@ -193,37 +190,13 @@ impl IpcVtable for PrimarySelectionIpc {
|
|||
dd.send_selection(offer);
|
||||
}
|
||||
|
||||
fn send_cancelled(source: &Rc<Self::Source>, _seat: &Rc<WlSeatGlobal>) {
|
||||
source.send_cancelled();
|
||||
}
|
||||
|
||||
fn get_offer_id(offer: &Self::Offer) -> DataOfferId {
|
||||
offer.offer_id
|
||||
}
|
||||
|
||||
fn send_offer(dd: &Self::Device, offer: &Rc<Self::Offer>) {
|
||||
dd.send_data_offer(offer);
|
||||
}
|
||||
|
||||
fn send_mime_type(offer: &Rc<Self::Offer>, mime_type: &str) {
|
||||
offer.send_offer(mime_type);
|
||||
}
|
||||
|
||||
fn unset(seat: &Rc<WlSeatGlobal>, _role: Role) {
|
||||
seat.unset_primary_selection();
|
||||
}
|
||||
|
||||
fn send_send(src: &Rc<Self::Source>, mime_type: &str, fd: Rc<OwnedFd>) {
|
||||
src.send_send(mime_type, fd);
|
||||
}
|
||||
|
||||
fn remove_from_seat(device: &Self::Device) {
|
||||
device.seat.remove_primary_selection_device(device);
|
||||
}
|
||||
|
||||
fn get_offer_seat(offer: &Self::Offer) -> Rc<WlSeatGlobal> {
|
||||
offer.seat.clone()
|
||||
}
|
||||
}
|
||||
|
||||
object_base! {
|
||||
|
|
|
|||
|
|
@ -1,10 +1,13 @@
|
|||
use {
|
||||
crate::{
|
||||
client::{Client, ClientError},
|
||||
client::{Client, ClientError, ClientId},
|
||||
ifs::{
|
||||
ipc::{
|
||||
break_offer_loops, destroy_data_offer, receive_data_offer,
|
||||
zwp_primary_selection_device_v1::PrimarySelectionIpc, DataOfferId, OfferData,
|
||||
break_offer_loops, cancel_offer, destroy_data_offer, receive_data_offer,
|
||||
zwp_primary_selection_device_v1::{
|
||||
PrimarySelectionIpc, ZwpPrimarySelectionDeviceV1,
|
||||
},
|
||||
DataOffer, DataOfferId, DynDataOffer, OfferData,
|
||||
},
|
||||
wl_seat::WlSeatGlobal,
|
||||
},
|
||||
|
|
@ -23,15 +26,49 @@ pub struct ZwpPrimarySelectionOfferV1 {
|
|||
pub offer_id: DataOfferId,
|
||||
pub seat: Rc<WlSeatGlobal>,
|
||||
pub client: Rc<Client>,
|
||||
pub data: OfferData<PrimarySelectionIpc>,
|
||||
pub data: OfferData<ZwpPrimarySelectionDeviceV1>,
|
||||
pub tracker: Tracker<Self>,
|
||||
}
|
||||
|
||||
impl DataOffer for ZwpPrimarySelectionOfferV1 {
|
||||
type Device = ZwpPrimarySelectionDeviceV1;
|
||||
|
||||
fn offer_data(&self) -> &OfferData<Self::Device> {
|
||||
&self.data
|
||||
}
|
||||
}
|
||||
|
||||
impl DynDataOffer for ZwpPrimarySelectionOfferV1 {
|
||||
fn offer_id(&self) -> DataOfferId {
|
||||
self.offer_id
|
||||
}
|
||||
|
||||
fn client_id(&self) -> ClientId {
|
||||
self.client.id
|
||||
}
|
||||
|
||||
fn send_offer(self: Rc<Self>, mime_type: &str) {
|
||||
ZwpPrimarySelectionOfferV1::send_offer(&self, mime_type);
|
||||
}
|
||||
|
||||
fn destroy(&self) {
|
||||
destroy_data_offer::<PrimarySelectionIpc>(self);
|
||||
}
|
||||
|
||||
fn cancel(&self) {
|
||||
cancel_offer::<PrimarySelectionIpc>(self);
|
||||
}
|
||||
|
||||
fn get_seat(&self) -> Rc<WlSeatGlobal> {
|
||||
self.seat.clone()
|
||||
}
|
||||
}
|
||||
|
||||
impl ZwpPrimarySelectionOfferV1 {
|
||||
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 {
|
||||
if !src.source_data().is_xwm {
|
||||
self.client.state.xwayland.queue.push(
|
||||
XWaylandEvent::PrimarySelectionAddOfferMimeType(
|
||||
self.clone(),
|
||||
|
|
|
|||
|
|
@ -1,9 +1,13 @@
|
|||
use {
|
||||
crate::{
|
||||
client::{Client, ClientError},
|
||||
ifs::ipc::{
|
||||
add_data_source_mime_type, break_source_loops, destroy_data_source,
|
||||
zwp_primary_selection_device_v1::PrimarySelectionIpc, SourceData,
|
||||
ifs::{
|
||||
ipc::{
|
||||
add_data_source_mime_type, break_source_loops, cancel_offers, destroy_data_source,
|
||||
detach_seat, offer_source_to, zwp_primary_selection_device_v1::PrimarySelectionIpc,
|
||||
DataSource, DynDataSource, SourceData,
|
||||
},
|
||||
wl_seat::WlSeatGlobal,
|
||||
},
|
||||
leaks::Tracker,
|
||||
object::Object,
|
||||
|
|
@ -18,10 +22,38 @@ use {
|
|||
|
||||
pub struct ZwpPrimarySelectionSourceV1 {
|
||||
pub id: ZwpPrimarySelectionSourceV1Id,
|
||||
pub data: SourceData<PrimarySelectionIpc>,
|
||||
pub data: SourceData,
|
||||
pub tracker: Tracker<Self>,
|
||||
}
|
||||
|
||||
impl DataSource for ZwpPrimarySelectionSourceV1 {
|
||||
fn send_cancelled(self: &Rc<Self>, _seat: &Rc<WlSeatGlobal>) {
|
||||
ZwpPrimarySelectionSourceV1::send_cancelled(self);
|
||||
}
|
||||
}
|
||||
|
||||
impl DynDataSource for ZwpPrimarySelectionSourceV1 {
|
||||
fn source_data(&self) -> &SourceData {
|
||||
&self.data
|
||||
}
|
||||
|
||||
fn send_send(self: Rc<Self>, mime_type: &str, fd: Rc<OwnedFd>) {
|
||||
ZwpPrimarySelectionSourceV1::send_send(&self, mime_type, fd)
|
||||
}
|
||||
|
||||
fn offer_to(self: Rc<Self>, client: &Rc<Client>) {
|
||||
offer_source_to::<PrimarySelectionIpc, Self>(&self, client);
|
||||
}
|
||||
|
||||
fn detach_seat(self: Rc<Self>, seat: &Rc<WlSeatGlobal>) {
|
||||
detach_seat::<PrimarySelectionIpc>(&self, seat);
|
||||
}
|
||||
|
||||
fn cancel_offers(&self) {
|
||||
cancel_offers::<PrimarySelectionIpc>(self);
|
||||
}
|
||||
}
|
||||
|
||||
impl ZwpPrimarySelectionSourceV1 {
|
||||
pub fn new(id: ZwpPrimarySelectionSourceV1Id, client: &Rc<Client>, is_xwm: bool) -> Self {
|
||||
Self {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue