From 0a4c4b5941fe982ccb3d3175e26d9d83f0025ffd Mon Sep 17 00:00:00 2001 From: srdusr <99972264+srdusr@users.noreply.github.com> Date: Sat, 15 Feb 2025 14:56:00 +0200 Subject: Checkpoint: preserve all uncommitted rust-rewrite worktree work Safety commit before reconciling this worktree with main, which has diverged with its own separate fixes today. Nothing here is reviewed or curated yet - this exists purely so none of this work can be lost to a git operation, disk issue, or worktree cleanup while that reconciliation happens. --- crates/wayland/src/protocols/selection.rs | 52 +++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) create mode 100644 crates/wayland/src/protocols/selection.rs (limited to 'crates/wayland/src/protocols/selection.rs') diff --git a/crates/wayland/src/protocols/selection.rs b/crates/wayland/src/protocols/selection.rs new file mode 100644 index 0000000..fadb0ca --- /dev/null +++ b/crates/wayland/src/protocols/selection.rs @@ -0,0 +1,52 @@ +//! Clipboard/primary-selection/drag-and-drop. +//! +//! All three selection protocols below (`wl_data_device_manager`, +//! `zwp_primary_selection_v1`, `zwlr_data_control_manager_v1`) share +//! smithay's single `SelectionHandler`. Every transfer here is +//! *client-to-client*: one client owns the selection and writes the bytes +//! itself, and smithay wires the two ends together without the data passing +//! through us. `send_selection` is only ever called for a +//! **compositor-provided** selection (one this WM set itself via +//! `set_data_device_selection`), which srdwm never does - so it is +//! deliberately left unimplemented rather than faked. + +use smithay::wayland::selection::data_device::{ClientDndGrabHandler, DataDeviceHandler, DataDeviceState, ServerDndGrabHandler}; +use smithay::wayland::selection::primary_selection::{PrimarySelectionHandler, PrimarySelectionState}; +use smithay::wayland::selection::wlr_data_control::{DataControlHandler, DataControlState}; +use smithay::wayland::selection::SelectionHandler; + +use crate::state::CompState; + +impl SelectionHandler for CompState { + type SelectionUserData = (); +} + +impl DataDeviceHandler for CompState { + fn data_device_state(&self) -> &DataDeviceState { + &self.data_device_state + } +} + +// Drag-and-drop: the default trait methods already do the right thing for a +// compositor that doesn't draw its own drag icon or offer server-side drag +// sources - smithay runs the pointer grab and the offer/accept negotiation +// internally. Both are implemented empty (rather than skipped) because +// `DataDeviceHandler` requires them as supertraits. +impl ClientDndGrabHandler for CompState {} +impl ServerDndGrabHandler for CompState {} + +impl PrimarySelectionHandler for CompState { + fn primary_selection_state(&self) -> &PrimarySelectionState { + &self.primary_selection_state + } +} + +/// `zwlr_data_control_manager_v1`: lets a client read/watch the selection +/// without ever holding keyboard focus. This is what `wl-paste --watch` +/// (and thus `cliphist store`, which the user's session autostarts) needs +/// - a focus-following clipboard manager is impossible without it. +impl DataControlHandler for CompState { + fn data_control_state(&self) -> &DataControlState { + &self.data_control_state + } +} -- cgit v1.2.3