gtkmain: Wait for GDK_CROSSING_UNGRAB leave event with implicit grabs
authorCarlos Garnacho <carlosg@gnome.org>
Fri, 7 Feb 2020 00:02:47 +0000 (01:02 +0100)
committerCarlos Garnacho <carlosg@gnome.org>
Fri, 7 Feb 2020 00:02:47 +0000 (01:02 +0100)
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

index 887ce9bd1404cdf06f82b7561e83243206f94546..d8c1d35bebb9069450ff2d2883f5f79594e97efa 100644 (file)
@@ -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: