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

Modifiers can erroneously end up perma-set #583

Closed
Jules-Bertholet opened this issue Jan 8, 2025 · 1 comment · Fixed by #584
Closed

Modifiers can erroneously end up perma-set #583

Jules-Bertholet opened this issue Jan 8, 2025 · 1 comment · Fixed by #584
Labels
bug Indicates an unexpected problem or unintended behavior state Indicates a need for improvements or additions to the xkb_state API
Milestone

Comments

@Jules-Bertholet
Copy link
Contributor

Jules-Bertholet commented Jan 8, 2025

Consider the following symbols file (reduced from a real-world example):

default partial alphanumeric_keys
xkb_symbols "base" {
        name[Group1] = "Test latching behavior";

        key <AB01> { [ z, Z, y, Y, ezh, EZH, ydiaeresis, Ydiaeresis ], type[Group1] = "EIGHT_LEVEL" };

        key <LCTL> { [ Control_L ] };

        key <RALT> {
                symbols[Group1] = [ ISO_Level3_Latch, ISO_Level5_Latch ],
                actions[Group1] = [ LatchMods(modifiers=LevelThree,latchToLock=false,clearLocks), LatchMods(modifiers=LevelFive,latchToLock=false,clearLocks) ],
                type[Group1] = "PC_CONTROL_LEVEL2"
        };
};

When used along with the standard xkeyboard-config data, under current xkbcommon, with the following sequence of keypresses:

  • Press <LCTL>
  • Press and release <RALT>
  • Release <LCTL>
  • Press and release <RALT>
  • Press and release <AB01> (this should unlatch LevelThree)

LevelThree (Mod5) ends up permanently set, with no way to clear it, making the keyboard unusable.

Jules-Bertholet added a commit to Jules-Bertholet/libxkbcommon that referenced this issue Jan 8, 2025
Jules-Bertholet added a commit to Jules-Bertholet/libxkbcommon that referenced this issue Jan 8, 2025
@wismill wismill added bug Indicates an unexpected problem or unintended behavior state Indicates a need for improvements or additions to the xkb_state API labels Jan 14, 2025
@wismill wismill added this to the 1.8.0 milestone Jan 14, 2025
@wismill
Copy link
Member

wismill commented Jan 16, 2025

It seems this bug is present since at least xkbcommon 1.0. We would have detected before if we supported StickyKeys control (see #596).

wismill added a commit to Jules-Bertholet/libxkbcommon that referenced this issue Jan 16, 2025
The modifiers filters should ensure minimal interaction between them,
but currently the Latch mod filters are overzealous and mess with the
mods from other filters set to be cleared, resulting in some modifiers
permanently set.

Fixed by clearing mods properly with `OR` rather than direct setting
of `state::clear_mods`.

While we are at it, `state::set_mods` should be `OR`ed as well. This
should not have any impact for now, but this is more future-proof.

Fixes xkbcommon#583

Co-authored-by: Jules Bertholet <[email protected]>
Co-authored-by: Pierre Le Marre <[email protected]>
wismill added a commit to Jules-Bertholet/libxkbcommon that referenced this issue Jan 16, 2025
The modifiers filters should ensure minimal interaction between them,
but currently the Latch mod filters are overzealous and mess with the
mods from other filters set to be cleared, resulting in some modifiers
permanently set.

Fixed by clearing mods properly with `OR` rather than direct setting
of `state::clear_mods`.

While we are at it, `state::set_mods` should be `OR`ed as well. This
should not have any impact for now, but this is more future-proof.

Fixes xkbcommon#583

Co-authored-by: Jules Bertholet <[email protected]>
Co-authored-by: Pierre Le Marre <[email protected]>
wismill added a commit that referenced this issue Jan 16, 2025
The modifiers filters should ensure minimal interaction between them,
but currently the Latch mod filters are overzealous and mess with the
mods from other filters set to be cleared, resulting in some modifiers
permanently set.

Fixed by clearing mods properly with `OR` rather than direct setting
of `state::clear_mods`.

While we are at it, `state::set_mods` should be `OR`ed as well. This
should not have any impact for now, but this is more future-proof.

Fixes #583

Co-authored-by: Jules Bertholet <[email protected]>
Co-authored-by: Pierre Le Marre <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Indicates an unexpected problem or unintended behavior state Indicates a need for improvements or additions to the xkb_state API
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants