gdk: activate surface on keyboard grabs
authorSamuel Thibault <samuel.thibault@ens-lyon.org>
Fri, 1 Jun 2018 14:43:01 +0000 (16:43 +0200)
committerSamuel Thibault <samuel.thibault@ens-lyon.org>
Mon, 18 Jun 2018 08:31:15 +0000 (10:31 +0200)
In 01455399e83a ("gdk: do not deactivate surface on keyboard grabs"), we
made gdk avoid deactivating surfaces when another application takes a
keyboard grab, by using has_focus_window instead of has_focus. That however
broke activating surfaces when the gdk application acquired a grab itself,
in which case has_focus_window is false but has_focus is true.

We thus actually need to use both: surfaces should be activated either
because we have normal keyboard focus, or because we grabbed the keyboard.

This also renames HAS_FOCUS to APPEARS_FOCUSED to better reflect its
role.

Fixes #85

gdk/x11/gdkdevicemanager-core-x11.c
gdk/x11/gdkeventsource.c

index f2ae118afb306503e537612acd508078eb48286a..f64b5551e50186d475ad1d9782f82b1dcaf94476 100644 (file)
@@ -31,8 +31,8 @@
 
 
 
-#define HAS_FOCUS(toplevel)                           \
-  ((toplevel)->has_focus_window || (toplevel)->has_pointer_focus)
+#define APPEARS_FOCUSED(toplevel)                           \
+  ((toplevel)->has_focus || (toplevel)->has_focus_window || (toplevel)->has_pointer_focus)
 
 static void    gdk_x11_device_manager_core_finalize    (GObject *object);
 static void    gdk_x11_device_manager_core_constructed (GObject *object);
@@ -822,7 +822,7 @@ _gdk_device_manager_core_handle_focus (GdkSurface *surface,
   if (toplevel->focus_window == original)
     return;
 
-  had_focus = HAS_FOCUS (toplevel);
+  had_focus = APPEARS_FOCUSED (toplevel);
   x11_screen = GDK_X11_SCREEN (GDK_SURFACE_SCREEN (surface));
 
   switch (detail)
@@ -884,7 +884,7 @@ _gdk_device_manager_core_handle_focus (GdkSurface *surface,
       break;
     }
 
-  if (HAS_FOCUS (toplevel) != had_focus)
+  if (APPEARS_FOCUSED (toplevel) != had_focus)
     {
       GdkEvent *event;
 
index f5c68a57282d4617da0589241238ae603d901098..88460c8b352f0a2e181397d5715dc20a48428b48 100644 (file)
@@ -36,8 +36,8 @@ static void     gdk_event_source_finalize (GSource     *source);
 
 static GQuark quark_needs_enter = 0;
 
-#define HAS_FOCUS(toplevel)                           \
-  ((toplevel)->has_focus_window || (toplevel)->has_pointer_focus)
+#define APPEARS_FOCUSED(toplevel)                           \
+  ((toplevel)->has_focus || (toplevel)->has_focus_window || (toplevel)->has_pointer_focus)
 
 struct _GdkEventSource
 {
@@ -111,10 +111,10 @@ handle_focus_change (GdkEventCrossing *event)
   if (!event->focus || toplevel->has_focus_window)
     return;
 
-  had_focus = HAS_FOCUS (toplevel);
+  had_focus = APPEARS_FOCUSED (toplevel);
   toplevel->has_pointer_focus = focus_in;
 
-  if (HAS_FOCUS (toplevel) != had_focus)
+  if (APPEARS_FOCUSED (toplevel) != had_focus)
     {
       GdkEvent *focus_event;