diff --git a/Cargo.lock b/Cargo.lock index 852f83153..756552b65 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -654,6 +654,12 @@ dependencies = [ "typenum", ] +[[package]] +name = "cursor-icon" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "740bb192a8e2d1350119916954f4409ee7f62f149b536911eeb78ba5a20526bf" + [[package]] name = "deranged" version = "0.3.8" @@ -714,7 +720,7 @@ version = "0.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "330c60081dcc4c72131f8eb70510f1ac07223e5d4163db481a04a0befcffa412" dependencies = [ - "libloading 0.8.0", + "libloading 0.7.4", ] [[package]] @@ -2273,13 +2279,14 @@ checksum = "942b4a808e05215192e39f4ab80813e599068285906cc91aa64f923db842bd5a" [[package]] name = "smithay" version = "0.3.0" -source = "git+https://github.com/Smithay/smithay.git#74ef59a3f8b6a1f86a74388590f2f852040354e4" +source = "git+https://github.com/Smithay/smithay.git#528e23f9bb3d3e1b16189070519ea85f480c3b0e" dependencies = [ "appendlist", "bitflags 2.4.0", "calloop 0.12.2", "cc", "cgmath", + "cursor-icon", "downcast-rs", "drm", "drm-ffi", @@ -2336,7 +2343,7 @@ dependencies = [ [[package]] name = "smithay-drm-extras" version = "0.1.0" -source = "git+https://github.com/Smithay/smithay.git#74ef59a3f8b6a1f86a74388590f2f852040354e4" +source = "git+https://github.com/Smithay/smithay.git#528e23f9bb3d3e1b16189070519ea85f480c3b0e" dependencies = [ "drm", "edid-rs", diff --git a/src/handlers/mod.rs b/src/handlers/mod.rs index 743fd93c6..546d22e0d 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 527282a7b..2c817f21e 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::(&display_handle); let data_device_state = DataDeviceState::new::(&display_handle); let primary_selection_state = PrimarySelectionState::new::(&display_handle); + let data_control_state = DataControlState::new::( + &display_handle, + Some(&primary_selection_state), + |_| true, + ); let presentation_state = PresentationState::new::(&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 {