gdk: do not deactivate surface on keyboard grabs
authorSamuel Thibault <samuel.thibault@ens-lyon.org>
Thu, 19 Apr 2018 12:10:23 +0000 (14:10 +0200)
committerSamuel Thibault <samuel.thibault@ens-lyon.org>
Mon, 30 Apr 2018 08:57:53 +0000 (10:57 +0200)
When pressing e.g. a window manager shortcut, which acquires keyboard grab,
Xorg would send FocusOut NotifyGrab then FocusIn NotifyUngrab.  Currently
gdk would then deactivate the current surface, which makes accessibility
screen readers think that we have switched to a non-accessible application
and came back again, and thus reannounce the application frame etc. which we
don't want when e.g. just raising volume.

And actually, receiving FocusOut NotifyGrab does not mean losing the
X focus, it only means an application aqcuired a grab, i.e. it is
temporarily stealing keyboard events. On Wayland, this isn't even
notified actually.

This commit makes gdk only deactivate surfaces when there was an actual
focus switch to another window, as determined by has_focus_window (instead
of just has_focus), which happens either normally through FocusOut with
NotifyNormal, or during grabs through FocusOut with NotifyWhileGrabbed.

Fixes #85

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

index 6ae5fc8a8e7e660a46a380c37cf3249c5a412c9d..f2ae118afb306503e537612acd508078eb48286a 100644 (file)
@@ -32,7 +32,7 @@
 
 
 #define HAS_FOCUS(toplevel)                           \
-  ((toplevel)->has_focus || (toplevel)->has_pointer_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);
index a4bbea0079b82223714860ad5d852d10a32dcce3..f5c68a57282d4617da0589241238ae603d901098 100644 (file)
@@ -37,7 +37,7 @@ static void     gdk_event_source_finalize (GSource     *source);
 static GQuark quark_needs_enter = 0;
 
 #define HAS_FOCUS(toplevel)                           \
-  ((toplevel)->has_focus || (toplevel)->has_pointer_focus)
+  ((toplevel)->has_focus_window || (toplevel)->has_pointer_focus)
 
 struct _GdkEventSource
 {