diff --git a/src/config/mod.rs b/src/config/mod.rs index 89c46c21..bffbc380 100644 --- a/src/config/mod.rs +++ b/src/config/mod.rs @@ -51,6 +51,7 @@ pub struct Config { pub struct StaticConfig { pub key_bindings: HashMap, pub tiling_enabled: bool, + pub data_control_enabled: bool, } #[derive(Debug)] @@ -191,6 +192,7 @@ impl Config { StaticConfig { key_bindings: HashMap::new(), tiling_enabled: false, + data_control_enabled: false, } } diff --git a/src/state.rs b/src/state.rs index 9bd3db61..a0840004 100644 --- a/src/state.rs +++ b/src/state.rs @@ -71,7 +71,10 @@ use smithay::{ presentation::PresentationState, seat::WaylandFocus, security_context::{SecurityContext, SecurityContextState}, - selection::{data_device::DataDeviceState, primary_selection::PrimarySelectionState}, + selection::{ + data_device::DataDeviceState, primary_selection::PrimarySelectionState, + wlr_data_control::DataControlState, + }, session_lock::{LockSurface, SessionLockManagerState}, shell::{kde::decoration::KdeDecorationState, xdg::decoration::XdgDecorationState}, shm::ShmState, @@ -160,6 +163,7 @@ pub struct Common { pub output_configuration_state: OutputConfigurationState, pub presentation_state: PresentationState, pub primary_selection_state: PrimarySelectionState, + pub data_control_state: Option, pub screencopy_state: ScreencopyState, pub seat_state: SeatState, pub session_lock_manager_state: SessionLockManagerState, @@ -358,6 +362,10 @@ impl State { TextInputManagerState::new::(&dh); VirtualKeyboardManagerState::new::(&dh, client_should_see_privileged_protocols); + let data_control_state = config.static_conf.data_control_enabled.then(|| { + DataControlState::new::(dh, Some(&primary_selection_state), |_| true) + }); + let shell = Shell::new(&config, dh); State { @@ -400,6 +408,7 @@ impl State { output_configuration_state, presentation_state, primary_selection_state, + data_control_state, viewporter_state, wl_drm_state, kde_decoration_state, diff --git a/src/wayland/handlers/data_control.rs b/src/wayland/handlers/data_control.rs new file mode 100644 index 00000000..546b039a --- /dev/null +++ b/src/wayland/handlers/data_control.rs @@ -0,0 +1,15 @@ +// SPDX-License-Identifier: GPL-3.0-only + +use crate::state::State; +use smithay::{ + delegate_data_control, + wayland::selection::wlr_data_control::{DataControlHandler, DataControlState}, +}; + +impl DataControlHandler for State { + fn data_control_state(&self) -> &DataControlState { + self.common.data_control_state.as_ref().unwrap() + } +} + +delegate_data_control!(State); diff --git a/src/wayland/handlers/mod.rs b/src/wayland/handlers/mod.rs index 92159c75..dbfb5cb0 100644 --- a/src/wayland/handlers/mod.rs +++ b/src/wayland/handlers/mod.rs @@ -2,6 +2,7 @@ pub mod buffer; pub mod compositor; +pub mod data_control; pub mod data_device; pub mod decoration; pub mod dmabuf;