Skip to content

wayland: check native window for crossing events

Olivier Fourdan requested to merge ofourdan/gtk:bz780422 into gtk-3-22

gdk_wayland_*_grab()/ungrab() would emit crossing events which translate as focus_in/focus_out events for keyboard.

However, the ungrab() functions compare the native toplevel as this is what gets the Wayland pointer enter/leave events with the grab window, so if the grab is issued on a child gdk window, those won't match and we would emit more focus_out events than focus_in events.

This means that a widget such as spice-gtk which issues a keyboard grab whenever the pointer enters the window and releases the grab when it leaves the window would get uneven numbers of focus_in/focus_out events.

Also, gdk_wayland_seat_ungrab() would not emit crossing events for keyboard devices, whereas gdk_wayland_device_ungrab() does, which adds even more potential discrepancies between focus_in/focus_out events.

To solve this problem, introduce two new helper functions which check the relevant native windows to emit crossing events when needed that get called evenly from both gdk_wayland_seat_grab()/ungrab() and gdk_Wayland _device_grab()/ungrab() APIs.

Fixes: https://bugzilla.gnome.org/show_bug.cgi?id=780422 Fixes: #792 (closed)

Merge request reports