Focus events are not always matched
Submitted by Jonathon Jongsma
In virt-viewer, we are getting a warning in the terminal when running under wayland.
Some very short background: virt-viewer does certain things (e.g. grab the keyboard, enable usb auto-redirect, etc) when the spice widget gets focus, and "undoes" those things when the widget loses focus.
The reason that we are getting a warning is because we are not getting matched focus-in and focus-out events. When running under wayland in Fedora 25, if we click inside the virt-viewer window, a focus-in event is generated. However, when clicking outside of the window, two focus-out events are generated. The handler for the first event runs without problem, but the second one generates a warning since it is attempting to perform a task that has already been performed by the first handler.
I bisected gtk+ to determine when the problem appeared, and came up with the following commit:
wayland: Ensure device grabs generate crossing/focus events On X11 this is something the windowing system does for us, which the wayland backend should emulate, being grabs completely client-side. So, if the grab and current focus windows differ, make sure we emit focus/crossing events as it corresponds to the grab device.
I've not yet been able to create a minimal test case to trigger this bug in gtk+.
This bug was initially opened in the spice bug tracker, but after discussing it with some Gtk+ developers, they suggested opening a bug in Gtk+. Original bug is here: https://bugs.freedesktop.org/show_bug.cgi?id=99296