ipc: remove X-only code from traits
This commit is contained in:
parent
1ca5d43557
commit
487efafdf5
6 changed files with 9 additions and 64 deletions
|
|
@ -6,7 +6,7 @@ use {
|
||||||
ipc::{
|
ipc::{
|
||||||
x_data_device::XIpcDevice, zwlr_data_control_device_v1::ZwlrDataControlDeviceV1,
|
x_data_device::XIpcDevice, zwlr_data_control_device_v1::ZwlrDataControlDeviceV1,
|
||||||
},
|
},
|
||||||
wl_seat::{WlSeatError, WlSeatGlobal},
|
wl_seat::WlSeatGlobal,
|
||||||
},
|
},
|
||||||
utils::{
|
utils::{
|
||||||
bitflags::BitflagsExt, cell_ext::CellExt, clonecell::CloneCell, numcell::NumCell,
|
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<Self::Offer>;
|
fn get_device_data(dd: &Self::Device) -> &DeviceData<Self::Offer>;
|
||||||
fn get_device_seat(dd: &Self::Device) -> Rc<WlSeatGlobal>;
|
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(
|
fn create_offer(
|
||||||
dd: &Rc<Self::Device>,
|
dd: &Rc<Self::Device>,
|
||||||
data: OfferData<Self::Device>,
|
data: OfferData<Self::Device>,
|
||||||
|
|
|
||||||
|
|
@ -173,14 +173,6 @@ impl IpcVtable for ClipboardIpc {
|
||||||
dd.seat.clone()
|
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(
|
fn create_offer(
|
||||||
device: &Rc<WlDataDevice>,
|
device: &Rc<WlDataDevice>,
|
||||||
offer_data: OfferData<Self::Device>,
|
offer_data: OfferData<Self::Device>,
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@ use {
|
||||||
x_data_offer::XDataOffer, x_data_source::XDataSource, DeviceData, IpcLocation,
|
x_data_offer::XDataOffer, x_data_source::XDataSource, DeviceData, IpcLocation,
|
||||||
IpcVtable, OfferData, Role,
|
IpcVtable, OfferData, Role,
|
||||||
},
|
},
|
||||||
wl_seat::{WlSeatError, WlSeatGlobal},
|
wl_seat::WlSeatGlobal,
|
||||||
},
|
},
|
||||||
state::State,
|
state::State,
|
||||||
xwayland::XWaylandEvent,
|
xwayland::XWaylandEvent,
|
||||||
|
|
@ -77,17 +77,6 @@ impl<T: XIpc> IpcVtable for T {
|
||||||
dd.seat.clone()
|
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(
|
fn create_offer(
|
||||||
dd: &Rc<Self::Device>,
|
dd: &Rc<Self::Device>,
|
||||||
data: OfferData<Self::Device>,
|
data: OfferData<Self::Device>,
|
||||||
|
|
|
||||||
|
|
@ -143,11 +143,6 @@ trait WlrIpc {
|
||||||
|
|
||||||
fn wlr_get_device_data(dd: &ZwlrDataControlDeviceV1) -> &DeviceData<ZwlrDataControlOfferV1>;
|
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_send_selection(dd: &ZwlrDataControlDeviceV1, offer: Option<&Rc<ZwlrDataControlOfferV1>>);
|
||||||
|
|
||||||
fn wlr_unset(seat: &Rc<WlSeatGlobal>);
|
fn wlr_unset(seat: &Rc<WlSeatGlobal>);
|
||||||
|
|
@ -161,13 +156,6 @@ impl WlrIpc for WlrClipboardIpcCore {
|
||||||
&dd.clipboard_data
|
&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(
|
fn wlr_send_selection(
|
||||||
dd: &ZwlrDataControlDeviceV1,
|
dd: &ZwlrDataControlDeviceV1,
|
||||||
offer: Option<&Rc<ZwlrDataControlOfferV1>>,
|
offer: Option<&Rc<ZwlrDataControlOfferV1>>,
|
||||||
|
|
@ -188,13 +176,6 @@ impl WlrIpc for WlrPrimarySelectionIpcCore {
|
||||||
&dd.primary_selection_data
|
&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(
|
fn wlr_send_selection(
|
||||||
dd: &ZwlrDataControlDeviceV1,
|
dd: &ZwlrDataControlDeviceV1,
|
||||||
offer: Option<&Rc<ZwlrDataControlOfferV1>>,
|
offer: Option<&Rc<ZwlrDataControlOfferV1>>,
|
||||||
|
|
@ -229,16 +210,6 @@ impl<T: WlrIpc> IpcVtable for WlrIpcImpl<T> {
|
||||||
dd.seat.clone()
|
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(
|
fn create_offer(
|
||||||
device: &Rc<ZwlrDataControlDeviceV1>,
|
device: &Rc<ZwlrDataControlDeviceV1>,
|
||||||
offer_data: OfferData<Self::Device>,
|
offer_data: OfferData<Self::Device>,
|
||||||
|
|
|
||||||
|
|
@ -121,14 +121,6 @@ impl IpcVtable for PrimarySelectionIpc {
|
||||||
dd.seat.clone()
|
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(
|
fn create_offer(
|
||||||
device: &Rc<ZwpPrimarySelectionDeviceV1>,
|
device: &Rc<ZwpPrimarySelectionDeviceV1>,
|
||||||
offer_data: OfferData<Self::Device>,
|
offer_data: OfferData<Self::Device>,
|
||||||
|
|
|
||||||
|
|
@ -1749,7 +1749,13 @@ impl Wm {
|
||||||
for target in &targets {
|
for target in &targets {
|
||||||
add_data_source_mime_type::<T>(&source, target);
|
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));
|
log::error!("Could not set selection: {}", ErrorFmt(e));
|
||||||
return Ok(());
|
return Ok(());
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue