From f28f31fc323b5893242753ef409b00b47de04ae8 Mon Sep 17 00:00:00 2001 From: Carlos Garnacho Date: Tue, 3 Dec 2024 18:03:50 +0100 Subject: [PATCH] wayland: Fix updating pointer cursor on Drag and Drop The logic to allow src/wayland to update the pointer cursor changed to bypassing grabs in commit e69e4fa6, since it is nowadays the responsibility of the DnD source to update the pointer cursor in reaction to the negotiated action. This is not entirely correct, and was done at the expense of regressions. Change the logic so we explicitly check for a DnD grab existing, or use the active focus instead (i.e. grab-aware). This fixes the regression, and keep DnD cursor icons working. This is a partial revert of commit e69e4fa6dbbd62677de61bcd2f5f3bec515e79ce. Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/3460 Fixes: e69e4fa6db ("Revert "wayland: Check focus surface to set a pointer cursor"") Part-of: --- src/wayland/meta-wayland-pointer.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/wayland/meta-wayland-pointer.c b/src/wayland/meta-wayland-pointer.c index e9b1d363f..9ba969522 100644 --- a/src/wayland/meta-wayland-pointer.c +++ b/src/wayland/meta-wayland-pointer.c @@ -57,6 +57,7 @@ #include "wayland/meta-cursor-sprite-wayland.h" #include "wayland/meta-wayland-buffer.h" #include "wayland/meta-wayland-cursor-surface.h" +#include "wayland/meta-wayland-data-device.h" #include "wayland/meta-wayland-pointer.h" #include "wayland/meta-wayland-popup.h" #include "wayland/meta-wayland-private.h" @@ -1137,8 +1138,17 @@ meta_wayland_pointer_update_cursor_surface (MetaWaylandPointer *pointer) { MetaBackend *backend = backend_from_pointer (pointer); MetaCursorTracker *cursor_tracker = meta_backend_get_cursor_tracker (backend); + MetaWaylandSeat *seat = meta_wayland_pointer_get_seat (pointer); + MetaWaylandDragGrab *drag_grab; + MetaWaylandSurface *surface; - if (pointer->current) + drag_grab = meta_wayland_data_device_get_current_grab (&seat->data_device); + if (drag_grab) + surface = meta_wayland_drag_grab_get_origin (drag_grab); + else + surface = pointer->focus_surface; + + if (surface) { MetaCursorSprite *cursor_sprite = NULL;