ipc: remove DynDataSource::offer_to_regular/wlr
This commit is contained in:
parent
487efafdf5
commit
40f7bc2542
8 changed files with 31 additions and 110 deletions
|
|
@ -64,9 +64,7 @@ pub trait DataSource: DynDataSource {
|
|||
pub trait DynDataSource: 'static {
|
||||
fn source_data(&self) -> &SourceData;
|
||||
fn send_send(&self, mime_type: &str, fd: Rc<OwnedFd>);
|
||||
fn offer_to_regular_client(self: Rc<Self>, client: &Rc<Client>);
|
||||
fn offer_to_x(self: Rc<Self>, dd: &Rc<XIpcDevice>);
|
||||
fn offer_to_wlr_device(self: Rc<Self>, dd: &Rc<ZwlrDataControlDeviceV1>);
|
||||
fn detach_seat(&self, seat: &Rc<WlSeatGlobal>);
|
||||
fn cancel_unprivileged_offers(&self);
|
||||
|
||||
|
|
@ -315,8 +313,8 @@ pub fn detach_seat<S: DataSource>(src: &S, seat: &Rc<WlSeatGlobal>) {
|
|||
// data.client.flush();
|
||||
}
|
||||
|
||||
fn offer_source_to_device<T: IpcVtable, S: DynDataSource>(
|
||||
src: &Rc<S>,
|
||||
fn offer_source_to_device<T: IpcVtable>(
|
||||
src: &Rc<dyn DynDataSource>,
|
||||
dd: &Rc<T::Device>,
|
||||
data: &SourceData,
|
||||
shared: Rc<SharedState>,
|
||||
|
|
@ -351,31 +349,29 @@ fn offer_source_to_device<T: IpcVtable, S: DynDataSource>(
|
|||
}
|
||||
}
|
||||
|
||||
fn offer_source_to_x<T, S>(src: &Rc<S>, dd: &Rc<XIpcDevice>)
|
||||
fn offer_source_to_x<T>(src: Rc<dyn DynDataSource>, dd: &Rc<XIpcDevice>)
|
||||
where
|
||||
T: IpcVtable<Device = XIpcDevice>,
|
||||
S: DynDataSource,
|
||||
{
|
||||
let data = src.source_data();
|
||||
src.cancel_unprivileged_offers();
|
||||
let shared = data.shared.get();
|
||||
shared.role.set(data.role.get());
|
||||
offer_source_to_device::<T, S>(src, dd, data, shared);
|
||||
offer_source_to_device::<T>(&src, dd, data, shared);
|
||||
}
|
||||
|
||||
pub fn offer_source_to_wlr_device<T, S>(src: &Rc<S>, dd: &Rc<T::Device>)
|
||||
pub fn offer_source_to_wlr_device<T>(src: Rc<dyn DynDataSource>, dd: &Rc<T::Device>)
|
||||
where
|
||||
T: IpcVtable<Device = ZwlrDataControlDeviceV1>,
|
||||
S: DynDataSource,
|
||||
{
|
||||
let data = src.source_data();
|
||||
let shared = data.shared.get();
|
||||
shared.role.set(data.role.get());
|
||||
offer_source_to_device::<T, _>(src, dd, data, shared);
|
||||
offer_source_to_device::<T>(&src, dd, data, shared);
|
||||
}
|
||||
|
||||
fn offer_source_to_regular_client<T: IterableIpcVtable, S: DynDataSource>(
|
||||
src: &Rc<S>,
|
||||
pub fn offer_source_to_regular_client<T: IterableIpcVtable>(
|
||||
src: Rc<dyn DynDataSource>,
|
||||
client: &Rc<Client>,
|
||||
) {
|
||||
let data = src.source_data();
|
||||
|
|
@ -390,7 +386,7 @@ fn offer_source_to_regular_client<T: IterableIpcVtable, S: DynDataSource>(
|
|||
let shared = data.shared.get();
|
||||
shared.role.set(data.role.get());
|
||||
T::for_each_device(&seat, client.id, |dd| {
|
||||
offer_source_to_device::<T, S>(src, dd, data, shared.clone());
|
||||
offer_source_to_device::<T>(&src, dd, data, shared.clone());
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -4,12 +4,10 @@ use {
|
|||
ifs::{
|
||||
ipc::{
|
||||
add_data_source_mime_type, break_source_loops, cancel_offers, destroy_data_source,
|
||||
detach_seat, offer_source_to_regular_client, offer_source_to_wlr_device,
|
||||
offer_source_to_x,
|
||||
detach_seat, offer_source_to_x,
|
||||
wl_data_device::ClipboardIpc,
|
||||
wl_data_device_manager::{DND_ALL, DND_NONE},
|
||||
x_data_device::{XClipboardIpc, XIpcDevice},
|
||||
zwlr_data_control_device_v1::{WlrClipboardIpc, ZwlrDataControlDeviceV1},
|
||||
DataSource, DynDataOffer, DynDataSource, SharedState, SourceData,
|
||||
OFFER_STATE_ACCEPTED, OFFER_STATE_DROPPED, SOURCE_STATE_CANCELLED,
|
||||
SOURCE_STATE_DROPPED,
|
||||
|
|
@ -55,16 +53,8 @@ impl DynDataSource for WlDataSource {
|
|||
WlDataSource::send_send(self, mime_type, fd);
|
||||
}
|
||||
|
||||
fn offer_to_regular_client(self: Rc<Self>, client: &Rc<Client>) {
|
||||
offer_source_to_regular_client::<ClipboardIpc, Self>(&self, client);
|
||||
}
|
||||
|
||||
fn offer_to_x(self: Rc<Self>, dd: &Rc<XIpcDevice>) {
|
||||
offer_source_to_x::<XClipboardIpc, Self>(&self, dd);
|
||||
}
|
||||
|
||||
fn offer_to_wlr_device(self: Rc<Self>, dd: &Rc<ZwlrDataControlDeviceV1>) {
|
||||
offer_source_to_wlr_device::<WlrClipboardIpc, Self>(&self, dd)
|
||||
offer_source_to_x::<XClipboardIpc>(self, dd);
|
||||
}
|
||||
|
||||
fn detach_seat(&self, seat: &Rc<WlSeatGlobal>) {
|
||||
|
|
|
|||
|
|
@ -1,17 +1,9 @@
|
|||
use {
|
||||
crate::{
|
||||
client::Client,
|
||||
ifs::{
|
||||
ipc::{
|
||||
cancel_offers, detach_seat, offer_source_to_regular_client,
|
||||
offer_source_to_wlr_device,
|
||||
wl_data_device::ClipboardIpc,
|
||||
x_data_device::XIpcDevice,
|
||||
zwlr_data_control_device_v1::{
|
||||
WlrClipboardIpc, WlrPrimarySelectionIpc, ZwlrDataControlDeviceV1,
|
||||
},
|
||||
zwp_primary_selection_device_v1::PrimarySelectionIpc,
|
||||
DataSource, DynDataSource, IpcLocation, SourceData,
|
||||
cancel_offers, detach_seat, x_data_device::XIpcDevice, DataSource, DynDataSource,
|
||||
IpcLocation, SourceData,
|
||||
},
|
||||
wl_seat::WlSeatGlobal,
|
||||
},
|
||||
|
|
@ -54,17 +46,6 @@ impl DynDataSource for XDataSource {
|
|||
});
|
||||
}
|
||||
|
||||
fn offer_to_regular_client(self: Rc<Self>, client: &Rc<Client>) {
|
||||
match self.location {
|
||||
IpcLocation::Clipboard => {
|
||||
offer_source_to_regular_client::<ClipboardIpc, Self>(&self, client)
|
||||
}
|
||||
IpcLocation::PrimarySelection => {
|
||||
offer_source_to_regular_client::<PrimarySelectionIpc, Self>(&self, client)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn offer_to_x(self: Rc<Self>, _dd: &Rc<XIpcDevice>) {
|
||||
self.cancel_unprivileged_offers();
|
||||
self.state.xwayland.queue.push(IpcSetSelection {
|
||||
|
|
@ -74,17 +55,6 @@ impl DynDataSource for XDataSource {
|
|||
});
|
||||
}
|
||||
|
||||
fn offer_to_wlr_device(self: Rc<Self>, dd: &Rc<ZwlrDataControlDeviceV1>) {
|
||||
match self.location {
|
||||
IpcLocation::Clipboard => {
|
||||
offer_source_to_wlr_device::<WlrClipboardIpc, Self>(&self, dd)
|
||||
}
|
||||
IpcLocation::PrimarySelection => {
|
||||
offer_source_to_wlr_device::<WlrPrimarySelectionIpc, Self>(&self, dd)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn detach_seat(&self, seat: &Rc<WlSeatGlobal>) {
|
||||
detach_seat(self, seat);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,7 +3,11 @@ use {
|
|||
client::{Client, ClientCaps, ClientError, CAP_DATA_CONTROL_MANAGER},
|
||||
globals::{Global, GlobalName},
|
||||
ifs::ipc::{
|
||||
zwlr_data_control_device_v1::{ZwlrDataControlDeviceV1, PRIMARY_SELECTION_SINCE},
|
||||
offer_source_to_wlr_device,
|
||||
zwlr_data_control_device_v1::{
|
||||
WlrClipboardIpc, WlrPrimarySelectionIpc, ZwlrDataControlDeviceV1,
|
||||
PRIMARY_SELECTION_SINCE,
|
||||
},
|
||||
zwlr_data_control_source_v1::ZwlrDataControlSourceV1,
|
||||
},
|
||||
leaks::Tracker,
|
||||
|
|
@ -78,12 +82,12 @@ impl ZwlrDataControlManagerV1RequestHandler for ZwlrDataControlManagerV1 {
|
|||
seat.global.add_wlr_device(&dev);
|
||||
self.client.add_client_obj(&dev)?;
|
||||
match seat.global.get_selection() {
|
||||
Some(s) => s.offer_to_wlr_device(&dev),
|
||||
Some(s) => offer_source_to_wlr_device::<WlrClipboardIpc>(s, &dev),
|
||||
_ => dev.send_selection(None),
|
||||
}
|
||||
if self.version >= PRIMARY_SELECTION_SINCE {
|
||||
match seat.global.get_primary_selection() {
|
||||
Some(s) => s.offer_to_wlr_device(&dev),
|
||||
Some(s) => offer_source_to_wlr_device::<WlrPrimarySelectionIpc>(s, &dev),
|
||||
_ => dev.send_primary_selection(None),
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,14 +4,9 @@ use {
|
|||
ifs::{
|
||||
ipc::{
|
||||
add_data_source_mime_type, break_source_loops, cancel_offers, destroy_data_source,
|
||||
detach_seat, offer_source_to_regular_client, offer_source_to_wlr_device,
|
||||
offer_source_to_x,
|
||||
wl_data_device::ClipboardIpc,
|
||||
detach_seat, offer_source_to_x,
|
||||
x_data_device::{XClipboardIpc, XIpcDevice, XPrimarySelectionIpc},
|
||||
zwlr_data_control_device_v1::{
|
||||
WlrClipboardIpc, WlrPrimarySelectionIpc, ZwlrDataControlDeviceV1,
|
||||
},
|
||||
zwp_primary_selection_device_v1::PrimarySelectionIpc,
|
||||
zwlr_data_control_device_v1::{WlrClipboardIpc, WlrPrimarySelectionIpc},
|
||||
DataSource, DynDataSource, IpcLocation, SourceData,
|
||||
},
|
||||
wl_seat::WlSeatGlobal,
|
||||
|
|
@ -49,34 +44,10 @@ impl DynDataSource for ZwlrDataControlSourceV1 {
|
|||
ZwlrDataControlSourceV1::send_send(&self, mime_type, fd);
|
||||
}
|
||||
|
||||
fn offer_to_regular_client(self: Rc<Self>, client: &Rc<Client>) {
|
||||
match self.location.get() {
|
||||
IpcLocation::Clipboard => {
|
||||
offer_source_to_regular_client::<ClipboardIpc, Self>(&self, client)
|
||||
}
|
||||
IpcLocation::PrimarySelection => {
|
||||
offer_source_to_regular_client::<PrimarySelectionIpc, Self>(&self, client)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn offer_to_x(self: Rc<Self>, dd: &Rc<XIpcDevice>) {
|
||||
match self.location.get() {
|
||||
IpcLocation::Clipboard => offer_source_to_x::<XClipboardIpc, Self>(&self, dd),
|
||||
IpcLocation::PrimarySelection => {
|
||||
offer_source_to_x::<XPrimarySelectionIpc, Self>(&self, dd)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn offer_to_wlr_device(self: Rc<Self>, dd: &Rc<ZwlrDataControlDeviceV1>) {
|
||||
match self.location.get() {
|
||||
IpcLocation::Clipboard => {
|
||||
offer_source_to_wlr_device::<WlrClipboardIpc, Self>(&self, dd)
|
||||
}
|
||||
IpcLocation::PrimarySelection => {
|
||||
offer_source_to_wlr_device::<WlrPrimarySelectionIpc, Self>(&self, dd)
|
||||
}
|
||||
IpcLocation::Clipboard => offer_source_to_x::<XClipboardIpc>(self, dd),
|
||||
IpcLocation::PrimarySelection => offer_source_to_x::<XPrimarySelectionIpc>(self, dd),
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -4,10 +4,8 @@ use {
|
|||
ifs::{
|
||||
ipc::{
|
||||
add_data_source_mime_type, break_source_loops, cancel_offers, destroy_data_source,
|
||||
detach_seat, offer_source_to_regular_client, offer_source_to_wlr_device,
|
||||
offer_source_to_x,
|
||||
detach_seat, offer_source_to_x,
|
||||
x_data_device::{XIpcDevice, XPrimarySelectionIpc},
|
||||
zwlr_data_control_device_v1::{WlrPrimarySelectionIpc, ZwlrDataControlDeviceV1},
|
||||
zwp_primary_selection_device_v1::PrimarySelectionIpc,
|
||||
DataSource, DynDataSource, SourceData,
|
||||
},
|
||||
|
|
@ -44,16 +42,8 @@ impl DynDataSource for ZwpPrimarySelectionSourceV1 {
|
|||
ZwpPrimarySelectionSourceV1::send_send(self, mime_type, fd)
|
||||
}
|
||||
|
||||
fn offer_to_regular_client(self: Rc<Self>, client: &Rc<Client>) {
|
||||
offer_source_to_regular_client::<PrimarySelectionIpc, Self>(&self, client);
|
||||
}
|
||||
|
||||
fn offer_to_x(self: Rc<Self>, dd: &Rc<XIpcDevice>) {
|
||||
offer_source_to_x::<XPrimarySelectionIpc, Self>(&self, dd);
|
||||
}
|
||||
|
||||
fn offer_to_wlr_device(self: Rc<Self>, dd: &Rc<ZwlrDataControlDeviceV1>) {
|
||||
offer_source_to_wlr_device::<WlrPrimarySelectionIpc, Self>(&self, dd)
|
||||
offer_source_to_x::<XPrimarySelectionIpc>(self, dd);
|
||||
}
|
||||
|
||||
fn detach_seat(&self, seat: &Rc<WlSeatGlobal>) {
|
||||
|
|
|
|||
|
|
@ -32,7 +32,7 @@ use {
|
|||
ifs::{
|
||||
ext_idle_notification_v1::ExtIdleNotificationV1,
|
||||
ipc::{
|
||||
self,
|
||||
self, offer_source_to_regular_client, offer_source_to_wlr_device,
|
||||
wl_data_device::{ClipboardIpc, WlDataDevice},
|
||||
wl_data_source::WlDataSource,
|
||||
x_data_device::{XClipboardIpc, XIpcDevice, XIpcDeviceId, XPrimarySelectionIpc},
|
||||
|
|
@ -739,7 +739,7 @@ impl WlSeatGlobal {
|
|||
// client.flush();
|
||||
}
|
||||
W::for_each_device(self, |device| match &src {
|
||||
Some(src) => src.clone().offer_to_wlr_device(device),
|
||||
Some(src) => offer_source_to_wlr_device::<W>(src.clone(), device),
|
||||
_ => W::send_selection(device, None),
|
||||
});
|
||||
Ok(())
|
||||
|
|
@ -763,7 +763,7 @@ impl WlSeatGlobal {
|
|||
});
|
||||
} else {
|
||||
match selection {
|
||||
Some(src) => src.offer_to_regular_client(client),
|
||||
Some(src) => offer_source_to_regular_client::<T>(src, client),
|
||||
_ => T::for_each_device(self, client.id, |device| {
|
||||
T::send_selection(device, None);
|
||||
}),
|
||||
|
|
|
|||
|
|
@ -9,13 +9,13 @@ use {
|
|||
fixed::Fixed,
|
||||
ifs::{
|
||||
ipc::{
|
||||
offer_source_to_regular_client,
|
||||
wl_data_device::{ClipboardIpc, WlDataDevice},
|
||||
x_data_device::{XClipboardIpc, XPrimarySelectionIpc},
|
||||
zwlr_data_control_device_v1::ZwlrDataControlDeviceV1,
|
||||
zwp_primary_selection_device_v1::{
|
||||
PrimarySelectionIpc, ZwpPrimarySelectionDeviceV1,
|
||||
},
|
||||
DynDataSource,
|
||||
},
|
||||
wl_seat::{
|
||||
tablet::{TabletPad, TabletPadId, TabletTool, TabletToolId},
|
||||
|
|
@ -1445,7 +1445,7 @@ impl WlSeatGlobal {
|
|||
) {
|
||||
if let Some(src) = &dnd.src {
|
||||
if !surface.client.is_xwayland {
|
||||
src.clone().offer_to_regular_client(&surface.client);
|
||||
offer_source_to_regular_client::<ClipboardIpc>(src.clone(), &surface.client);
|
||||
}
|
||||
src.for_each_data_offer(|offer| {
|
||||
offer.send_enter(surface.id, x, y, serial);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue