From 487efafdf54edac23afcf2a98a84a0b1089c441c Mon Sep 17 00:00:00 2001 From: Julian Orth Date: Tue, 8 Oct 2024 12:58:32 +0200 Subject: [PATCH] ipc: remove X-only code from traits --- src/ifs/ipc.rs | 7 +---- src/ifs/ipc/wl_data_device.rs | 8 ----- src/ifs/ipc/x_data_device.rs | 13 +-------- src/ifs/ipc/zwlr_data_control_device_v1.rs | 29 ------------------- .../ipc/zwp_primary_selection_device_v1.rs | 8 ----- src/xwayland/xwm.rs | 8 ++++- 6 files changed, 9 insertions(+), 64 deletions(-) diff --git a/src/ifs/ipc.rs b/src/ifs/ipc.rs index 0def2a61..35f9f8b4 100644 --- a/src/ifs/ipc.rs +++ b/src/ifs/ipc.rs @@ -6,7 +6,7 @@ use { ipc::{ x_data_device::XIpcDevice, zwlr_data_control_device_v1::ZwlrDataControlDeviceV1, }, - wl_seat::{WlSeatError, WlSeatGlobal}, + wl_seat::WlSeatGlobal, }, utils::{ bitflags::BitflagsExt, cell_ext::CellExt, clonecell::CloneCell, numcell::NumCell, @@ -152,11 +152,6 @@ pub trait IpcVtable: Sized { fn get_device_data(dd: &Self::Device) -> &DeviceData; fn get_device_seat(dd: &Self::Device) -> Rc; - fn set_seat_selection( - seat: &Rc, - source: &Rc, - serial: Option, - ) -> Result<(), WlSeatError>; fn create_offer( dd: &Rc, data: OfferData, diff --git a/src/ifs/ipc/wl_data_device.rs b/src/ifs/ipc/wl_data_device.rs index 35b935ea..98b4de3c 100644 --- a/src/ifs/ipc/wl_data_device.rs +++ b/src/ifs/ipc/wl_data_device.rs @@ -173,14 +173,6 @@ impl IpcVtable for ClipboardIpc { dd.seat.clone() } - fn set_seat_selection( - seat: &Rc, - source: &Rc, - serial: Option, - ) -> Result<(), WlSeatError> { - seat.set_wl_data_source_selection(Some(source.clone()), serial) - } - fn create_offer( device: &Rc, offer_data: OfferData, diff --git a/src/ifs/ipc/x_data_device.rs b/src/ifs/ipc/x_data_device.rs index aa03bb69..6fb48591 100644 --- a/src/ifs/ipc/x_data_device.rs +++ b/src/ifs/ipc/x_data_device.rs @@ -6,7 +6,7 @@ use { x_data_offer::XDataOffer, x_data_source::XDataSource, DeviceData, IpcLocation, IpcVtable, OfferData, Role, }, - wl_seat::{WlSeatError, WlSeatGlobal}, + wl_seat::WlSeatGlobal, }, state::State, xwayland::XWaylandEvent, @@ -77,17 +77,6 @@ impl IpcVtable for T { dd.seat.clone() } - fn set_seat_selection( - seat: &Rc, - source: &Rc, - _serial: Option, - ) -> Result<(), WlSeatError> { - match source.location { - IpcLocation::Clipboard => seat.set_selection(Some(source.clone())), - IpcLocation::PrimarySelection => seat.set_primary_selection(Some(source.clone())), - } - } - fn create_offer( dd: &Rc, data: OfferData, diff --git a/src/ifs/ipc/zwlr_data_control_device_v1.rs b/src/ifs/ipc/zwlr_data_control_device_v1.rs index cf62a678..ecd5cf2f 100644 --- a/src/ifs/ipc/zwlr_data_control_device_v1.rs +++ b/src/ifs/ipc/zwlr_data_control_device_v1.rs @@ -143,11 +143,6 @@ trait WlrIpc { fn wlr_get_device_data(dd: &ZwlrDataControlDeviceV1) -> &DeviceData; - fn wlr_set_seat_selection( - seat: &Rc, - source: &Rc, - ) -> Result<(), WlSeatError>; - fn wlr_send_selection(dd: &ZwlrDataControlDeviceV1, offer: Option<&Rc>); fn wlr_unset(seat: &Rc); @@ -161,13 +156,6 @@ impl WlrIpc for WlrClipboardIpcCore { &dd.clipboard_data } - fn wlr_set_seat_selection( - seat: &Rc, - source: &Rc, - ) -> Result<(), WlSeatError> { - seat.set_selection(Some(source.clone())) - } - fn wlr_send_selection( dd: &ZwlrDataControlDeviceV1, offer: Option<&Rc>, @@ -188,13 +176,6 @@ impl WlrIpc for WlrPrimarySelectionIpcCore { &dd.primary_selection_data } - fn wlr_set_seat_selection( - seat: &Rc, - source: &Rc, - ) -> Result<(), WlSeatError> { - seat.set_primary_selection(Some(source.clone())) - } - fn wlr_send_selection( dd: &ZwlrDataControlDeviceV1, offer: Option<&Rc>, @@ -229,16 +210,6 @@ impl IpcVtable for WlrIpcImpl { dd.seat.clone() } - fn set_seat_selection( - seat: &Rc, - source: &Rc, - serial: Option, - ) -> Result<(), WlSeatError> { - debug_assert!(serial.is_none()); - let _ = serial; - T::wlr_set_seat_selection(seat, source) - } - fn create_offer( device: &Rc, offer_data: OfferData, diff --git a/src/ifs/ipc/zwp_primary_selection_device_v1.rs b/src/ifs/ipc/zwp_primary_selection_device_v1.rs index 346bd091..63296837 100644 --- a/src/ifs/ipc/zwp_primary_selection_device_v1.rs +++ b/src/ifs/ipc/zwp_primary_selection_device_v1.rs @@ -121,14 +121,6 @@ impl IpcVtable for PrimarySelectionIpc { dd.seat.clone() } - fn set_seat_selection( - seat: &Rc, - source: &Rc, - serial: Option, - ) -> Result<(), WlSeatError> { - seat.set_zwp_primary_selection(Some(source.clone()), serial) - } - fn create_offer( device: &Rc, offer_data: OfferData, diff --git a/src/xwayland/xwm.rs b/src/xwayland/xwm.rs index 21e90132..3baf57b1 100644 --- a/src/xwayland/xwm.rs +++ b/src/xwayland/xwm.rs @@ -1749,7 +1749,13 @@ impl Wm { for target in &targets { add_data_source_mime_type::(&source, target); } - if let Err(e) = T::set_seat_selection(&seat, &source, None) { + let res = match source.location { + IpcLocation::Clipboard => seat.set_selection(Some(source.clone())), + IpcLocation::PrimarySelection => { + seat.set_primary_selection(Some(source.clone())) + } + }; + if let Err(e) = res { log::error!("Could not set selection: {}", ErrorFmt(e)); return Ok(()); }