Skip to content

Commit

Permalink
Enable wlr_data_control protocol (#101)
Browse files Browse the repository at this point in the history
  • Loading branch information
xDarksome authored Nov 13, 2023
1 parent d051d14 commit 72ee1c4
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 1 deletion.
2 changes: 2 additions & 0 deletions src/config/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ pub struct Config {
pub struct StaticConfig {
pub key_bindings: HashMap<key_bindings::KeyPattern, key_bindings::Action>,
pub tiling_enabled: bool,
pub data_control_enabled: bool,
}

#[derive(Debug)]
Expand Down Expand Up @@ -191,6 +192,7 @@ impl Config {
StaticConfig {
key_bindings: HashMap::new(),
tiling_enabled: false,
data_control_enabled: false,
}
}

Expand Down
11 changes: 10 additions & 1 deletion src/state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -160,6 +163,7 @@ pub struct Common {
pub output_configuration_state: OutputConfigurationState<State>,
pub presentation_state: PresentationState,
pub primary_selection_state: PrimarySelectionState,
pub data_control_state: Option<DataControlState>,
pub screencopy_state: ScreencopyState,
pub seat_state: SeatState<State>,
pub session_lock_manager_state: SessionLockManagerState,
Expand Down Expand Up @@ -358,6 +362,10 @@ impl State {
TextInputManagerState::new::<Self>(&dh);
VirtualKeyboardManagerState::new::<State, _>(&dh, client_should_see_privileged_protocols);

let data_control_state = config.static_conf.data_control_enabled.then(|| {
DataControlState::new::<Self, _>(dh, Some(&primary_selection_state), |_| true)
});

let shell = Shell::new(&config, dh);

State {
Expand Down Expand Up @@ -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,
Expand Down
15 changes: 15 additions & 0 deletions src/wayland/handlers/data_control.rs
Original file line number Diff line number Diff line change
@@ -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);
1 change: 1 addition & 0 deletions src/wayland/handlers/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

pub mod buffer;
pub mod compositor;
pub mod data_control;
pub mod data_device;
pub mod decoration;
pub mod dmabuf;
Expand Down

0 comments on commit 72ee1c4

Please sign in to comment.