aboutsummaryrefslogtreecommitdiff
path: root/src/handlers/mod.rs
diff options
context:
space:
mode:
authorChristian Meissl <meissl.christian@gmail.com>2024-02-24 18:17:51 +0100
committerIvan Molodetskikh <yalterz@gmail.com>2024-09-30 05:04:58 -0700
commiteb190e3f9447e4d49cfdcb5a0093443ca8b684fe (patch)
tree7845bc23b9ed43bb75464d2dff5442d2d02285c5 /src/handlers/mod.rs
parent80bb0d5876f8fae43791a8d6e52a38d3c1e01a72 (diff)
downloadniri-eb190e3f9447e4d49cfdcb5a0093443ca8b684fe.tar.gz
niri-eb190e3f9447e4d49cfdcb5a0093443ca8b684fe.tar.bz2
niri-eb190e3f9447e4d49cfdcb5a0093443ca8b684fe.zip
handle role specific buffer offset
Diffstat (limited to 'src/handlers/mod.rs')
-rw-r--r--src/handlers/mod.rs26
1 files changed, 22 insertions, 4 deletions
diff --git a/src/handlers/mod.rs b/src/handlers/mod.rs
index 3e0bb18f..63bde132 100644
--- a/src/handlers/mod.rs
+++ b/src/handlers/mod.rs
@@ -12,7 +12,9 @@ use smithay::backend::allocator::dmabuf::Dmabuf;
use smithay::backend::drm::DrmNode;
use smithay::backend::input::TabletToolDescriptor;
use smithay::desktop::{PopupKind, PopupManager};
-use smithay::input::pointer::{CursorIcon, CursorImageStatus, PointerHandle};
+use smithay::input::pointer::{
+ CursorIcon, CursorImageStatus, CursorImageSurfaceData, PointerHandle,
+};
use smithay::input::{keyboard, Seat, SeatHandler, SeatState};
use smithay::output::Output;
use smithay::reexports::rustix::fs::{fcntl_setfl, OFlags};
@@ -22,7 +24,7 @@ use smithay::reexports::wayland_server::protocol::wl_data_source::WlDataSource;
use smithay::reexports::wayland_server::protocol::wl_output::WlOutput;
use smithay::reexports::wayland_server::protocol::wl_surface::WlSurface;
use smithay::reexports::wayland_server::Resource;
-use smithay::utils::{Logical, Rectangle, Size};
+use smithay::utils::{Logical, Point, Rectangle, Size};
use smithay::wayland::compositor::with_states;
use smithay::wayland::dmabuf::{DmabufGlobal, DmabufHandler, DmabufState, ImportNotifier};
use smithay::wayland::drm_lease::{
@@ -64,7 +66,7 @@ use smithay::{
};
pub use crate::handlers::xdg_shell::KdeDecorationsModeState;
-use crate::niri::{ClientState, State};
+use crate::niri::{ClientState, DndIcon, State};
use crate::protocols::foreign_toplevel::{
self, ForeignToplevelHandler, ForeignToplevelManagerState,
};
@@ -225,7 +227,23 @@ impl ClientDndGrabHandler for State {
icon: Option<WlSurface>,
_seat: Seat<Self>,
) {
- self.niri.dnd_icon = icon;
+ let offset = if let CursorImageStatus::Surface(ref surface) =
+ self.niri.cursor_manager.cursor_image()
+ {
+ with_states(surface, |states| {
+ let hotspot = states
+ .data_map
+ .get::<CursorImageSurfaceData>()
+ .unwrap()
+ .lock()
+ .unwrap()
+ .hotspot;
+ Point::from((-hotspot.x, -hotspot.y))
+ })
+ } else {
+ (0, 0).into()
+ };
+ self.niri.dnd_icon = icon.map(|surface| DndIcon { surface, offset });
// FIXME: more granular
self.niri.queue_redraw_all();
}