Skip to content

Commit

Permalink
ipc: remove X-only code from traits
Browse files Browse the repository at this point in the history
  • Loading branch information
mahkoh committed Oct 25, 2024
1 parent 1ca5d43 commit 487efaf
Show file tree
Hide file tree
Showing 6 changed files with 9 additions and 64 deletions.
7 changes: 1 addition & 6 deletions src/ifs/ipc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -152,11 +152,6 @@ pub trait IpcVtable: Sized {

fn get_device_data(dd: &Self::Device) -> &DeviceData<Self::Offer>;
fn get_device_seat(dd: &Self::Device) -> Rc<WlSeatGlobal>;
fn set_seat_selection(
seat: &Rc<WlSeatGlobal>,
source: &Rc<Self::Source>,
serial: Option<u64>,
) -> Result<(), WlSeatError>;
fn create_offer(
dd: &Rc<Self::Device>,
data: OfferData<Self::Device>,
Expand Down
8 changes: 0 additions & 8 deletions src/ifs/ipc/wl_data_device.rs
Original file line number Diff line number Diff line change
Expand Up @@ -173,14 +173,6 @@ impl IpcVtable for ClipboardIpc {
dd.seat.clone()
}

fn set_seat_selection(
seat: &Rc<WlSeatGlobal>,
source: &Rc<Self::Source>,
serial: Option<u64>,
) -> Result<(), WlSeatError> {
seat.set_wl_data_source_selection(Some(source.clone()), serial)
}

fn create_offer(
device: &Rc<WlDataDevice>,
offer_data: OfferData<Self::Device>,
Expand Down
13 changes: 1 addition & 12 deletions src/ifs/ipc/x_data_device.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -77,17 +77,6 @@ impl<T: XIpc> IpcVtable for T {
dd.seat.clone()
}

fn set_seat_selection(
seat: &Rc<WlSeatGlobal>,
source: &Rc<Self::Source>,
_serial: Option<u64>,
) -> 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<Self::Device>,
data: OfferData<Self::Device>,
Expand Down
29 changes: 0 additions & 29 deletions src/ifs/ipc/zwlr_data_control_device_v1.rs
Original file line number Diff line number Diff line change
Expand Up @@ -143,11 +143,6 @@ trait WlrIpc {

fn wlr_get_device_data(dd: &ZwlrDataControlDeviceV1) -> &DeviceData<ZwlrDataControlOfferV1>;

fn wlr_set_seat_selection(
seat: &Rc<WlSeatGlobal>,
source: &Rc<ZwlrDataControlSourceV1>,
) -> Result<(), WlSeatError>;

fn wlr_send_selection(dd: &ZwlrDataControlDeviceV1, offer: Option<&Rc<ZwlrDataControlOfferV1>>);

fn wlr_unset(seat: &Rc<WlSeatGlobal>);
Expand All @@ -161,13 +156,6 @@ impl WlrIpc for WlrClipboardIpcCore {
&dd.clipboard_data
}

fn wlr_set_seat_selection(
seat: &Rc<WlSeatGlobal>,
source: &Rc<ZwlrDataControlSourceV1>,
) -> Result<(), WlSeatError> {
seat.set_selection(Some(source.clone()))
}

fn wlr_send_selection(
dd: &ZwlrDataControlDeviceV1,
offer: Option<&Rc<ZwlrDataControlOfferV1>>,
Expand All @@ -188,13 +176,6 @@ impl WlrIpc for WlrPrimarySelectionIpcCore {
&dd.primary_selection_data
}

fn wlr_set_seat_selection(
seat: &Rc<WlSeatGlobal>,
source: &Rc<ZwlrDataControlSourceV1>,
) -> Result<(), WlSeatError> {
seat.set_primary_selection(Some(source.clone()))
}

fn wlr_send_selection(
dd: &ZwlrDataControlDeviceV1,
offer: Option<&Rc<ZwlrDataControlOfferV1>>,
Expand Down Expand Up @@ -229,16 +210,6 @@ impl<T: WlrIpc> IpcVtable for WlrIpcImpl<T> {
dd.seat.clone()
}

fn set_seat_selection(
seat: &Rc<WlSeatGlobal>,
source: &Rc<Self::Source>,
serial: Option<u64>,
) -> Result<(), WlSeatError> {
debug_assert!(serial.is_none());
let _ = serial;
T::wlr_set_seat_selection(seat, source)
}

fn create_offer(
device: &Rc<ZwlrDataControlDeviceV1>,
offer_data: OfferData<Self::Device>,
Expand Down
8 changes: 0 additions & 8 deletions src/ifs/ipc/zwp_primary_selection_device_v1.rs
Original file line number Diff line number Diff line change
Expand Up @@ -121,14 +121,6 @@ impl IpcVtable for PrimarySelectionIpc {
dd.seat.clone()
}

fn set_seat_selection(
seat: &Rc<WlSeatGlobal>,
source: &Rc<Self::Source>,
serial: Option<u64>,
) -> Result<(), WlSeatError> {
seat.set_zwp_primary_selection(Some(source.clone()), serial)
}

fn create_offer(
device: &Rc<ZwpPrimarySelectionDeviceV1>,
offer_data: OfferData<Self::Device>,
Expand Down
8 changes: 7 additions & 1 deletion src/xwayland/xwm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1749,7 +1749,13 @@ impl Wm {
for target in &targets {
add_data_source_mime_type::<T>(&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(());
}
Expand Down

0 comments on commit 487efaf

Please sign in to comment.