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

Experiment: state: support pure virtual modifiers #450

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

Conversation

whot
Copy link
Contributor

@whot whot commented Feb 14, 2024

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.


This took forever to wrap my head around it almost feels too simple now... The one test case failure was in the de(neo) layout but after staring at this - it actually fixes that particular issue.

Related to #447

cc @wismill, @bluetech, @fooishbar

@wismill wismill added state Indicates a need for improvements or additions to the xkb_state API discussion: backward compatibility labels Feb 15, 2024
@whot
Copy link
Contributor Author

whot commented Feb 20, 2024

Referencing #36 here too since there's significant overlap.

@wismill wismill added this to the 1.8.0 milestone Mar 12, 2024
@fooishbar
Copy link
Member

Yeah, nice. I think this is definitely the right approach.

@wismill
Copy link
Member

wismill commented Jul 9, 2024

@whot I added some tests in whot#1.

whot and others added 2 commits August 30, 2024 09:10
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
Copy link
Member

wismill commented Aug 30, 2024

Rebased and added first dedicated tests. Since this has the potential to breaks things, I would proceed with care. But honestly I feel it looks pretty solid for now. Maybe modify more tests much like keyseq where two rules files (usual vs “pure” virtual modifiers) are used alternatively on the same tests.

@wismill
Copy link
Member

wismill commented Sep 23, 2024

This will require #512 for a full implementation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
discussion: backward compatibility 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.

3 participants