gail shouldn't emit window deactivate/activate on window manager shortcut presses
Hello,
How to reproduce:
- Run an X11 session
- In accerciser, in the Event Monitor, enable window:activate and window:deactivate, and enable Monitor Events
- Switch to a gtk application
- Press a shortcut handled by the window manager (e.g. raising the volume)
- In accerciser, window:deactivate and window:activate events show up
This makes screen readers think focus has moved to another application, then back to the original application, and thus makes them re-speak the context of the application, which is painful for just shortcuts.
What happens is that
- the window manager use X11's grab feature to implement shortcuts.
- On shortcut keypress, Gtk receives FocusOut NotifyGrab then FocusIn NotifyUngrab.
- In ./gdk/x11/gdkdevicemanager-core-x11.c's _gdk_device_manager_core_handle_focus these are properly handled (as well as the NotifyWhileGrabbed case), i.e. toplevel-has_focus is updated, but toplevel->has_focus_window is not.
- _gdk_device_manager_core_handle_focus however emits a GDK_FOCUS_CHANGE event when has_focus changes, not when has_focus_window changes.
- and ./gtk/a11y/gtkaccessibility.c's gail_focus_watcher watches GDK_FOCUS_CHANGE, and thus emits window:deactivate/activate.
I'd say we could introduce GDK_FOCUS_WINDOW_CHANGE, for gail to only track real focus changes, and not transient focus changes?
Samuel