Xpra: Ticket #1195: keyboard grabs - conflicting shortcuts and modifier grabbing

I'm experiencing two problems with client shortcuts:

Current Alt+Shift+something shortcuts are in conflict with common keyboard layout switching shortcut Alt+Shift. Perhaps, some unused prefix could be found.

There is no way to enable grabbing and passing through of modifier keys, like Super. This is especially needed in shadow and full-desktop (like with Xephyr) sessions. To pass Super+something to the server host.

The answer to both problems could be Host Key concept. It is used by such software as VirtualBox? or Remmina: Define a Host key (R_Control by default) which would have special meaning for Xpra client. Host+something would do some stuff. Single Host key tap would switch unconditional grabbing of keyboard, including modifier keys, as long as any xpra window has focus. Single (of doubles) key, like R_Control would not interfere with any of common shortcuts like Alt+Shift, and leave L_Control to act as Control itself.



Sun, 22 May 2016 10:00:43 GMT - Antoine Martin: owner changed

All the shortcuts are configurable, if your DE intercepts them then you can change your DE shortcuts or change xpra's.

As for passing the super key to the server, that seemed easy enough to implement (but in the end.. it wasn't), so that's done in r12645.

This is done by adding a new key shortcut "Control_R" which toggles grabbing the keyboard. Whilst the keyboard is grabbed, all keys will be sent to the server, including the super key. We release the grab when we lose focus. That part was hard to implement on X11 with GTK because it seems to swallow focus events when we hold the grab..

We already had similar functionality on win32 (which was disabled by default until now), see #1152.

Please close if this works for you.


Sun, 22 May 2016 10:21:38 GMT - psycho_zs:

Big thanks! I'll test it in a few days. When Control_R is bound to toggle_keyboard_grab, can it still be bound to other actions as a part of combination?


Mon, 23 May 2016 02:05:58 GMT - Antoine Martin:

When Control_R is bound to toggle_keyboard_grab, can it still be bound to other actions as a part of combination?


Theoretically yes, but each shortcut will then also toggle the keyboard grab. Probably not a good idea.


Mon, 23 May 2016 07:59:26 GMT - psycho_zs:

Key grab seems to work, at least with simple rootless xpra session. I will have more testing cases tomorrow, including shadow sessions.

btw, I've replaced all 'Meta+Shift' with 'Shift_R' and none of xpra shortcuts seem to work this way.

Theoretically yes, but each shortcut will then also toggle the keyboard grab. Probably not a good idea.

If action would be triggered on exact match keys release, it would be possible to partially replicate host key behavior. For full host key feature it would also be needed to add option 'host-key' to the config file and allow 'key-shortcut' option to parse 'Host_key' value as a key set by 'host-key' option.


Mon, 23 May 2016 09:21:17 GMT - Antoine Martin: status changed; resolution set

btw, I've replaced all 'Meta+Shift' with 'Shift_R' and none of xpra shortcuts seem to work this way.


Modifier keys have no concept of right or left once they are pressed in X11. Theoretically, it might be possible to keep track of which key triggered which modifier to be enabled (ie: Shift_R for shift), but I am not crazy enough to attempt writing such horrible code.


I also don't have time to implement the host-key feature, feel free to create a new ticket for that. I'm closing as fixed because all keys can now be forwarded and trying to find shortcuts that don't conflict with any DE is futile.


Mon, 01 Aug 2016 04:28:02 GMT - Antoine Martin: summary changed


Mon, 01 Aug 2016 04:32:55 GMT - Antoine Martin:

Mouse grabs in #1229 done the same way.


Mon, 01 Aug 2016 04:37:24 GMT - Antoine Martin: milestone set


Tue, 02 Aug 2016 06:17:16 GMT - Antoine Martin:

Important: the shortcuts have just been changed, see r13169

Some GTK API links:


Tue, 02 Aug 2016 07:24:58 GMT - psycho_zs:

So, ctrl+menu grabs keyboard, shift+menu grabs mouse? Sounds good.


Mon, 31 Oct 2016 10:21:42 GMT - Antoine Martin:

r14359 also intercepts Alt-Tab on win32 (only when we have the keyboard grab obviously).


Sun, 11 Feb 2018 06:21:39 GMT - Antoine Martin:

See also:


Sat, 23 Jan 2021 05:17:35 GMT - migration script:

this ticket has been moved to: https://github.com/Xpra-org/xpra/issues/1195