[gtk/wip/carlosg/no-early-popup-ungrabs-4-2] gdk/wayland: Break only implicit grabs on wl_pointer.leave w/ pressed buttons




commit e7fdb434993eb1c9e03bf1b3eab42fce3c0cccd0
Author: Carlos Garnacho <carlosg gnome org>
Date:   Thu Jun 3 16:18:28 2021 +0200

    gdk/wayland: Break only implicit grabs on wl_pointer.leave w/ pressed buttons
    
    The releasing of grabs while a button is pressed (e.g. after starting dnd, or
    dragging the window, or going to overview with a pressed button, etc...) was
    generalized here in https://gitlab.gnome.org/GNOME/gtk/-/merge_requests/1879.
    
    However we shouldn't break all grabs here. In the case of grabbing popups,
    compositors will still emit crossing events between client surfaces (e.g.
    popping up and selecting a menu item via press-drag-release), breaking all
    grabs here means inconsistent client state, that was
    https://gitlab.gnome.org/GNOME/gtk/-/issues/2746.
    
    That was fixed in mutter, by essentially making implicit grabs
    owner_events=FALSE, however that breaks the mentioned use pattern entirely.
    Mutter is changing this behavior back, so GTK should handle these crossing
    events.
    
    The grab that we are interested in breaking here is the implicit pointer
    one. Popups will be dismissed via other means if the compositor says their
    active grab needs breaking. This still leaves dnd/move/resize drags in
    one place, while not allowing #2746 to happen with popups.

 gdk/wayland/gdkdevice-wayland.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
---
diff --git a/gdk/wayland/gdkdevice-wayland.c b/gdk/wayland/gdkdevice-wayland.c
index 5211cbbbda..3aac18487b 100644
--- a/gdk/wayland/gdkdevice-wayland.c
+++ b/gdk/wayland/gdkdevice-wayland.c
@@ -1518,6 +1518,7 @@ pointer_handle_leave (void              *data,
   GdkWaylandSeat *seat = data;
   GdkEvent *event;
   GdkWaylandDisplay *display_wayland = GDK_WAYLAND_DISPLAY (seat->display);
+  GdkDeviceGrabInfo *grab;
 
   if (!surface)
     return;
@@ -1529,8 +1530,11 @@ pointer_handle_leave (void              *data,
     return;
 
   _gdk_wayland_display_update_serial (display_wayland, serial);
+  grab = _gdk_display_get_last_device_grab (seat->display,
+                                            seat->logical_pointer);
 
-  if (seat->pointer_info.button_modifiers != 0)
+  if (seat->pointer_info.button_modifiers != 0 &&
+      grab && grab->implicit)
     {
       gulong display_serial;
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]