1
0
Fork 0
forked from wry/wry

data-control: remove wlr-specific code

This commit is contained in:
Julian Orth 2024-10-08 13:11:42 +02:00
parent 40f7bc2542
commit dfc0a11935
12 changed files with 120 additions and 99 deletions

View file

@ -6,7 +6,8 @@ use {
ext_image_capture_source_v1::ExtImageCaptureSourceV1, ext_image_capture_source_v1::ExtImageCaptureSourceV1,
ext_image_copy::ext_image_copy_capture_session_v1::ExtImageCopyCaptureSessionV1, ext_image_copy::ext_image_copy_capture_session_v1::ExtImageCopyCaptureSessionV1,
ipc::{ ipc::{
wl_data_source::WlDataSource, zwlr_data_control_source_v1::ZwlrDataControlSourceV1, data_control::zwlr_data_control_source_v1::ZwlrDataControlSourceV1,
wl_data_source::WlDataSource,
zwp_primary_selection_source_v1::ZwpPrimarySelectionSourceV1, zwp_primary_selection_source_v1::ZwpPrimarySelectionSourceV1,
}, },
jay_output::JayOutput, jay_output::JayOutput,

View file

@ -274,6 +274,7 @@ fn start_compositor2(
toplevels: Default::default(), toplevels: Default::default(),
const_40hz_latch: Default::default(), const_40hz_latch: Default::default(),
tray_item_ids: Default::default(), tray_item_ids: Default::default(),
data_control_device_ids: Default::default(),
}); });
state.tracker.register(ClientId::from_raw(0)); state.tracker.register(ClientId::from_raw(0));
create_dummy_output(&state); create_dummy_output(&state);

View file

