forge
Explore
Log in

Don't you dare go Hollow

Fix DnD icon offset from surface cursor

Browse files at this commit

86edeb3b0b3d1a08d4d4f59705cbc99a732f5e95Ivan MolodetskikhParent: d9648e6
The offset is already relative to the hotspot, no need to offset twice.
src/handlers/mod.rsmodified+5 -20
@@ -13,9 +13,7 @@ use smithay::backend::allocator::dmabuf::Dmabuf;
13 use smithay::backend::drm::DrmNode;13 use smithay::backend::drm::DrmNode;
14 use smithay::backend::input::{InputEvent, TabletToolDescriptor};14 use smithay::backend::input::{InputEvent, TabletToolDescriptor};
15 use smithay::desktop::{PopupKind, PopupManager};15 use smithay::desktop::{PopupKind, PopupManager};
16-use smithay::input::pointer::{16+use smithay::input::pointer::{CursorIcon, CursorImageStatus, PointerHandle};
17- CursorIcon, CursorImageStatus, CursorImageSurfaceData, PointerHandle,
18-};
19 use smithay::input::{keyboard, Seat, SeatHandler, SeatState};17 use smithay::input::{keyboard, Seat, SeatHandler, SeatState};
20 use smithay::output::Output;18 use smithay::output::Output;
21 use smithay::reexports::rustix::fs::{fcntl_setfl, OFlags};19 use smithay::reexports::rustix::fs::{fcntl_setfl, OFlags};
@@ -323,23 +321,10 @@ impl ClientDndGrabHandler for State {
323 icon: Option<WlSurface>,321 icon: Option<WlSurface>,
324 _seat: Seat<Self>,322 _seat: Seat<Self>,
325 ) {323 ) {
326- let offset = if let CursorImageStatus::Surface(ref surface) =324+ self.niri.dnd_icon = icon.map(|surface| DndIcon {
327- self.niri.cursor_manager.cursor_image()325+ surface,
328- {326+ offset: Point::new(0, 0),
329- with_states(surface, |states| {327+ });
330- let hotspot = states
331- .data_map
332- .get::<CursorImageSurfaceData>()
333- .unwrap()
334- .lock()
335- .unwrap()
336- .hotspot;
337- Point::from((-hotspot.x, -hotspot.y))
338- })
339- } else {
340- (0, 0).into()
341- };
342- self.niri.dnd_icon = icon.map(|surface| DndIcon { surface, offset });
343 // FIXME: more granular328 // FIXME: more granular
344 self.niri.queue_redraw_all();329 self.niri.queue_redraw_all();
345 }330 }