Fix stale keysym entries when modifier changes while key is held#4747
Merged
tarek-y-ismail merged 1 commit intoadd-keyboard-state-trackerfrom Mar 9, 2026
Merged
Fix stale keysym entries when modifier changes while key is held#4747tarek-y-ismail merged 1 commit intoadd-keyboard-state-trackerfrom
tarek-y-ismail merged 1 commit intoadd-keyboard-state-trackerfrom
Conversation
Contributor
Author
|
Just as a heads up, I was blocked by some firewall rules while working on your feedback. Expand below for details. |
Copilot
AI
changed the title
[WIP] Update keyboard state tracker implementation based on review feedback
Fix stale keysym entries when modifier changes while key is held
Mar 5, 2026
tarek-y-ismail
approved these changes
Mar 5, 2026
Contributor
tarek-y-ismail
left a comment
There was a problem hiding this comment.
Makes sense. @AlanGriffiths What do you think?
3d1ec08 to
fa7ae7d
Compare
ba462f0 to
13bf364
Compare
Contributor
|
@copilot Rebase this branch on main and fix any conflicts. |
Copilot stopped work on behalf of
tarek-y-ismail due to an error
March 6, 2026 13:48
Contributor
|
Fine, I'll do it myself 🤦 Later... |
bb7f499 to
c621224
Compare
…s on key-up Co-authored-by: tarek-y-ismail <[email protected]>
c621224 to
e856a50
Compare
tarek-y-ismail
approved these changes
Mar 9, 2026
16bc38f
into
add-keyboard-state-tracker
29 of 32 checks passed
TICS Quality Gate✔️ Passedmir
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
KeyboardStateTrackerused the keysym from the key-up event to erase frompressed_keysyms, but that keysym can differ from what was stored at key-down when a modifier changes mid-hold (e.g.1down → Shift down → key-up reportsXKB_KEY_exclam, leavingXKB_KEY_1stranded).Related: #4746
What's new?
scancode_to_keysymmap replaces the two separate sets (pressed_keysyms/pressed_scancodes). Scancode is the stable identity of a physical key; the map stores the keysym recorded at key-down against it.scancode_to_keysym.erase(scancode)), so mismatched key-up keysyms caused by held modifiers never leave stale entries.xkb_keysym_to_upper/xkb_keysym_to_lower, replacing the previous set-rebuild approach.keysym_is_pressedusesstd::ranges::any_ofover map values;scancode_is_pressedusesmap.contains. The linear scan for keysyms is inconsequential given the physical bound on simultaneously held keys (≤ ~20).key_up_clears_key_when_modifier_changed_while_heldexercises the exact failure scenario:1down → Shift down →!up → neitherXKB_KEY_1norXKB_KEY_exclamremains pressed.How to test
Run the
KeyboardStateTrackerTestsuite:All 17 tests should pass, including the new regression test.
Checklist
(optional) Added Screenshots or videos