@ -10,8 +10,8 @@ use {
ext_output_image_capture_source_manager_v1::ExtOutputImageCaptureSourceManagerV1Global, ext_output_image_capture_source_manager_v1::ExtOutputImageCaptureSourceManagerV1Global,
ext_session_lock_manager_v1::ExtSessionLockManagerV1Global, ext_session_lock_manager_v1::ExtSessionLockManagerV1Global,
ipc::{ ipc::{
data_control::zwlr_data_control_manager_v1::ZwlrDataControlManagerV1Global,
wl_data_device_manager::WlDataDeviceManagerGlobal, wl_data_device_manager::WlDataDeviceManagerGlobal,
zwlr_data_control_manager_v1::ZwlrDataControlManagerV1Global,
zwp_primary_selection_device_manager_v1::ZwpPrimarySelectionDeviceManagerV1Global, zwp_primary_selection_device_manager_v1::ZwpPrimarySelectionDeviceManagerV1Global,
}, },
jay_compositor::JayCompositorGlobal, jay_compositor::JayCompositorGlobal,

View file

@ -2,12 +2,7 @@ use {
crate::{ crate::{
client::{Client, ClientError, ClientId}, client::{Client, ClientError, ClientId},
fixed::Fixed, fixed::Fixed,
ifs::{ ifs::{ipc::x_data_device::XIpcDevice, wl_seat::WlSeatGlobal},
ipc::{
x_data_device::XIpcDevice, zwlr_data_control_device_v1::ZwlrDataControlDeviceV1,
},
wl_seat::WlSeatGlobal,
},
utils::{ utils::{
bitflags::BitflagsExt, cell_ext::CellExt, clonecell::CloneCell, numcell::NumCell, bitflags::BitflagsExt, cell_ext::CellExt, clonecell::CloneCell, numcell::NumCell,
smallmap::SmallMap, smallmap::SmallMap,
@ -26,6 +21,7 @@ use {
uapi::OwnedFd, uapi::OwnedFd,
}; };
pub mod data_control;
pub mod wl_data_device; pub mod wl_data_device;
pub mod wl_data_device_manager; pub mod wl_data_device_manager;
pub mod wl_data_offer; pub mod wl_data_offer;
@ -33,10 +29,6 @@ pub mod wl_data_source;
pub mod x_data_device; pub mod x_data_device;
pub mod x_data_offer; pub mod x_data_offer;
pub mod x_data_source; pub mod x_data_source;
pub mod zwlr_data_control_device_v1;
pub mod zwlr_data_control_manager_v1;
pub mod zwlr_data_control_offer_v1;
pub mod zwlr_data_control_source_v1;
pub mod zwp_primary_selection_device_manager_v1; pub mod zwp_primary_selection_device_manager_v1;
pub mod zwp_primary_selection_device_v1; pub mod zwp_primary_selection_device_v1;
pub mod zwp_primary_selection_offer_v1; pub mod zwp_primary_selection_offer_v1;
@ -137,12 +129,6 @@ pub trait IterableIpcVtable: IpcVtable {
C: FnMut(&Rc<Self::Device>); C: FnMut(&Rc<Self::Device>);
} }
pub trait WlrIpcVtable: IpcVtable<Device = ZwlrDataControlDeviceV1> {
fn for_each_device<C>(seat: &WlSeatGlobal, f: C)
where
C: FnMut(&Rc<Self::Device>);
}
pub trait IpcVtable: Sized { pub trait IpcVtable: Sized {
type Device; type Device;
type Source: DataSource; type Source: DataSource;
@ -360,9 +346,9 @@ where
offer_source_to_device::<T>(&src, dd, data, shared); offer_source_to_device::<T>(&src, dd, data, shared);
} }
pub fn offer_source_to_wlr_device<T>(src: Rc<dyn DynDataSource>, dd: &Rc<T::Device>) pub fn offer_source_to_data_control_device<T>(src: Rc<dyn DynDataSource>, dd: &Rc<T::Device>)
where where
T: IpcVtable<Device = ZwlrDataControlDeviceV1>, T: IpcVtable,
{ {
let data = src.source_data(); let data = src.source_data();
let shared = data.shared.get(); let shared = data.shared.get();

View file

@ -0,0 +1,21 @@
use {
crate::ifs::ipc::{DynDataSource, IpcLocation},
std::rc::Rc,
};
pub mod zwlr_data_control_device_v1;
pub mod zwlr_data_control_manager_v1;
pub mod zwlr_data_control_offer_v1;
pub mod zwlr_data_control_source_v1;
linear_ids!(DataControlDeviceIds, DataControlDeviceId, u64);
pub trait DynDataControlDevice {
fn id(&self) -> DataControlDeviceId;
fn handle_new_source(
self: Rc<Self>,
location: IpcLocation,
source: Option<Rc<dyn DynDataSource>>,
);
}

View file

@ -3,13 +3,17 @@ use {
client::{Client, ClientError}, client::{Client, ClientError},
ifs::{ ifs::{
ipc::{ ipc::{
break_device_loops, destroy_data_device, break_device_loops,
zwlr_data_control_device_v1::private::{ data_control::{
WlrClipboardIpcCore, WlrIpcImpl, WlrPrimarySelectionIpcCore, zwlr_data_control_device_v1::private::{
WlrClipboardIpcCore, WlrIpcImpl, WlrPrimarySelectionIpcCore,
},
zwlr_data_control_offer_v1::ZwlrDataControlOfferV1,
zwlr_data_control_source_v1::ZwlrDataControlSourceV1,
DataControlDeviceId, DynDataControlDevice,
}, },
zwlr_data_control_offer_v1::ZwlrDataControlOfferV1, destroy_data_device, offer_source_to_data_control_device, DeviceData,
zwlr_data_control_source_v1::ZwlrDataControlSourceV1, DynDataSource, IpcLocation, IpcVtable, OfferData, Role,
DeviceData, IpcLocation, IpcVtable, OfferData, Role, WlrIpcVtable,
}, },
wl_seat::{WlSeatError, WlSeatGlobal}, wl_seat::{WlSeatError, WlSeatGlobal},
}, },
@ -28,6 +32,7 @@ pub const PRIMARY_SELECTION_SINCE: Version = Version(2);
pub struct ZwlrDataControlDeviceV1 { pub struct ZwlrDataControlDeviceV1 {
pub id: ZwlrDataControlDeviceV1Id, pub id: ZwlrDataControlDeviceV1Id,
pub data_control_device_id: DataControlDeviceId,
pub client: Rc<Client>, pub client: Rc<Client>,
pub version: Version, pub version: Version,
pub seat: Rc<WlSeatGlobal>, pub seat: Rc<WlSeatGlobal>,
@ -45,6 +50,7 @@ impl ZwlrDataControlDeviceV1 {
) -> Self { ) -> Self {
Self { Self {
id, id,
data_control_device_id: client.state.data_control_device_ids.next(),
client: client.clone(), client: client.clone(),
version, version,
seat: seat.clone(), seat: seat.clone(),
@ -111,7 +117,7 @@ impl ZwlrDataControlDeviceV1RequestHandler for ZwlrDataControlDeviceV1 {
fn destroy(&self, _req: Destroy, _slf: &Rc<Self>) -> Result<(), Self::Error> { fn destroy(&self, _req: Destroy, _slf: &Rc<Self>) -> Result<(), Self::Error> {
destroy_data_device::<WlrClipboardIpc>(self); destroy_data_device::<WlrClipboardIpc>(self);
destroy_data_device::<WlrPrimarySelectionIpc>(self); destroy_data_device::<WlrPrimarySelectionIpc>(self);
self.seat.remove_wlr_device(self); self.seat.remove_data_control_device(self);
self.client.remove_obj(self)?; self.client.remove_obj(self)?;
Ok(()) Ok(())
} }
@ -138,7 +144,6 @@ pub type WlrClipboardIpc = WlrIpcImpl<WlrClipboardIpcCore>;
pub type WlrPrimarySelectionIpc = WlrIpcImpl<WlrPrimarySelectionIpcCore>; pub type WlrPrimarySelectionIpc = WlrIpcImpl<WlrPrimarySelectionIpcCore>;
trait WlrIpc { trait WlrIpc {
const MIN_VERSION: Version;
const LOCATION: IpcLocation; const LOCATION: IpcLocation;
fn wlr_get_device_data(dd: &ZwlrDataControlDeviceV1) -> &DeviceData<ZwlrDataControlOfferV1>; fn wlr_get_device_data(dd: &ZwlrDataControlDeviceV1) -> &DeviceData<ZwlrDataControlOfferV1>;
@ -149,7 +154,6 @@ trait WlrIpc {
} }
impl WlrIpc for WlrClipboardIpcCore { impl WlrIpc for WlrClipboardIpcCore {
const MIN_VERSION: Version = Version::ALL;
const LOCATION: IpcLocation = IpcLocation::Clipboard; const LOCATION: IpcLocation = IpcLocation::Clipboard;
fn wlr_get_device_data(dd: &ZwlrDataControlDeviceV1) -> &DeviceData<ZwlrDataControlOfferV1> { fn wlr_get_device_data(dd: &ZwlrDataControlDeviceV1) -> &DeviceData<ZwlrDataControlOfferV1> {
@ -169,7 +173,6 @@ impl WlrIpc for WlrClipboardIpcCore {
} }
impl WlrIpc for WlrPrimarySelectionIpcCore { impl WlrIpc for WlrPrimarySelectionIpcCore {
const MIN_VERSION: Version = PRIMARY_SELECTION_SINCE;
const LOCATION: IpcLocation = IpcLocation::PrimarySelection; const LOCATION: IpcLocation = IpcLocation::PrimarySelection;
fn wlr_get_device_data(dd: &ZwlrDataControlDeviceV1) -> &DeviceData<ZwlrDataControlOfferV1> { fn wlr_get_device_data(dd: &ZwlrDataControlDeviceV1) -> &DeviceData<ZwlrDataControlOfferV1> {
@ -188,15 +191,6 @@ impl WlrIpc for WlrPrimarySelectionIpcCore {
} }
} }
impl<T: WlrIpc> WlrIpcVtable for WlrIpcImpl<T> {
fn for_each_device<C>(seat: &WlSeatGlobal, f: C)
where
C: FnMut(&Rc<Self::Device>),
{
seat.for_each_wlr_data_device(T::MIN_VERSION, f)
}
}
impl<T: WlrIpc> IpcVtable for WlrIpcImpl<T> { impl<T: WlrIpc> IpcVtable for WlrIpcImpl<T> {
type Device = ZwlrDataControlDeviceV1; type Device = ZwlrDataControlDeviceV1;
type Source = ZwlrDataControlSourceV1; type Source = ZwlrDataControlSourceV1;
@ -245,6 +239,35 @@ impl<T: WlrIpc> IpcVtable for WlrIpcImpl<T> {
} }
} }
impl DynDataControlDevice for ZwlrDataControlDeviceV1 {
fn id(&self) -> DataControlDeviceId {
self.data_control_device_id
}
fn handle_new_source(
self: Rc<Self>,
location: IpcLocation,
source: Option<Rc<dyn DynDataSource>>,
) {
match location {
IpcLocation::Clipboard => match source {
Some(src) => offer_source_to_data_control_device::<WlrClipboardIpc>(src, &self),
_ => self.send_selection(None),
},
IpcLocation::PrimarySelection => {
if self.version >= PRIMARY_SELECTION_SINCE {
match source {
Some(src) => offer_source_to_data_control_device::<WlrPrimarySelectionIpc>(
src, &self,
),
_ => self.send_primary_selection(None),
}
}
}
}
}
}
object_base! { object_base! {
self = ZwlrDataControlDeviceV1; self = ZwlrDataControlDeviceV1;
version = self.version; version = self.version;
@ -254,7 +277,7 @@ impl Object for ZwlrDataControlDeviceV1 {
fn break_loops(&self) { fn break_loops(&self) {
break_device_loops::<WlrClipboardIpc>(self); break_device_loops::<WlrClipboardIpc>(self);
break_device_loops::<WlrPrimarySelectionIpc>(self); break_device_loops::<WlrPrimarySelectionIpc>(self);
self.seat.remove_wlr_device(self); self.seat.remove_data_control_device(self);
} }
} }

View file

@ -3,12 +3,11 @@ use {
client::{Client, ClientCaps, ClientError, CAP_DATA_CONTROL_MANAGER}, client::{Client, ClientCaps, ClientError, CAP_DATA_CONTROL_MANAGER},
globals::{Global, GlobalName}, globals::{Global, GlobalName},
ifs::ipc::{ ifs::ipc::{
offer_source_to_wlr_device, data_control::{
zwlr_data_control_device_v1::{ zwlr_data_control_device_v1::ZwlrDataControlDeviceV1,
WlrClipboardIpc, WlrPrimarySelectionIpc, ZwlrDataControlDeviceV1, zwlr_data_control_source_v1::ZwlrDataControlSourceV1, DynDataControlDevice,
PRIMARY_SELECTION_SINCE,
}, },
zwlr_data_control_source_v1::ZwlrDataControlSourceV1, IpcLocation,
}, },
leaks::Tracker, leaks::Tracker,
object::{Object, Version}, object::{Object, Version},
@ -79,18 +78,14 @@ impl ZwlrDataControlManagerV1RequestHandler for ZwlrDataControlManagerV1 {
&seat.global, &seat.global,
)); ));
track!(self.client, dev); track!(self.client, dev);
seat.global.add_wlr_device(&dev); seat.global.add_data_control_device(dev.clone());
self.client.add_client_obj(&dev)?; self.client.add_client_obj(&dev)?;
match seat.global.get_selection() { dev.clone()
Some(s) => offer_source_to_wlr_device::<WlrClipboardIpc>(s, &dev), .handle_new_source(IpcLocation::Clipboard, seat.global.get_selection());
_ => dev.send_selection(None), dev.clone().handle_new_source(
} IpcLocation::PrimarySelection,
if self.version >= PRIMARY_SELECTION_SINCE { seat.global.get_primary_selection(),
match seat.global.get_primary_selection() { );
Some(s) => offer_source_to_wlr_device::<WlrPrimarySelectionIpc>(s, &dev),
_ => dev.send_primary_selection(None),
}
}
Ok(()) Ok(())
} }

View file

@ -3,11 +3,12 @@ use {
client::{Client, ClientError, ClientId}, client::{Client, ClientError, ClientId},
ifs::{ ifs::{
ipc::{ ipc::{
break_offer_loops, cancel_offer, destroy_data_offer, receive_data_offer, break_offer_loops, cancel_offer,
zwlr_data_control_device_v1::{ data_control::zwlr_data_control_device_v1::{
WlrClipboardIpc, WlrPrimarySelectionIpc, ZwlrDataControlDeviceV1, WlrClipboardIpc, WlrPrimarySelectionIpc, ZwlrDataControlDeviceV1,
}, },
DataOffer, DataOfferId, DynDataOffer, IpcLocation, OfferData, destroy_data_offer, receive_data_offer, DataOffer, DataOfferId, DynDataOffer,
IpcLocation, OfferData,
}, },
wl_seat::WlSeatGlobal, wl_seat::WlSeatGlobal,
}, },

View file

@ -3,10 +3,12 @@ use {
client::{Client, ClientError}, client::{Client, ClientError},
ifs::{ ifs::{
ipc::{ ipc::{
add_data_source_mime_type, break_source_loops, cancel_offers, destroy_data_source, add_data_source_mime_type, break_source_loops, cancel_offers,
detach_seat, offer_source_to_x, data_control::zwlr_data_control_device_v1::{
WlrClipboardIpc, WlrPrimarySelectionIpc,
},
destroy_data_source, detach_seat, offer_source_to_x,
x_data_device::{XClipboardIpc, XIpcDevice, XPrimarySelectionIpc}, x_data_device::{XClipboardIpc, XIpcDevice, XPrimarySelectionIpc},
zwlr_data_control_device_v1::{WlrClipboardIpc, WlrPrimarySelectionIpc},
DataSource, DynDataSource, IpcLocation, SourceData, DataSource, DynDataSource, IpcLocation, SourceData,
}, },
wl_seat::WlSeatGlobal, wl_seat::WlSeatGlobal,

View file

@ -32,18 +32,17 @@ use {
ifs::{ ifs::{
ext_idle_notification_v1::ExtIdleNotificationV1, ext_idle_notification_v1::ExtIdleNotificationV1,
ipc::{ ipc::{
self, offer_source_to_regular_client, offer_source_to_wlr_device, self,
data_control::{DataControlDeviceId, DynDataControlDevice},
offer_source_to_regular_client,
wl_data_device::{ClipboardIpc, WlDataDevice}, wl_data_device::{ClipboardIpc, WlDataDevice},
wl_data_source::WlDataSource, wl_data_source::WlDataSource,
x_data_device::{XClipboardIpc, XIpcDevice, XIpcDeviceId, XPrimarySelectionIpc}, x_data_device::{XClipboardIpc, XIpcDevice, XIpcDeviceId, XPrimarySelectionIpc},
zwlr_data_control_device_v1::{
WlrClipboardIpc, WlrPrimarySelectionIpc, ZwlrDataControlDeviceV1,
},
zwp_primary_selection_device_v1::{ zwp_primary_selection_device_v1::{
PrimarySelectionIpc, ZwpPrimarySelectionDeviceV1, PrimarySelectionIpc, ZwpPrimarySelectionDeviceV1,
}, },
zwp_primary_selection_source_v1::ZwpPrimarySelectionSourceV1, zwp_primary_selection_source_v1::ZwpPrimarySelectionSourceV1,
DynDataSource, IpcError, DynDataSource, IpcError, IpcLocation,
}, },
wl_output::WlOutputGlobal, wl_output::WlOutputGlobal,
wl_seat::{ wl_seat::{
@ -88,8 +87,8 @@ use {
}, },
wire::{ wire::{
wl_seat::*, ExtIdleNotificationV1Id, WlDataDeviceId, WlKeyboardId, WlPointerId, wl_seat::*, ExtIdleNotificationV1Id, WlDataDeviceId, WlKeyboardId, WlPointerId,
WlSeatId, WlTouchId, XdgPopupId, ZwlrDataControlDeviceV1Id, WlSeatId, WlTouchId, XdgPopupId, ZwpPrimarySelectionDeviceV1Id, ZwpRelativePointerV1Id,
ZwpPrimarySelectionDeviceV1Id, ZwpRelativePointerV1Id, ZwpTextInputV3Id, ZwpTextInputV3Id,
}, },
wire_ei::EiSeatId, wire_ei::EiSeatId,
xkbcommon::{DynKeyboardState, KeyboardState, KeymapId, XkbKeymap, XkbState}, xkbcommon::{DynKeyboardState, KeyboardState, KeymapId, XkbKeymap, XkbState},
@ -167,8 +166,7 @@ pub struct WlSeatGlobal {
AHashMap<ZwpPrimarySelectionDeviceV1Id, Rc<ZwpPrimarySelectionDeviceV1>>, AHashMap<ZwpPrimarySelectionDeviceV1Id, Rc<ZwpPrimarySelectionDeviceV1>>,
>, >,
>, >,
wlr_data_devices: data_control_devices: CopyHashMap<DataControlDeviceId, Rc<dyn DynDataControlDevice>>,
CopyHashMap<(ClientId, ZwlrDataControlDeviceV1Id), Rc<ZwlrDataControlDeviceV1>>,
repeat_rate: Cell<(i32, i32)>, repeat_rate: Cell<(i32, i32)>,
seat_kb_map: CloneCell<Rc<XkbKeymap>>, seat_kb_map: CloneCell<Rc<XkbKeymap>>,
seat_xkb_state: CloneCell<Rc<RefCell<XkbState>>>, seat_xkb_state: CloneCell<Rc<RefCell<XkbState>>>,
@ -267,7 +265,7 @@ impl WlSeatGlobal {
constraint: Default::default(), constraint: Default::default(),
idle_notifications: Default::default(), idle_notifications: Default::default(),
last_input_usec: Cell::new(state.now_usec()), last_input_usec: Cell::new(state.now_usec()),
wlr_data_devices: Default::default(), data_control_devices: Default::default(),
text_inputs: Default::default(), text_inputs: Default::default(),
text_input: Default::default(), text_input: Default::default(),
input_method: Default::default(), input_method: Default::default(),
@ -383,13 +381,12 @@ impl WlSeatGlobal {
} }
} }
pub fn add_wlr_device(&self, device: &Rc<ZwlrDataControlDeviceV1>) { pub fn add_data_control_device(&self, device: Rc<dyn DynDataControlDevice>) {
self.wlr_data_devices self.data_control_devices.set(device.id(), device.clone());
.set((device.client.id, device.id), device.clone());
} }
pub fn remove_wlr_device(&self, device: &ZwlrDataControlDeviceV1) { pub fn remove_data_control_device(&self, device: &dyn DynDataControlDevice) {
self.wlr_data_devices.remove(&(device.client.id, device.id)); self.data_control_devices.remove(&device.id());
} }
pub fn get_output(&self) -> Rc<OutputNode> { pub fn get_output(&self) -> Rc<OutputNode> {
@ -711,15 +708,15 @@ impl WlSeatGlobal {
} }
} }
fn set_selection_<T, X, W, S>( fn set_selection_<T, X, S>(
self: &Rc<Self>, self: &Rc<Self>,
field: &CloneCell<Option<Rc<dyn DynDataSource>>>, field: &CloneCell<Option<Rc<dyn DynDataSource>>>,
src: Option<Rc<S>>, src: Option<Rc<S>>,
location: IpcLocation,
) -> Result<(), WlSeatError> ) -> Result<(), WlSeatError>
where where
T: ipc::IterableIpcVtable, T: ipc::IterableIpcVtable,
X: ipc::IpcVtable<Device = XIpcDevice>, X: ipc::IpcVtable<Device = XIpcDevice>,
W: ipc::WlrIpcVtable,
S: DynDataSource, S: DynDataSource,
{ {
if let (Some(new), Some(old)) = (&src, &field.get()) { if let (Some(new), Some(old)) = (&src, &field.get()) {
@ -738,10 +735,10 @@ impl WlSeatGlobal {
self.offer_selection_to_client::<T, X>(src.clone().map(|v| v as Rc<_>), &client); self.offer_selection_to_client::<T, X>(src.clone().map(|v| v as Rc<_>), &client);
// client.flush(); // client.flush();
} }
W::for_each_device(self, |device| match &src { let dyn_source = src.map(|s| s as Rc<dyn DynDataSource>);
Some(src) => offer_source_to_wlr_device::<W>(src.clone(), device), for dd in self.data_control_devices.lock().values() {
_ => W::send_selection(device, None), dd.clone().handle_new_source(location, dyn_source.clone());
}); }
Ok(()) Ok(())
} }
@ -825,9 +822,10 @@ impl WlSeatGlobal {
self: &Rc<Self>, self: &Rc<Self>,
selection: Option<Rc<S>>, selection: Option<Rc<S>>,
) -> Result<(), WlSeatError> { ) -> Result<(), WlSeatError> {
self.set_selection_::<ClipboardIpc, XClipboardIpc, WlrClipboardIpc, _>( self.set_selection_::<ClipboardIpc, XClipboardIpc, _>(
&self.selection, &self.selection,
selection, selection,
IpcLocation::Clipboard,
) )
} }
@ -871,9 +869,10 @@ impl WlSeatGlobal {
self: &Rc<Self>, self: &Rc<Self>,
selection: Option<Rc<S>>, selection: Option<Rc<S>>,
) -> Result<(), WlSeatError> { ) -> Result<(), WlSeatError> {
self.set_selection_::<PrimarySelectionIpc, XPrimarySelectionIpc, WlrPrimarySelectionIpc, _>( self.set_selection_::<PrimarySelectionIpc, XPrimarySelectionIpc, _>(
&self.primary_selection, &self.primary_selection,
selection, selection,
IpcLocation::PrimarySelection,
) )
} }
@ -910,7 +909,7 @@ impl WlSeatGlobal {
self.bindings.borrow_mut().clear(); self.bindings.borrow_mut().clear();
self.data_devices.borrow_mut().clear(); self.data_devices.borrow_mut().clear();
self.primary_selection_devices.borrow_mut().clear(); self.primary_selection_devices.borrow_mut().clear();
self.wlr_data_devices.clear(); self.data_control_devices.clear();
self.cursor_user_group.detach(); self.cursor_user_group.detach();
self.selection.set(None); self.selection.set(None);
self.primary_selection.set(None); self.primary_selection.set(None);

View file

@ -12,7 +12,6 @@ use {
offer_source_to_regular_client, offer_source_to_regular_client,
wl_data_device::{ClipboardIpc, WlDataDevice}, wl_data_device::{ClipboardIpc, WlDataDevice},
x_data_device::{XClipboardIpc, XPrimarySelectionIpc}, x_data_device::{XClipboardIpc, XPrimarySelectionIpc},
zwlr_data_control_device_v1::ZwlrDataControlDeviceV1,
zwp_primary_selection_device_v1::{ zwp_primary_selection_device_v1::{
PrimarySelectionIpc, ZwpPrimarySelectionDeviceV1, PrimarySelectionIpc, ZwpPrimarySelectionDeviceV1,
}, },
@ -1037,17 +1036,6 @@ impl WlSeatGlobal {
} }
} }
pub fn for_each_wlr_data_device<C>(&self, ver: Version, mut f: C)
where
C: FnMut(&Rc<ZwlrDataControlDeviceV1>),
{
for dd in self.wlr_data_devices.lock().values() {
if dd.version >= ver {
f(dd);
}
}
}
fn surface_pointer_frame(&self, surface: &WlSurface) { fn surface_pointer_frame(&self, surface: &WlSurface) {
self.surface_pointer_event(POINTER_FRAME_SINCE_VERSION, surface, |p| p.send_frame()); self.surface_pointer_event(POINTER_FRAME_SINCE_VERSION, surface, |p| p.send_frame());
} }

View file

@ -35,7 +35,10 @@ use {
ifs::{ ifs::{
ext_foreign_toplevel_list_v1::ExtForeignToplevelListV1, ext_foreign_toplevel_list_v1::ExtForeignToplevelListV1,
ext_session_lock_v1::ExtSessionLockV1, ext_session_lock_v1::ExtSessionLockV1,
ipc::{x_data_device::XIpcDeviceIds, DataOfferIds, DataSourceIds}, ipc::{
data_control::DataControlDeviceIds, x_data_device::XIpcDeviceIds, DataOfferIds,
DataSourceIds,
},
jay_render_ctx::JayRenderCtx, jay_render_ctx::JayRenderCtx,
jay_screencast::JayScreencast, jay_screencast::JayScreencast,
jay_seat_events::JaySeatEvents, jay_seat_events::JaySeatEvents,
@ -224,6 +227,7 @@ pub struct State {
pub toplevels: CopyHashMap<ToplevelIdentifier, Weak<dyn ToplevelNode>>, pub toplevels: CopyHashMap<ToplevelIdentifier, Weak<dyn ToplevelNode>>,
pub const_40hz_latch: EventSource<dyn LatchListener>, pub const_40hz_latch: EventSource<dyn LatchListener>,
pub tray_item_ids: TrayItemIds, pub tray_item_ids: TrayItemIds,
pub data_control_device_ids: DataControlDeviceIds,
} }
// impl Drop for State { // impl Drop for State {