[gtk/wip/carlosg/broken-grabs: 166/170] gdk/wayland: Keep track of implicit grabs



commit 2bd8124b5d9d5f824744a7e00611a6231acbfd1c
Author: Carlos Garnacho <carlosg gnome org>
Date:   Tue May 12 10:19:47 2020 +0200

    gdk/wayland: Keep track of implicit grabs
    
    Tracking of those broke sometime along the gdk cleanups, so we
    started missing some GDK_GRAB_BROKEN events from being emitted
    (eg. after a button press/implicit grab triggers an active grab).
    
    Implicit grabs are only added if there's no prior grab (either
    implicit through other button presses, or explicit), in order to
    keep accounting correct, make those prevail.

 gdk/gdksurface.c | 26 +++++++++++++++++++++++---
 1 file changed, 23 insertions(+), 3 deletions(-)
---
diff --git a/gdk/gdksurface.c b/gdk/gdksurface.c
index c4a058e75d..b6ee8f577a 100644
--- a/gdk/gdksurface.c
+++ b/gdk/gdksurface.c
@@ -2293,9 +2293,29 @@ _gdk_windowing_got_event (GdkDisplay *display,
   else if (type == GDK_LEAVE_NOTIFY)
     _gdk_display_set_surface_under_pointer (display, device, NULL);
 
-  if (type == GDK_BUTTON_RELEASE ||
-      type == GDK_TOUCH_CANCEL ||
-      type == GDK_TOUCH_END)
+  if (type == GDK_BUTTON_PRESS)
+    {
+      GdkSurface *grab_surface;
+      gboolean owner_events;
+
+      if (!gdk_device_grab_info (display, device, &grab_surface, &owner_events))
+        {
+          _gdk_display_add_device_grab (display,
+                                        device,
+                                        event_surface,
+                                        GDK_OWNERSHIP_NONE,
+                                        FALSE,
+                                        GDK_ALL_EVENTS_MASK,
+                                        serial,
+                                        gdk_event_get_time (event),
+                                        TRUE);
+          _gdk_display_device_grab_update (display, device,
+                                           source_device, serial);
+        }
+    }
+  else if (type == GDK_BUTTON_RELEASE ||
+           type == GDK_TOUCH_CANCEL ||
+           type == GDK_TOUCH_END)
     {
       if (type == GDK_BUTTON_RELEASE ||
           gdk_event_get_pointer_emulated (event))


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