[gtk/wip/carlosg/implicit-grabs-on-leave: 2/2] gtkmain: Wait for GDK_CROSSING_UNGRAB leave event with implicit grabs



commit e67f0bfcfda56950c82a5f384e2d4c640ab7a7f4
Author: Carlos Garnacho <carlosg gnome org>
Date:   Fri Feb 7 01:02:47 2020 +0100

    gtkmain: Wait for GDK_CROSSING_UNGRAB leave event with implicit grabs
    
    If there is a passive grab and the pointer leaves the window we would
    receive a GDK_CROSSING_NORMAL event when the pointer moves outside
    the window, and a GDK_CROSSING_UNGRAB event when we do release the
    button and the implicit grab.
    
    We currently would react to the first, but want to react to the
    second. In the time between both events, the client would still receive
    pointer motion that will reach the implicitly grabbed widget.
    
    Closes: https://gitlab.gnome.org/GNOME/gtk/issues/13

 gtk/gtkmain.c | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)
---
diff --git a/gtk/gtkmain.c b/gtk/gtkmain.c
index 887ce9bd14..d8c1d35beb 100644
--- a/gtk/gtkmain.c
+++ b/gtk/gtkmain.c
@@ -1742,9 +1742,14 @@ handle_pointing_event (GdkEvent *event)
   switch ((guint) event->any.type)
     {
     case GDK_LEAVE_NOTIFY:
-      if (event->crossing.mode == GDK_CROSSING_GRAB ||
-          event->crossing.mode == GDK_CROSSING_UNGRAB)
-        break;
+      if (event->crossing.mode == GDK_CROSSING_NORMAL &&
+          gtk_window_lookup_pointer_focus_implicit_grab (toplevel, device, NULL))
+        {
+          /* We have an implicit grab, wait for the corresponding
+           * GDK_CROSSING_UNGRAB.
+           */
+          break;
+        }
       G_GNUC_FALLTHROUGH;
     case GDK_TOUCH_END:
     case GDK_TOUCH_CANCEL:


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