server: refactor to use ECS
This should simplify how some of the code reads, as well as allowing for future feature additions to be accomplished in a less restrictive manner. The slotmap + Object enum pattern was kind of like a really bad ecs in a way anyway. Also I was looking for an excuse to use an ecs.
This commit is contained in:
parent
da2ecb5be8
commit
799027d1ae
11 changed files with 2046 additions and 1970 deletions
|
|
@ -1,133 +0,0 @@
|
|||
use crate::clientside::Globals;
|
||||
use smithay_client_toolkit::{
|
||||
data_device_manager::{
|
||||
data_device::DataDeviceHandler, data_offer::DataOfferHandler,
|
||||
data_source::DataSourceHandler,
|
||||
},
|
||||
delegate_data_device,
|
||||
};
|
||||
delegate_data_device!(Globals);
|
||||
|
||||
impl DataDeviceHandler for Globals {
|
||||
fn selection(
|
||||
&mut self,
|
||||
_: &wayland_client::Connection,
|
||||
_: &wayland_client::QueueHandle<Self>,
|
||||
data_device: &wayland_client::protocol::wl_data_device::WlDataDevice,
|
||||
) {
|
||||
self.selection = Some(data_device.clone());
|
||||
}
|
||||
|
||||
fn drop_performed(
|
||||
&mut self,
|
||||
_: &wayland_client::Connection,
|
||||
_: &wayland_client::QueueHandle<Self>,
|
||||
_: &wayland_client::protocol::wl_data_device::WlDataDevice,
|
||||
) {
|
||||
}
|
||||
|
||||
fn motion(
|
||||
&mut self,
|
||||
_: &wayland_client::Connection,
|
||||
_: &wayland_client::QueueHandle<Self>,
|
||||
_: &wayland_client::protocol::wl_data_device::WlDataDevice,
|
||||
_: f64,
|
||||
_: f64,
|
||||
) {
|
||||
}
|
||||
|
||||
fn leave(
|
||||
&mut self,
|
||||
_: &wayland_client::Connection,
|
||||
_: &wayland_client::QueueHandle<Self>,
|
||||
_: &wayland_client::protocol::wl_data_device::WlDataDevice,
|
||||
) {
|
||||
}
|
||||
|
||||
fn enter(
|
||||
&mut self,
|
||||
_: &wayland_client::Connection,
|
||||
_: &wayland_client::QueueHandle<Self>,
|
||||
_: &wayland_client::protocol::wl_data_device::WlDataDevice,
|
||||
_: f64,
|
||||
_: f64,
|
||||
_: &wayland_client::protocol::wl_surface::WlSurface,
|
||||
) {
|
||||
}
|
||||
}
|
||||
|
||||
impl DataSourceHandler for Globals {
|
||||
fn send_request(
|
||||
&mut self,
|
||||
_: &wayland_client::Connection,
|
||||
_: &wayland_client::QueueHandle<Self>,
|
||||
_: &wayland_client::protocol::wl_data_source::WlDataSource,
|
||||
mime: String,
|
||||
fd: smithay_client_toolkit::data_device_manager::WritePipe,
|
||||
) {
|
||||
self.selection_requests.push((mime, fd));
|
||||
}
|
||||
|
||||
fn cancelled(
|
||||
&mut self,
|
||||
_: &wayland_client::Connection,
|
||||
_: &wayland_client::QueueHandle<Self>,
|
||||
_: &wayland_client::protocol::wl_data_source::WlDataSource,
|
||||
) {
|
||||
self.cancelled = true;
|
||||
}
|
||||
|
||||
fn action(
|
||||
&mut self,
|
||||
_: &wayland_client::Connection,
|
||||
_: &wayland_client::QueueHandle<Self>,
|
||||
_: &wayland_client::protocol::wl_data_source::WlDataSource,
|
||||
_: wayland_client::protocol::wl_data_device_manager::DndAction,
|
||||
) {
|
||||
}
|
||||
|
||||
fn dnd_finished(
|
||||
&mut self,
|
||||
_: &wayland_client::Connection,
|
||||
_: &wayland_client::QueueHandle<Self>,
|
||||
_: &wayland_client::protocol::wl_data_source::WlDataSource,
|
||||
) {
|
||||
}
|
||||
|
||||
fn dnd_dropped(
|
||||
&mut self,
|
||||
_: &wayland_client::Connection,
|
||||
_: &wayland_client::QueueHandle<Self>,
|
||||
_: &wayland_client::protocol::wl_data_source::WlDataSource,
|
||||
) {
|
||||
}
|
||||
|
||||
fn accept_mime(
|
||||
&mut self,
|
||||
_: &wayland_client::Connection,
|
||||
_: &wayland_client::QueueHandle<Self>,
|
||||
_: &wayland_client::protocol::wl_data_source::WlDataSource,
|
||||
_: Option<String>,
|
||||
) {
|
||||
}
|
||||
}
|
||||
|
||||
impl DataOfferHandler for Globals {
|
||||
fn selected_action(
|
||||
&mut self,
|
||||
_: &wayland_client::Connection,
|
||||
_: &wayland_client::QueueHandle<Self>,
|
||||
_: &mut smithay_client_toolkit::data_device_manager::data_offer::DragOffer,
|
||||
_: wayland_client::protocol::wl_data_device_manager::DndAction,
|
||||
) {
|
||||
}
|
||||
|
||||
fn source_actions(
|
||||
&mut self,
|
||||
_: &wayland_client::Connection,
|
||||
_: &wayland_client::QueueHandle<Self>,
|
||||
_: &mut smithay_client_toolkit::data_device_manager::data_offer::DragOffer,
|
||||
_: wayland_client::protocol::wl_data_device_manager::DndAction,
|
||||
) {
|
||||
}
|
||||
}
|
||||
|
|
@ -1,42 +0,0 @@
|
|||
use smithay_client_toolkit::{
|
||||
activation::{ActivationHandler, RequestData, RequestDataExt},
|
||||
delegate_activation,
|
||||
};
|
||||
use xcb::x;
|
||||
|
||||
use crate::clientside::Globals;
|
||||
|
||||
delegate_activation!(Globals, ActivationData);
|
||||
|
||||
pub struct ActivationData {
|
||||
window: x::Window,
|
||||
data: RequestData,
|
||||
}
|
||||
|
||||
impl ActivationData {
|
||||
pub fn new(window: x::Window, data: RequestData) -> Self {
|
||||
Self { window, data }
|
||||
}
|
||||
}
|
||||
|
||||
impl RequestDataExt for ActivationData {
|
||||
fn app_id(&self) -> Option<&str> {
|
||||
self.data.app_id()
|
||||
}
|
||||
|
||||
fn seat_and_serial(&self) -> Option<(&wayland_client::protocol::wl_seat::WlSeat, u32)> {
|
||||
self.data.seat_and_serial()
|
||||
}
|
||||
|
||||
fn surface(&self) -> Option<&wayland_client::protocol::wl_surface::WlSurface> {
|
||||
self.data.surface()
|
||||
}
|
||||
}
|
||||
|
||||
impl ActivationHandler for Globals {
|
||||
type RequestData = ActivationData;
|
||||
|
||||
fn new_token(&mut self, token: String, data: &Self::RequestData) {
|
||||
self.pending_activations.push((data.window, token));
|
||||
}
|
||||
}
|
||||
|
|
@ -1,4 +1,3 @@
|
|||
mod clientside;
|
||||
mod server;
|
||||
pub mod xstate;
|
||||
|
||||
|
|
|
|||
|
|
@ -1,8 +1,13 @@
|
|||
mod data_device;
|
||||
pub mod xdg_activation;
|
||||
|
||||
use crate::server::{ObjectEvent, ObjectKey};
|
||||
use std::os::unix::net::UnixStream;
|
||||
use super::ObjectEvent;
|
||||
use hecs::{Entity, World};
|
||||
use smithay_client_toolkit::{
|
||||
activation::{ActivationHandler, RequestData, RequestDataExt},
|
||||
data_device_manager::{
|
||||
data_device::DataDeviceHandler, data_offer::DataOfferHandler,
|
||||
data_source::DataSourceHandler,
|
||||
},
|
||||
delegate_activation, delegate_data_device,
|
||||
};
|
||||
use std::sync::{mpsc, Mutex, OnceLock};
|
||||
use wayland_client::protocol::{
|
||||
wl_buffer::WlBuffer, wl_callback::WlCallback, wl_compositor::WlCompositor,
|
||||
|
|
@ -12,16 +17,14 @@ use wayland_client::protocol::{
|
|||
};
|
||||
use wayland_client::{
|
||||
delegate_noop, event_created_child,
|
||||
globals::{registry_queue_init, Global, GlobalList, GlobalListContents},
|
||||
Connection, Dispatch, EventQueue, Proxy, QueueHandle,
|
||||
globals::{Global, GlobalList, GlobalListContents},
|
||||
Connection, Dispatch, Proxy, QueueHandle,
|
||||
};
|
||||
use wayland_protocols::wp::relative_pointer::zv1::client::{
|
||||
zwp_relative_pointer_manager_v1::ZwpRelativePointerManagerV1,
|
||||
zwp_relative_pointer_v1::ZwpRelativePointerV1,
|
||||
};
|
||||
use wayland_protocols::xdg::decoration::zv1::client::zxdg_decoration_manager_v1::ZxdgDecorationManagerV1;
|
||||
use wayland_protocols::xdg::decoration::zv1::client::zxdg_toplevel_decoration_v1::ZxdgToplevelDecorationV1;
|
||||
use wayland_protocols::{
|
||||
wp::relative_pointer::zv1::client::{
|
||||
zwp_relative_pointer_manager_v1::ZwpRelativePointerManagerV1,
|
||||
zwp_relative_pointer_v1::ZwpRelativePointerV1,
|
||||
},
|
||||
wp::{
|
||||
fractional_scale::v1::client::{
|
||||
wp_fractional_scale_manager_v1::WpFractionalScaleManagerV1,
|
||||
|
|
@ -52,6 +55,8 @@ use wayland_protocols::{
|
|||
},
|
||||
viewporter::client::{wp_viewport::WpViewport, wp_viewporter::WpViewporter},
|
||||
},
|
||||
xdg::decoration::zv1::client::zxdg_decoration_manager_v1::ZxdgDecorationManagerV1,
|
||||
xdg::decoration::zv1::client::zxdg_toplevel_decoration_v1::ZxdgToplevelDecorationV1,
|
||||
xdg::{
|
||||
activation::v1::client::xdg_activation_v1::XdgActivationV1,
|
||||
shell::client::{
|
||||
|
|
@ -65,55 +70,56 @@ use wayland_protocols::{
|
|||
};
|
||||
use wayland_server::protocol as server;
|
||||
use wl_drm::client::wl_drm::WlDrm;
|
||||
use xcb::x;
|
||||
|
||||
#[derive(Default)]
|
||||
pub struct Globals {
|
||||
events: Vec<(ObjectKey, ObjectEvent)>,
|
||||
queued_events: Vec<mpsc::Receiver<(ObjectKey, ObjectEvent)>>,
|
||||
pub(super) struct MyWorld {
|
||||
pub world: World,
|
||||
pub global_list: GlobalList,
|
||||
pub new_globals: Vec<Global>,
|
||||
events: Vec<(Entity, ObjectEvent)>,
|
||||
queued_events: Vec<mpsc::Receiver<(Entity, ObjectEvent)>>,
|
||||
pub selection: Option<wayland_client::protocol::wl_data_device::WlDataDevice>,
|
||||
pub selection_requests: Vec<(
|
||||
String,
|
||||
smithay_client_toolkit::data_device_manager::WritePipe,
|
||||
)>,
|
||||
pub cancelled: bool,
|
||||
pub selection_cancelled: bool,
|
||||
pub pending_activations: Vec<(xcb::x::Window, String)>,
|
||||
}
|
||||
|
||||
pub type ClientQueueHandle = QueueHandle<Globals>;
|
||||
|
||||
pub struct ClientState {
|
||||
_connection: Connection,
|
||||
pub queue: EventQueue<Globals>,
|
||||
pub qh: ClientQueueHandle,
|
||||
pub globals: Globals,
|
||||
pub global_list: GlobalList,
|
||||
}
|
||||
|
||||
impl ClientState {
|
||||
pub fn new(server_connection: Option<UnixStream>) -> Self {
|
||||
let connection = if let Some(stream) = server_connection {
|
||||
Connection::from_socket(stream)
|
||||
} else {
|
||||
Connection::connect_to_env()
|
||||
}
|
||||
.unwrap();
|
||||
let (global_list, queue) = registry_queue_init::<Globals>(&connection).unwrap();
|
||||
let globals = Globals::default();
|
||||
let qh = queue.handle();
|
||||
|
||||
impl MyWorld {
|
||||
pub fn new(global_list: GlobalList) -> Self {
|
||||
Self {
|
||||
_connection: connection,
|
||||
queue,
|
||||
qh,
|
||||
globals,
|
||||
world: World::new(),
|
||||
global_list,
|
||||
new_globals: Vec::new(),
|
||||
events: Vec::new(),
|
||||
queued_events: Vec::new(),
|
||||
selection: None,
|
||||
selection_requests: Vec::new(),
|
||||
selection_cancelled: false,
|
||||
pending_activations: Vec::new(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub fn read_events(&mut self) -> Vec<(ObjectKey, ObjectEvent)> {
|
||||
let mut events = std::mem::take(&mut self.globals.events);
|
||||
self.globals.queued_events.retain(|rx| {
|
||||
impl std::ops::Deref for MyWorld {
|
||||
type Target = World;
|
||||
fn deref(&self) -> &Self::Target {
|
||||
&self.world
|
||||
}
|
||||
}
|
||||
|
||||
impl std::ops::DerefMut for MyWorld {
|
||||
fn deref_mut(&mut self) -> &mut Self::Target {
|
||||
&mut self.world
|
||||
}
|
||||
}
|
||||
|
||||
impl MyWorld {
|
||||
pub(crate) fn read_events(&mut self) -> Vec<(Entity, ObjectEvent)> {
|
||||
let mut events = std::mem::take(&mut self.events);
|
||||
self.queued_events.retain(|rx| {
|
||||
match rx.try_recv() {
|
||||
Ok(event) => {
|
||||
events.push(event);
|
||||
|
|
@ -132,25 +138,25 @@ impl ClientState {
|
|||
|
||||
pub type Event<T> = <T as Proxy>::Event;
|
||||
|
||||
delegate_noop!(Globals: WlCompositor);
|
||||
delegate_noop!(Globals: WlRegion);
|
||||
delegate_noop!(Globals: ignore WlShm);
|
||||
delegate_noop!(Globals: ignore ZwpLinuxDmabufV1);
|
||||
delegate_noop!(Globals: ZwpRelativePointerManagerV1);
|
||||
delegate_noop!(Globals: ignore dmabuf::zwp_linux_buffer_params_v1::ZwpLinuxBufferParamsV1);
|
||||
delegate_noop!(Globals: XdgPositioner);
|
||||
delegate_noop!(Globals: WlShmPool);
|
||||
delegate_noop!(Globals: WpViewporter);
|
||||
delegate_noop!(Globals: WpViewport);
|
||||
delegate_noop!(Globals: ZxdgOutputManagerV1);
|
||||
delegate_noop!(Globals: ZwpPointerConstraintsV1);
|
||||
delegate_noop!(Globals: ZwpTabletManagerV2);
|
||||
delegate_noop!(Globals: XdgActivationV1);
|
||||
delegate_noop!(Globals: ZxdgDecorationManagerV1);
|
||||
delegate_noop!(Globals: WpFractionalScaleManagerV1);
|
||||
delegate_noop!(Globals: ignore ZxdgToplevelDecorationV1);
|
||||
delegate_noop!(MyWorld: WlCompositor);
|
||||
delegate_noop!(MyWorld: WlRegion);
|
||||
delegate_noop!(MyWorld: ignore WlShm);
|
||||
delegate_noop!(MyWorld: ignore ZwpLinuxDmabufV1);
|
||||
delegate_noop!(MyWorld: ZwpRelativePointerManagerV1);
|
||||
delegate_noop!(MyWorld: ignore dmabuf::zwp_linux_buffer_params_v1::ZwpLinuxBufferParamsV1);
|
||||
delegate_noop!(MyWorld: XdgPositioner);
|
||||
delegate_noop!(MyWorld: WlShmPool);
|
||||
delegate_noop!(MyWorld: WpViewporter);
|
||||
delegate_noop!(MyWorld: WpViewport);
|
||||
delegate_noop!(MyWorld: ZxdgOutputManagerV1);
|
||||
delegate_noop!(MyWorld: ZwpPointerConstraintsV1);
|
||||
delegate_noop!(MyWorld: ZwpTabletManagerV2);
|
||||
delegate_noop!(MyWorld: XdgActivationV1);
|
||||
delegate_noop!(MyWorld: ZxdgDecorationManagerV1);
|
||||
delegate_noop!(MyWorld: WpFractionalScaleManagerV1);
|
||||
delegate_noop!(MyWorld: ignore ZxdgToplevelDecorationV1);
|
||||
|
||||
impl Dispatch<WlRegistry, GlobalListContents> for Globals {
|
||||
impl Dispatch<WlRegistry, GlobalListContents> for MyWorld {
|
||||
fn event(
|
||||
state: &mut Self,
|
||||
_: &WlRegistry,
|
||||
|
|
@ -174,7 +180,7 @@ impl Dispatch<WlRegistry, GlobalListContents> for Globals {
|
|||
}
|
||||
}
|
||||
|
||||
impl Dispatch<XdgWmBase, ()> for Globals {
|
||||
impl Dispatch<XdgWmBase, ()> for MyWorld {
|
||||
fn event(
|
||||
_: &mut Self,
|
||||
base: &XdgWmBase,
|
||||
|
|
@ -189,7 +195,7 @@ impl Dispatch<XdgWmBase, ()> for Globals {
|
|||
}
|
||||
}
|
||||
|
||||
impl Dispatch<WlCallback, server::wl_callback::WlCallback> for Globals {
|
||||
impl Dispatch<WlCallback, server::wl_callback::WlCallback> for MyWorld {
|
||||
fn event(
|
||||
_: &mut Self,
|
||||
_: &WlCallback,
|
||||
|
|
@ -206,12 +212,12 @@ impl Dispatch<WlCallback, server::wl_callback::WlCallback> for Globals {
|
|||
|
||||
macro_rules! push_events {
|
||||
($type:ident) => {
|
||||
impl Dispatch<$type, ObjectKey> for Globals {
|
||||
impl Dispatch<$type, Entity> for MyWorld {
|
||||
fn event(
|
||||
state: &mut Self,
|
||||
_: &$type,
|
||||
event: <$type as Proxy>::Event,
|
||||
key: &ObjectKey,
|
||||
key: &Entity,
|
||||
_: &Connection,
|
||||
_: &QueueHandle<Self>,
|
||||
) {
|
||||
|
|
@ -240,16 +246,16 @@ push_events!(ZwpLockedPointerV1);
|
|||
push_events!(WpFractionalScaleV1);
|
||||
|
||||
pub(crate) struct LateInitObjectKey<P: Proxy> {
|
||||
key: OnceLock<ObjectKey>,
|
||||
key: OnceLock<Entity>,
|
||||
queued_events: Mutex<Vec<P::Event>>,
|
||||
sender: Mutex<Option<mpsc::Sender<(ObjectKey, ObjectEvent)>>>,
|
||||
sender: Mutex<Option<mpsc::Sender<(Entity, ObjectEvent)>>>,
|
||||
}
|
||||
|
||||
impl<P: Proxy> LateInitObjectKey<P>
|
||||
where
|
||||
P::Event: Into<ObjectEvent>,
|
||||
{
|
||||
pub fn init(&self, key: ObjectKey) {
|
||||
pub fn init(&self, key: Entity) {
|
||||
self.key.set(key).expect("Object key should not be set");
|
||||
if let Some(sender) = self.sender.lock().unwrap().take() {
|
||||
for event in self.queued_events.lock().unwrap().drain(..) {
|
||||
|
|
@ -266,7 +272,7 @@ where
|
|||
}
|
||||
}
|
||||
|
||||
fn push_or_queue_event(&self, state: &mut Globals, event: P::Event) {
|
||||
fn push_or_queue_event(&self, state: &mut MyWorld, event: P::Event) {
|
||||
if let Some(key) = self.key.get().copied() {
|
||||
state.events.push((key, event.into()));
|
||||
} else {
|
||||
|
|
@ -282,7 +288,7 @@ where
|
|||
}
|
||||
|
||||
impl<P: Proxy> std::ops::Deref for LateInitObjectKey<P> {
|
||||
type Target = ObjectKey;
|
||||
type Target = Entity;
|
||||
|
||||
#[track_caller]
|
||||
fn deref(&self) -> &Self::Target {
|
||||
|
|
@ -290,19 +296,19 @@ impl<P: Proxy> std::ops::Deref for LateInitObjectKey<P> {
|
|||
}
|
||||
}
|
||||
|
||||
impl Dispatch<ZwpTabletSeatV2, ObjectKey> for Globals {
|
||||
impl Dispatch<ZwpTabletSeatV2, Entity> for MyWorld {
|
||||
fn event(
|
||||
state: &mut Self,
|
||||
_: &ZwpTabletSeatV2,
|
||||
event: <ZwpTabletSeatV2 as Proxy>::Event,
|
||||
key: &ObjectKey,
|
||||
key: &Entity,
|
||||
_: &Connection,
|
||||
_: &QueueHandle<Self>,
|
||||
) {
|
||||
state.events.push((*key, event.into()));
|
||||
}
|
||||
|
||||
event_created_child!(Globals, ZwpTabletSeatV2, [
|
||||
event_created_child!(MyWorld, ZwpTabletSeatV2, [
|
||||
EVT_TABLET_ADDED_OPCODE => (ZwpTabletV2, LateInitObjectKey::new()),
|
||||
EVT_PAD_ADDED_OPCODE => (ZwpTabletPadV2, LateInitObjectKey::new()),
|
||||
EVT_TOOL_ADDED_OPCODE => (ZwpTabletToolV2, LateInitObjectKey::new())
|
||||
|
|
@ -311,7 +317,7 @@ impl Dispatch<ZwpTabletSeatV2, ObjectKey> for Globals {
|
|||
|
||||
macro_rules! push_or_queue_events {
|
||||
($type:ty) => {
|
||||
impl Dispatch<$type, LateInitObjectKey<$type>> for Globals {
|
||||
impl Dispatch<$type, LateInitObjectKey<$type>> for MyWorld {
|
||||
fn event(
|
||||
state: &mut Self,
|
||||
_: &$type,
|
||||
|
|
@ -331,7 +337,7 @@ push_or_queue_events!(ZwpTabletToolV2);
|
|||
push_or_queue_events!(ZwpTabletPadRingV2);
|
||||
push_or_queue_events!(ZwpTabletPadStripV2);
|
||||
|
||||
impl Dispatch<ZwpTabletPadV2, LateInitObjectKey<ZwpTabletPadV2>> for Globals {
|
||||
impl Dispatch<ZwpTabletPadV2, LateInitObjectKey<ZwpTabletPadV2>> for MyWorld {
|
||||
fn event(
|
||||
state: &mut Self,
|
||||
_: &ZwpTabletPadV2,
|
||||
|
|
@ -343,12 +349,12 @@ impl Dispatch<ZwpTabletPadV2, LateInitObjectKey<ZwpTabletPadV2>> for Globals {
|
|||
key.push_or_queue_event(state, event);
|
||||
}
|
||||
|
||||
event_created_child!(Globals, ZwpTabletPadV2, [
|
||||
event_created_child!(MyWorld, ZwpTabletPadV2, [
|
||||
EVT_GROUP_OPCODE => (ZwpTabletPadGroupV2, LateInitObjectKey::new())
|
||||
]);
|
||||
}
|
||||
|
||||
impl Dispatch<ZwpTabletPadGroupV2, LateInitObjectKey<ZwpTabletPadGroupV2>> for Globals {
|
||||
impl Dispatch<ZwpTabletPadGroupV2, LateInitObjectKey<ZwpTabletPadGroupV2>> for MyWorld {
|
||||
fn event(
|
||||
state: &mut Self,
|
||||
_: &ZwpTabletPadGroupV2,
|
||||
|
|
@ -360,8 +366,169 @@ impl Dispatch<ZwpTabletPadGroupV2, LateInitObjectKey<ZwpTabletPadGroupV2>> for G
|
|||
key.push_or_queue_event(state, event);
|
||||
}
|
||||
|
||||
event_created_child!(Globals, ZwpTabletPadGroupV2, [
|
||||
event_created_child!(MyWorld, ZwpTabletPadGroupV2, [
|
||||
EVT_RING_OPCODE => (ZwpTabletPadRingV2, LateInitObjectKey::new()),
|
||||
EVT_STRIP_OPCODE => (ZwpTabletPadStripV2, LateInitObjectKey::new())
|
||||
]);
|
||||
}
|
||||
|
||||
delegate_data_device!(MyWorld);
|
||||
|
||||
impl DataDeviceHandler for MyWorld {
|
||||
fn selection(
|
||||
&mut self,
|
||||
_: &wayland_client::Connection,
|
||||
_: &wayland_client::QueueHandle<Self>,
|
||||
data_device: &wayland_client::protocol::wl_data_device::WlDataDevice,
|
||||
) {
|
||||
self.selection = Some(data_device.clone());
|
||||
}
|
||||
|
||||
fn drop_performed(
|
||||
&mut self,
|
||||
_: &wayland_client::Connection,
|
||||
_: &wayland_client::QueueHandle<Self>,
|
||||
_: &wayland_client::protocol::wl_data_device::WlDataDevice,
|
||||
) {
|
||||
}
|
||||
|
||||
fn motion(
|
||||
&mut self,
|
||||
_: &wayland_client::Connection,
|
||||
_: &wayland_client::QueueHandle<Self>,
|
||||
_: &wayland_client::protocol::wl_data_device::WlDataDevice,
|
||||
_: f64,
|
||||
_: f64,
|
||||
) {
|
||||
}
|
||||
|
||||
fn leave(
|
||||
&mut self,
|
||||
_: &wayland_client::Connection,
|
||||
_: &wayland_client::QueueHandle<Self>,
|
||||
_: &wayland_client::protocol::wl_data_device::WlDataDevice,
|
||||
) {
|
||||
}
|
||||
|
||||
fn enter(
|
||||
&mut self,
|
||||
_: &wayland_client::Connection,
|
||||
_: &wayland_client::QueueHandle<Self>,
|
||||
_: &wayland_client::protocol::wl_data_device::WlDataDevice,
|
||||
_: f64,
|
||||
_: f64,
|
||||
_: &wayland_client::protocol::wl_surface::WlSurface,
|
||||
) {
|
||||
}
|
||||
}
|
||||
|
||||
impl DataSourceHandler for MyWorld {
|
||||
fn send_request(
|
||||
&mut self,
|
||||
_: &wayland_client::Connection,
|
||||
_: &wayland_client::QueueHandle<Self>,
|
||||
_: &wayland_client::protocol::wl_data_source::WlDataSource,
|
||||
mime: String,
|
||||
fd: smithay_client_toolkit::data_device_manager::WritePipe,
|
||||
) {
|
||||
self.selection_requests.push((mime, fd));
|
||||
}
|
||||
|
||||
fn cancelled(
|
||||
&mut self,
|
||||
_: &wayland_client::Connection,
|
||||
_: &wayland_client::QueueHandle<Self>,
|
||||
_: &wayland_client::protocol::wl_data_source::WlDataSource,
|
||||
) {
|
||||
self.selection_cancelled = true;
|
||||
}
|
||||
|
||||
fn action(
|
||||
&mut self,
|
||||
_: &wayland_client::Connection,
|
||||
_: &wayland_client::QueueHandle<Self>,
|
||||
_: &wayland_client::protocol::wl_data_source::WlDataSource,
|
||||
_: wayland_client::protocol::wl_data_device_manager::DndAction,
|
||||
) {
|
||||
}
|
||||
|
||||
fn dnd_finished(
|
||||
&mut self,
|
||||
_: &wayland_client::Connection,
|
||||
_: &wayland_client::QueueHandle<Self>,
|
||||
_: &wayland_client::protocol::wl_data_source::WlDataSource,
|
||||
) {
|
||||
}
|
||||
|
||||
fn dnd_dropped(
|
||||
&mut self,
|
||||
_: &wayland_client::Connection,
|
||||
_: &wayland_client::QueueHandle<Self>,
|
||||
_: &wayland_client::protocol::wl_data_source::WlDataSource,
|
||||
) {
|
||||
}
|
||||
|
||||
fn accept_mime(
|
||||
&mut self,
|
||||
_: &wayland_client::Connection,
|
||||
_: &wayland_client::QueueHandle<Self>,
|
||||
_: &wayland_client::protocol::wl_data_source::WlDataSource,
|
||||
_: Option<String>,
|
||||
) {
|
||||
}
|
||||
}
|
||||
|
||||
impl DataOfferHandler for MyWorld {
|
||||
fn selected_action(
|
||||
&mut self,
|
||||
_: &wayland_client::Connection,
|
||||
_: &wayland_client::QueueHandle<Self>,
|
||||
_: &mut smithay_client_toolkit::data_device_manager::data_offer::DragOffer,
|
||||
_: wayland_client::protocol::wl_data_device_manager::DndAction,
|
||||
) {
|
||||
}
|
||||
|
||||
fn source_actions(
|
||||
&mut self,
|
||||
_: &wayland_client::Connection,
|
||||
_: &wayland_client::QueueHandle<Self>,
|
||||
_: &mut smithay_client_toolkit::data_device_manager::data_offer::DragOffer,
|
||||
_: wayland_client::protocol::wl_data_device_manager::DndAction,
|
||||
) {
|
||||
}
|
||||
}
|
||||
|
||||
delegate_activation!(MyWorld, ActivationData);
|
||||
|
||||
pub struct ActivationData {
|
||||
window: x::Window,
|
||||
data: RequestData,
|
||||
}
|
||||
|
||||
impl ActivationData {
|
||||
pub fn new(window: x::Window, data: RequestData) -> Self {
|
||||
Self { window, data }
|
||||
}
|
||||
}
|
||||
|
||||
impl RequestDataExt for ActivationData {
|
||||
fn app_id(&self) -> Option<&str> {
|
||||
self.data.app_id()
|
||||
}
|
||||
|
||||
fn seat_and_serial(&self) -> Option<(&wayland_client::protocol::wl_seat::WlSeat, u32)> {
|
||||
self.data.seat_and_serial()
|
||||
}
|
||||
|
||||
fn surface(&self) -> Option<&wayland_client::protocol::wl_surface::WlSurface> {
|
||||
self.data.surface()
|
||||
}
|
||||
}
|
||||
|
||||
impl ActivationHandler for MyWorld {
|
||||
type RequestData = ActivationData;
|
||||
|
||||
fn new_token(&mut self, token: String, data: &Self::RequestData) {
|
||||
self.pending_activations.push((data.window, token));
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load diff
1573
src/server/event.rs
1573
src/server/event.rs
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
Loading…
Add table
Add a link
Reference in a new issue