[RFC] Modifier only shortcuts on X11

Martin Graesslin mgraesslin at kde.org
Fri Aug 12 14:11:50 UTC 2016


Hi Plasma devs,

I just created an RFC-phab request: https://phabricator.kde.org/D2425

This implements modifier-only global shortcuts on X11 reusing KWin's internal 
architecture written for Wayland.

What I want to know is whether it's worth something to follow up. We know that 
this is a feature wanted by many, so I want to explain why we don't have it 
yet and what this change does differently.

The main problem with modifier as shortcut is that it doesn't work with 
kglobalaccel. KGlobalAccel does a passive grab on the shortcuts. That is it 
will be notified when e.g. Alt+Tab is pressed. Other clients are then not 
informed about Alt+Tab being pressed. If we would do that for modifiers we 
would steal them and break everything.

Thus the normal architecture in kglobalaccel just cannot support modifier only 
shortcuts. What we would need is to listen to all key events once a modifier is 
pressed to detect when it's released. Which doesn't work as soon as another 
client grabs the keyboard (e.g. alt to open in-app menu) and again 
kglobalaccel cannot grab them.

Overall there are just many situations where it might happen that we don't 
detect properly that the modifier got pressed/released. That's also why I 
always was against us supporting ksuperkey by default.

What does my suggested change differently?

The suggested change uses XInput2.2 to listen to all Raw key events. That is 
KWin gets all raw keys reported, even when another client grabs the keyboard. 
This is just like on Wayland with libinput: kwin gets all key events.

On Wayland KWin sends all key events through Xkb to get the transformation 
into key codes and modifiers. Based on that KWin can detect when a modifier is 
pressed/released without anything else interfering.

And that is what the change does: all raw key events are sent through Xkb, so 
all the existing infrastructure gets reused.

This turns KWin into a key logger, makes it wake up on every key event. The 
change will need some more work and I want to know from you whether it's worth 
the effort and whether that's something we want to ship by default in 5.8.

I think this implementation will allow us to get the modifier-only shortcut 
work as expected.

Why in KWin and not in KGlobalAccel?
The X11 implementation could also be done in KGlobalAccel. On Wayland it needs 
to be in KWin and it's in a place inside KWin before the key event gets 
filtered through kglobalaccel. We would need to duplicate the logic.

Credits!
Credits go to Kai for complaining about screenedges on X11 stealing mouse 
clicks while I was fixing a bug in the XInput2 polling code which made me 
realize that we can raw events for way more than just mouse position tracking.

So what do you think?
Cheers
Martin
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 181 bytes
Desc: This is a digitally signed message part.
URL: <http://mail.kde.org/pipermail/plasma-devel/attachments/20160812/1c5d16f5/attachment.sig>


More information about the Plasma-devel mailing list