Skip to content

state: support pure virtual modifiers V2 #757

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

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

wismill
Copy link
Member

@wismill wismill commented May 8, 2025

Up-to-date alternative design to #450. Pure virtual modifiers are already supported, albeit requiring an explicit mapping. This PR only introduces assigning automatically a canonical mapping to vmod that remain unmapped after the usual vmod resolution.

I do not think we want this by default, at least not in the v1 keymap format, as it introduces breakage. However it could be activated by default in the v2 keymap format.

Warning

#755 should be fixed first.

Caution

This is a very raw draft; tests require an update.

TODO:

  • Ensure automated canonical mapping is made explicit at serialization
  • fix Specify virtual modifier indexes assignment #755
  • guard with v2 keymap format check
  • update the tests
  • update description
  • Update the commit messages to reflect current implementation

(old description, require update)

Traditionally, virtual modifiers were merely name aliases for real modifiers, e.g. NumLock was usually mapped to Mod2 (see modifier_map statement). Virtual modifiers that were never mapped to a real one had no effect on the keymap state.

This patch introduces the concept of pure virtual modifiers, i.e. virtual modifiers that are not mapped now show up as if the were true modifiers.

Note that pure virtual modifiers cannot be used in an interpret action's AnyOf() and an interpret action for a pure virtual modifier must be AnyOfOrNone() to take effect:

virtual_modifiers APureMod,...;

interpret a+AnyOfOrNone(all) {
  virtualModifier= APureMod;
  action= SetMods(modifiers=APureMod);
};

The above adds a pure virtual modifier for keysym a.

Interestingly, this fixes one current issue with our tests: previously the de(neo) layout level5 didn't take effect correctly, with this patch in place it now behaves.

@wismill wismill added this to the 1.10.0 milestone May 8, 2025
@wismill wismill added compile-keymap Indicates a need for improvements or additions to keymap compilation state Indicates a need for improvements or additions to the xkb_state API labels May 8, 2025
Traditionally, virtual modifiers were merely name aliases for real modifiers,
e.g. NumLock was usually mapped to Mod2 (see modifier_map statement). Virtual
modifiers that were never mapped to a real one had no effect on the keymap state.

This patch introduces the concept of pure virtual modifiers, i.e. virtual
modifiers that are not mapped now show up as if the were true modifiers.

Note that pure virtual modifiers cannot be used in an interpret action's AnyOf()
and an interpret action for a pure virtual modifier must be AnyOfOrNone() to
take effect:

    virtual_modifiers APureMod,...;

    interpret a+AnyOfOrNone(all) {
      virtualModifier= APureMod;
      action= SetMods(modifiers=APureMod);
    };

The above adds a pure virtual modifier for keysym `a`.

Interestingly, this fixes one current issue with our tests: previously the
de(neo) layout level5 didn't take effect correctly, with this patch in place it
now behaves.
@wismill wismill force-pushed the pure-virtual-modifiers/auto branch from 03a7c05 to c0087fb Compare May 9, 2025 08:32
@wismill wismill modified the milestones: 1.10.0, 1.11.0 May 9, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
compile-keymap Indicates a need for improvements or additions to keymap compilation state Indicates a need for improvements or additions to the xkb_state API
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Specify virtual modifier indexes assignment
2 participants