Details
-
Suggestion
-
Resolution: Unresolved
-
P3: Somewhat important
-
None
-
6.6.2
-
None
-
Fedora 40
Description
Quoting keyboard-shortcuts-inhibit-unstable-v1 protocol [1]:
This protocol specifies a way for a client to request the compositor to ignore its own keyboard shortcuts for a given seat, so that all key events from that seat get forwarded to a surface.
I think this can be used to implement QWaylandWindow::setKeyboardGrabEnabled(). Compositor wise, this is supported by Mutter (GNOME Shell), KWin (KDE), Sway, and Hyprland [2].
Reading the protocol wording, there's a caveat that the protocol allows the compositor to pull back the grab as it sees fit, and Qt doesn't seem to have a way to notify this fact to application code. Also, setKeyboardGrabEnabled() is synchronous, but Wayland communication is inherently asynchronous. So unless we want to block the application for the reply, I guess it's possible that setKeyboardGrabEnabled() return true but grabbing doesn't actually happen.
Still, I think this is strictly better than the current status, where keyboard grabbing is not implemented at all.
[1]: https://gitlab.freedesktop.org/wayland/wayland-protocols/-/tree/main/unstable/keyboard-shortcuts-inhibit
[2]: https://wayland.app/protocols/keyboard-shortcuts-inhibit-unstable-v1