Branch
Hash :
d9d82355
Author :
Date :
2025-06-12T09:13:27
keymap: Add option `lockOnRelease` for LockGroup()
It enables to use e.g. the combination `Control + Shift` *alone* to
switch layouts, while keeping the use of `Control + Shift + other key`
(typically for keyboard shortcuts).
The specification of `LockGroup()` is changed to:
- On key *press*:
- If `lockOnRelease` is set, then key press has no effect.
- Otherwise:
- if the `group` is absolute, key press sets the *locked* keyboard group to
`group`;
- otherwise, key press adds `group` to the *locked* keyboard group.
In either case, the resulting *locked* and *effective* group is brought back
into range depending on the value of the `GroupsWrap` control for the keyboard.
- On key *release*:
- If `lockOnRelease` is not set, then key release has no effect.
- Otherwise, if any other key was *pressed* after the locking key, then
key release has no effect.
- Otherwise, it has the same effect than a key press *without* `lockOnRelease`
set.
This is really useful for people coming from other platforms, such as
Windows.
It fixes a [20-year old issue] inherited from the X11 ecosystem, by
extending the [XKB protocol key actions].
As it is incompatible with X11, this feature is available only using the keymap
text format v2.
[20-year old issue]: https://gitlab.freedesktop.org/xorg/xserver/-/issues/258
[XKB protocol key actions]: https://www.x.org/releases/current/doc/kbproto/xkbproto.html#Key_Actions
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55
default partial
xkb_compatibility "lockOnPress" {
virtual_modifiers AltGr;
interpret.repeat= False;
interpret ISO_Next_Group {
useModMapMods= level1;
virtualModifier= AltGr;
action= LockGroup(group=+1, lockOnRelease=false);
};
interpret ISO_Prev_Group {
useModMapMods= level1;
virtualModifier= AltGr;
action= LockGroup(group=-1, lockOnRelease=false);
};
interpret ISO_First_Group {
action= LockGroup(group=1, lockOnRelease=false);
};
interpret ISO_Last_Group {
action= LockGroup(group=2, lockOnRelease=false);
};
};
partial
xkb_compatibility "lockOnRelease" {
virtual_modifiers AltGr;
interpret.repeat= False;
interpret ISO_Next_Group {
useModMapMods= level1;
virtualModifier= AltGr;
action= LockGroup(group=+1, lockOnRelease);
};
interpret ISO_Prev_Group {
useModMapMods= level1;
virtualModifier= AltGr;
action= LockGroup(group=-1, lockOnRelease);
};
interpret ISO_First_Group {
action= LockGroup(group=1, lockOnRelease);
};
interpret ISO_Last_Group {
action= LockGroup(group=2, lockOnRelease);
};
};