xwayland: Translate keyboard grabs on the root window
When an X11 client issues an active grab on the keyboard, Xwayland forward this to the Wayland compositor using the Xwayland specific protocol "xwayland-keyboard-grab" if it can find the corresponding Xwayland window.
Some X11 clients (typically older games) however try to issue the keyboard grab on the X11 root window, which has obviously no matching Xwayland window. In such a case, the grab is simply ignored and the game will not work as expected.
To workaround that issue, if an X11 client issues a keyboard grab on the root window, Xwayland will search for a toplevel window belonging to the same X11 client that it can use as the grab window instead.
This way, the grab can be forwarded to the Wayland compositor that can either grant or deny the request based on the window and its internal policies.
Signed-off-by: Olivier Fourdan ofourdan@redhat.com See-also: https://gitlab.gnome.org/GNOME/mutter/-/issues/1249