Skip to contentSkip to conversation

input-linux: customizable grab toggle keys v4

PATCH In review Ryan El Kochta 2 participants 2 messages Jan 20, 2019 – Jan 22, 2019

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 input-linux: customizable grab toggle keys v4

This patch adds a new option to the input-linux object:

grab-toggle=[key-combo]

The key combination can be one of the following:

* ctrl-ctrl
* alt-alt
* meta-meta
* ctrl-alt
* scrolllock
* ctrl-scrolllock
* ctrl-backtick

The user can pick any of these key combinations. The VM's grab of the evdev device will be toggled when the key combination is pressed.

Any invalid setting will result in an error. No setting will result in the current default of ctrl-ctrl.

If scrolllock is selected as one of the grab-toggle keys, it will be entirely disabled and not passed to the guest at all. This is to prevent enabling it while attempting to leave or enter the VM. On the host, scrolllock can be disabled using xmodmap.

First, find the modifier that Scroll_Lock is bound to:

$ xmodmap -pm

Then, remove Scroll_Lock from it, replacing modX with the modifier:

$ xmodmap -e 'remove modX = Scroll_Lock'

If Scroll_Lock is not bound to any modifier, it is already disabled.

To save the changes, add them to your xinitrc.

Side note - I have changed e-mail addresses from [email protected] due to issues with git send-mail. I am the same person.

---
 qapi/ui.json     | 10 +++++++
 ui/input-linux.c | 71 ++++++++++++++++++++++++++++++++++++++++++++++--
 2 files changed, 78 insertions(+), 3 deletions(-)
qapi/ui.json +10 -0
index 5ad1324..487653a 100644
@@ -1016,6 +1016,16 @@
             '*head'  : 'int',
             'events' : [ 'InputEvent' ] } }
 
+##
+# @GrabToggleKeys:
+#
+# Keys to toggle input-linux between host and guest.
+#
+# Since: 4.0
+#
+##
+{ 'enum': 'GrabToggleKeys',
+  'data': [ 'ctrl-ctrl', 'alt-alt', 'meta-meta', 'ctrl-alt', 'scrolllock', 'ctrl-scrolllock', 'ctrl-backtick' ] }
 
 ##
 # @DisplayGTK:
ui/input-linux.c +68 -3

106 lines not on this page · raw message

Signature · 1 line
2.20.1
#1 lore raw
Quoted 7 lines · Ryan El Kochta

This patch adds a new option to the input-linux object:

grab-toggle=[key-combo]

The key combination can be one of the following:

* ctrl-ctrl

left ctrl + right ctrl.

Quoted 1 line

* alt-alt

Same.

Quoted 1 line

* meta-meta

Same.

Quoted 1 line

* ctrl-alt

This is actually left ctrl + left alt (not any ctrl / alt) in the code.

Ctrl+Alt+Key isn't that uncommon as hotkey, linux console switching uses Ctrl+Alt+Fn for example. Also some GUI apps use Ctrl+Alt+Someletter for less frequently used functions when they run out of Ctrl+Someletter hotkeys. I'd suggest to drop this one.

Quoted 2 lines

* scrolllock
* ctrl-scrolllock

This likewise is actually left ctrl + scrolllock in the code.

Quoted 1 line

* ctrl-backtick

Not a good idea. backtick has no fixed location, depends on the keyboard layout.

So, the naming is a bit tricky here. If only the left ctrl key actually works we should say so in the name and call it "lctrl-scrolllock". Or leave the name and allow both ctrl keys.

For the ctrl-ctrl (and simliar) hotkeys I think it doesn't matter much whenever we call them "ctrl-ctrl" or "lctrl-rctrl". It is kida obvious that you need both the left and right one when you should press two control keys. But I think it should be consistent with what we pick for ctrl-scrolllock.

I think sticking with the current names and make both ctrl keys work with scrolllock is the better way.

cheers,
Gerd