aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorKirill Chibisov <contact@kchibisov.com>2023-09-30 21:05:13 +0400
committerIvan Molodetskikh <yalterz@gmail.com>2023-10-02 16:28:08 +0300
commit9168f08038b1e3d7b643519191e9c70eac639ddc (patch)
tree92af8aae00ef687909ef33832126fcd299faa7f1 /src
parent2d3d0ce165ef9a958390255d78523cbc945ba125 (diff)
downloadniri-9168f08038b1e3d7b643519191e9c70eac639ddc.tar.gz
niri-9168f08038b1e3d7b643519191e9c70eac639ddc.tar.bz2
niri-9168f08038b1e3d7b643519191e9c70eac639ddc.zip
protocols: add wlr_data_control
Also update smithay to the latest git hash. Fixes #20.
Diffstat (limited to 'src')
-rw-r--r--src/handlers/mod.rs32
-rw-r--r--src/niri.rs35
2 files changed, 44 insertions, 23 deletions
diff --git a/src/handlers/mod.rs b/src/handlers/mod.rs
index 743fd93c..546d22e0 100644
--- a/src/handlers/mod.rs
+++ b/src/handlers/mod.rs
@@ -11,19 +11,22 @@ use smithay::reexports::wayland_server::protocol::wl_data_source::WlDataSource;
use smithay::reexports::wayland_server::protocol::wl_surface::WlSurface;
use smithay::reexports::wayland_server::Resource;
use smithay::utils::{Logical, Rectangle};
-use smithay::wayland::data_device::{
+use smithay::wayland::dmabuf::{DmabufGlobal, DmabufHandler, DmabufState, ImportError};
+use smithay::wayland::input_method::{InputMethodHandler, PopupSurface};
+use smithay::wayland::selection::data_device::{
set_data_device_focus, ClientDndGrabHandler, DataDeviceHandler, DataDeviceState,
ServerDndGrabHandler,
};
-use smithay::wayland::dmabuf::{DmabufGlobal, DmabufHandler, DmabufState, ImportError};
-use smithay::wayland::input_method::{InputMethodHandler, PopupSurface};
-use smithay::wayland::primary_selection::{
+use smithay::wayland::selection::primary_selection::{
set_primary_focus, PrimarySelectionHandler, PrimarySelectionState,
};
+use smithay::wayland::selection::wlr_data_control::{DataControlHandler, DataControlState};
+use smithay::wayland::selection::SelectionHandler;
use smithay::{
- delegate_data_device, delegate_dmabuf, delegate_input_method_manager, delegate_output,
- delegate_pointer_gestures, delegate_presentation, delegate_primary_selection, delegate_seat,
- delegate_tablet_manager, delegate_text_input_manager, delegate_virtual_keyboard_manager,
+ delegate_data_control, delegate_data_device, delegate_dmabuf, delegate_input_method_manager,
+ delegate_output, delegate_pointer_gestures, delegate_presentation, delegate_primary_selection,
+ delegate_seat, delegate_tablet_manager, delegate_text_input_manager,
+ delegate_virtual_keyboard_manager,
};
use crate::niri::State;
@@ -72,8 +75,11 @@ impl InputMethodHandler for State {
delegate_input_method_manager!(State);
delegate_virtual_keyboard_manager!(State);
-impl DataDeviceHandler for State {
+impl SelectionHandler for State {
type SelectionUserData = ();
+}
+
+impl DataDeviceHandler for State {
fn data_device_state(&self) -> &DataDeviceState {
&self.niri.data_device_state
}
@@ -103,14 +109,20 @@ 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);
+impl DataControlHandler for State {
+ fn data_control_state(&self) -> &DataControlState {
+ &self.niri.data_control_state
+ }
+}
+
+delegate_data_control!(State);
+
delegate_output!(State);
delegate_presentation!(State);
diff --git a/src/niri.rs b/src/niri.rs
index 527282a7..2c817f21 100644
--- a/src/niri.rs
+++ b/src/niri.rs
@@ -54,13 +54,14 @@ use smithay::wayland::compositor::{
with_states, with_surface_tree_downward, CompositorClientState, CompositorState, SurfaceData,
TraversalAction,
};
-use smithay::wayland::data_device::DataDeviceState;
use smithay::wayland::dmabuf::DmabufFeedback;
use smithay::wayland::input_method::InputMethodManagerState;
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::selection::data_device::DataDeviceState;
+use smithay::wayland::selection::primary_selection::PrimarySelectionState;
+use smithay::wayland::selection::wlr_data_control::DataControlState;
use smithay::wayland::shell::kde::decoration::KdeDecorationState;
use smithay::wayland::shell::wlr_layer::{Layer, WlrLayerShellState};
use smithay::wayland::shell::xdg::decoration::XdgDecorationState;
@@ -121,6 +122,7 @@ pub struct Niri {
pub pointer_gestures_state: PointerGesturesState,
pub data_device_state: DataDeviceState,
pub primary_selection_state: PrimarySelectionState,
+ pub data_control_state: DataControlState,
pub popups: PopupManager,
pub presentation_state: PresentationState,
@@ -319,6 +321,11 @@ impl Niri {
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 data_control_state = DataControlState::new::<State, _>(
+ &display_handle,
+ Some(&primary_selection_state),
+ |_| true,
+ );
let presentation_state =
PresentationState::new::<State>(&display_handle, CLOCK_MONOTONIC as u32);
@@ -689,12 +696,13 @@ impl Niri {
pointer_gestures_state,
data_device_state,
primary_selection_state,
+ data_control_state,
popups: PopupManager::default(),
presentation_state,
seat,
default_cursor,
- cursor_image: CursorImageStatus::Default,
+ cursor_image: CursorImageStatus::default_named(),
dnd_icon: None,
zbus_conn,
@@ -1019,7 +1027,7 @@ impl Niri {
.hotspot
})
} else {
- self.cursor_image = CursorImageStatus::Default;
+ self.cursor_image = CursorImageStatus::default_named();
default_hotspot
}
} else {
@@ -1029,7 +1037,16 @@ impl Niri {
let mut pointer_elements = match &self.cursor_image {
CursorImageStatus::Hidden => vec![],
- CursorImageStatus::Default => vec![OutputRenderElements::DefaultPointer(
+ CursorImageStatus::Surface(surface) => render_elements_from_surface_tree(
+ renderer,
+ surface,
+ pointer_pos,
+ output_scale,
+ 1.,
+ Kind::Cursor,
+ ),
+ // Default shape catch-all
+ _ => vec![OutputRenderElements::DefaultPointer(
TextureRenderElement::from_texture_buffer(
pointer_pos.to_f64(),
&default_buffer,
@@ -1039,14 +1056,6 @@ impl Niri {
Kind::Cursor,
),
)],
- CursorImageStatus::Surface(surface) => render_elements_from_surface_tree(
- renderer,
- surface,
- pointer_pos,
- output_scale,
- 1.,
- Kind::Cursor,
- ),
};
if let Some(dnd_icon) = &self.dnd_icon {