Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Actions/locks xkb extension v3 #527

Draft
wants to merge 6 commits into
base: master
Choose a base branch
from

Conversation

wismill
Copy link
Member

@wismill wismill commented Oct 11, 2024

This is a refactor of #485 (and of the first attempt #446, see #484 for the rational). The differences is that is it rebased on master and without exposing the new format XKB_KEYMAP_FORMAT_TEXT_V1_1 yet. We use an experimental XKB_EXPERIMENTAL_LOCKS environment variable to activate it, until we agree on an API (see #484). Note that this is only temporary, in order to be able to test it in real conditions, without waiting for DE to enable configuration of the keymap format.

In order to fix #372 and #420, one must set the env variable XKB_EXPERIMENTAL_LOCKS to something, e.g. true.

Additionally for #420, on must must also modify /usr/share/xkb/symbols/group (preferably by overriding it via ~/.config/xkb), that is use multiple actions thanks to #487:

partial modifier_keys
xkb_symbols "lctrl_lshift_toggle" {
-    key <LFSH> {[  Shift_L,  ISO_Next_Group  ], type[group1] = "PC_CONTROL_LEVEL2" };
+    key <LFSH> {[  Shift_L,  {Shift_L, ISO_Next_Group}  ], type[group1] = "PC_CONTROL_LEVEL2" };
-    key <LCTL> {[  Control_L,  ISO_Next_Group  ]};
+    key <LCTL> {[  Control_L,  {Control_L, ISO_Next_Group}  ]};
};

partial modifier_keys
xkb_symbols "lctrl_lshift_toggle_rev" {
-    key <LFSH> {[  Shift_L,  ISO_Prev_Group  ], type[group1] = "PC_CONTROL_LEVEL2" };
+    key <LFSH> {[  Shift_L,  {Shift_L,ISO_Prev_Group}  ], type[group1] = "PC_CONTROL_LEVEL2" };
-    key <LCTL> {[  Control_L,  ISO_Prev_Group  ]};
+    key <LCTL> {[  Control_L,  {Control_L,ISO_Prev_Group}  ]};
};

partial modifier_keys
xkb_symbols "rctrl_rshift_toggle" {
-    key <RTSH> {[  Shift_R,  ISO_Next_Group  ], type[group1] = "PC_CONTROL_LEVEL2" };
+    key <RTSH> {[  Shift_R,  {Shift_R,ISO_Next_Group}  ], type[group1] = "PC_CONTROL_LEVEL2" };
-    key <RCTL> {[  Control_R,  ISO_Next_Group  ]};
+    key <RCTL> {[  Control_R,  {Control_R,ISO_Next_Group}  ]};
};

Changes:

  • Add new keymap format XKB_KEYMAP_FORMAT_TEXT_V1_1
  • Add new option lockOnRelease for LockGroup. It locks the group on release rather than press as in the protocol. Intended to fix issue for group lock on e.g. shift+alt. It is the default for XKB_KEYMAP_FORMAT_TEXT_V1_1, so that it fixes the issue with the xkeyboard-config files unchanged.
  • Add new option unlockOnPress for LockMods. It unlocks the modifiers on second press rather than the second release, as in the protocol. Intended to fix issue with CapsLock for fast typists. It is the default for XKB_KEYMAP_FORMAT_TEXT_V1_1, so that it fixes the issue with the xkeyboard-config files unchanged.
  • Add corresponding tests.
  • Add --format options to tools, in order to select the keymap format for parsing and serializing.

A lot of files are affected, but hopefully it is easier to review per commit. The first commit should be in an independent PR (hence the WIP title).


TODO:

  • More tests?
  • Move first commit to an independent PR
  • Changelog entries
  • Update documentation for the new format (keep it hidden until publicly exposed?)

@whot @bluetech @fooishbar

keymap: Add xkb_keymap_new_from_names2

Currently `xkb_keymap_new_from_names` does not allow to specify the
keymap format, so provide a new function `xkb_keymap_new_from_names2`.

keymap: Use explicit format in keymap_get_as_string

actions: Use explicit format for parsing actions

test: Use explicit format version in test_compile_rules

tools: Add --format* options

Allow to choose the exact keymap formats for parsing and serializing.
This prepares for the addition of the new minor version XKB 1.1.
For now only an internal format.
This is an extension to XKB, to allow to use e.g. the combination
`Control + Shift` *alone* to switch layouts, while keeping the use of
`Control + Shift + some other key` (typically for keyboard shortcuts).

This is really useful for people coming from other platform, such as
Windows.
This is an extensions to XKB. It intends to allow to deactivate CapsLock on press
rather than on release, as in other platforms such as Windows.
This is for experimental use only.
@wismill wismill added X11 legacy: limitations Indicates a need to lift legacy X11 limitations state Indicates a need for improvements or additions to the xkb_state API labels Oct 11, 2024
@wismill
Copy link
Member Author

wismill commented Oct 11, 2024

I installed this on my system and will test in various situations. So far it’s working well.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
state Indicates a need for improvements or additions to the xkb_state API X11 legacy: limitations Indicates a need to lift legacy X11 limitations
Projects
None yet
Development

Successfully merging this pull request may close these issues.

CapsLock change upon press instead of release option.
1 participant