Skip to content

Commit

Permalink
Implement primary selecton
Browse files Browse the repository at this point in the history
Firefox clipboard doesn't always work without it.
  • Loading branch information
YaLTeR committed Sep 26, 2023
1 parent d373522 commit 93369e1
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
12 changes: 11 additions & 1 deletion src/handlers/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,10 @@ use smithay::wayland::data_device::{
ServerDndGrabHandler,
};
use smithay::wayland::dmabuf::{DmabufGlobal, DmabufHandler, DmabufState, ImportError};
use smithay::wayland::primary_selection::{PrimarySelectionHandler, PrimarySelectionState};
use smithay::{
delegate_data_device, delegate_dmabuf, delegate_output, delegate_pointer_gestures,
delegate_presentation, delegate_seat, delegate_tablet_manager,
delegate_presentation, delegate_primary_selection, delegate_seat, delegate_tablet_manager,
};

use crate::niri::State;
Expand Down Expand Up @@ -75,6 +76,15 @@ impl ServerDndGrabHandler for State {}

delegate_data_device!(State);

impl PrimarySelectionHandler for State {
type SelectionUserData = ();

fn primary_selection_state(&self) -> &PrimarySelectionState {
&self.niri.primary_selection_state
}
}
delegate_primary_selection!(State);

delegate_output!(State);

delegate_presentation!(State);
Expand Down
4 changes: 4 additions & 0 deletions src/niri.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ use smithay::wayland::dmabuf::DmabufFeedback;
use smithay::wayland::output::OutputManagerState;
use smithay::wayland::pointer_gestures::PointerGesturesState;
use smithay::wayland::presentation::PresentationState;
use smithay::wayland::primary_selection::PrimarySelectionState;
use smithay::wayland::shell::wlr_layer::{Layer, WlrLayerShellState};
use smithay::wayland::shell::xdg::decoration::XdgDecorationState;
use smithay::wayland::shell::xdg::XdgShellState;
Expand Down Expand Up @@ -103,6 +104,7 @@ pub struct Niri {
pub tablet_state: TabletManagerState,
pub pointer_gestures_state: PointerGesturesState,
pub data_device_state: DataDeviceState,
pub primary_selection_state: PrimarySelectionState,
pub popups: PopupManager,
pub presentation_state: PresentationState,

Expand Down Expand Up @@ -243,6 +245,7 @@ impl Niri {
let tablet_state = TabletManagerState::new::<State>(&display_handle);
let pointer_gestures_state = PointerGesturesState::new::<State>(&display_handle);
let data_device_state = DataDeviceState::new::<State>(&display_handle);
let primary_selection_state = PrimarySelectionState::new::<State>(&display_handle);
let presentation_state =
PresentationState::new::<State>(&display_handle, CLOCK_MONOTONIC as u32);

Expand Down Expand Up @@ -593,6 +596,7 @@ impl Niri {
tablet_state,
pointer_gestures_state,
data_device_state,
primary_selection_state,
popups: PopupManager::default(),
presentation_state,

Expand Down

0 comments on commit 93369e1

Please sign in to comment.