Make KGlobalaccel X11 track XInput events to still work when an application grabs the keyboard
Review Request #129967 - Created Feb. 24, 2017 and updated
This means shortcuts still work when keyboard is grabbed by another
application. This allows us to still take a screenshot/change volume
with a context menu open.
The existing code doesn't seem to actually handle dynamic keyboard
layout switching, this code matches that behaviour.
Interestingly alt+tab behavior is unchanged so it doesn't /severely/ break
legitimate keyboard grabs like virtualbox.
This introduces a security issue as it would be possible to trigger global shortcuts while the screen is locked. Given that I am reluctant to accept it. This will also mean lots of bug reports raised due to it. Also it can result in severe issues in code which currently can savely assume that no global shortcut gets trigger. Large parts of KWin rely on the knowledge that no global shortcut gets triggered. E.g. Present Windows and Alt+Tab are mutual exclusive due to the keyboard grab. This change would result in undefined behavior in such a situation. It is not known how the code would react as that is outside the specification. We don't know how many more applications rely on keyboard grabbing not triggering global shortcuts.
For what is worth: on Wayland it is possible to trigger global shortcuts while context menus are open. I think now it is better to spend the time on making Wayland a first class citizen than to try working around X11 limitations.
As an idea: if I understand correctly the main motivation is to be able to trigger the volume control keys while a context menu is open. You are not that much interested in e.g. triggering Alt+Tab while context menu is shown.
So a possibility might be to add this to the client side. Assuming the Qt case: if keyboard is grabbed, context menu is open and the key event is not handled and one of the special keys which the application does not care about, it could close the context menu and XTest the event again. Then kglobalaccel would be able to handle it.