Repository navigation
fix(wasm): Stuck and flickering keyboard modifier state (6.8) (backport #25155) - #25775
Merged
agneszitte merged 8 commits intoOct 28, 2026
Merged
Conversation
KeyboardStateTracker emulated the Locked flag as a per-key press parity counter. That is only equivalent to the Win32 "toggled" bit it mirrors if every physical press produces exactly one update, which no platform guarantees: routed key events are raised once per element while bubbling, so the resulting flag depended on the focused element's depth in the visual tree, and OS auto-repeat flipped it again for a key held down. Nothing reads the flag, and for Caps Lock - the one key where an app would consult it - a press counter is the wrong source anyway, since the lock can be toggled before the app starts or while it is in the background. Dropping it also makes the tracker idempotent, which removes the need to tell an auto-repeat apart from a key down whose key up was never delivered: both mean the key is down. It also fixes the drag modifiers in PointerRoutedEventArgs.GetState, which compare against Down exactly and silently dropped whenever the parity landed on Down | Locked. See #17100 Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> (cherry picked from commit b580458) (cherry picked from commit ee98140)
Key downs and key ups cannot be trusted to stay paired: a modifier released while the browser or the OS holds focus - opening dev tools mid-keystroke, for instance - never produces a key up, leaving the key reported as held for the rest of the session. Every key event already carries the real state of all four modifiers alongside its own payload, so apply that in OnKey before dispatching. This is the single per-event entry point, so it runs once per physical key rather than once per element while bubbling. The key the event is about needs no special treatment: the key down/up applied while the event bubbles lands after this and wins, which also avoids relying on how a platform reports a modifier's own key up. See #17100 Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> (cherry picked from commit a9ff5c6) (cherry picked from commit 285b760)
A mobile on-screen keyboard can raise Shift during auto-capitalization without ever releasing it, with no window blur involved. In a touch-only session no key event follows either, so neither the key event resync nor the activation reset can correct it and every tap reads as Shift+tap. Pointer events carry the browser's own ctrl/shift on every occurrence, so feed those to the tracker as well. The write is skipped when the value is unchanged, to keep pointermove free of dictionary churn. Alt and Meta are not reported on pointer events and stay on the key event path. See #17100 Co-Authored-By: Jacques Bourque <[email protected]> Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> (cherry picked from commit 3a6454e) (cherry picked from commit 0a65287)
WebAssemblyWindowWrapper already had OnNativeActivated and OnNativeVisibilityChanged, but nothing ever called them: this was the only Skia target not feeding the shared activation path. Android, AppleUIKit and X11 all wire theirs. Map the browser equivalents onto it - window focus/blur for activation, document visibilitychange for visibility. Window.Activated and Window.VisibilityChanged consequently start being raised on this target, where they never fired before. This also restores the reset of the tracked keyboard state that BaseWindowImplementation performs on an activation change, which is what stops a modifier held while the browser steals focus from being reported as held once the page gets focus back. See #17100 Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> (cherry picked from commit 4ebc924) (cherry picked from commit de132fc)
OnEnterKeyPressed raised KeyDown with no matching KeyUp, so every Enter pressed on the on-screen keyboard left the key reported as held for the rest of the session. The AppleUIKit equivalent already raises both. See #17100 Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> (cherry picked from commit 9852c2d) (cherry picked from commit 2a4cbfb)
By default the server reports auto-repeat as a KeyRelease/KeyPress pair, so a key held down arrives as a rapid sequence of presses and releases and CoreWindow.GetKeyState reports it as not held in between. Detectable auto-repeat delivers repeated key presses instead, matching every other platform; GTK, Qt and SDL all request it. It is set per connection, and key events are read from whichever connection owns the window they target, so request it on both. See #17100 Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> (cherry picked from commit ac564bb) (cherry picked from commit 3c528bc)
Reports CoreWindow.GetKeyState for the modifier keys and the last key pressed, so a modifier that stays reported as held, or a held key whose state is not stable, is visible without a debugger. Also written to the console, where the transition matters more than the current value. See #17100 Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> (cherry picked from commit 92deeda) (cherry picked from commit 929750e)
Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> (cherry picked from commit 9bfda24) (cherry picked from commit 7567b44)
agneszitte
approved these changes
Oct 28, 2026
2 of 5 tasks
This was referenced Nov 9, 2026
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.
GitHub Issue: unoplatform/kahua-private#545 (backport of #24575)
PR Type:
🐞 Bugfix
What changed? 🚀
Backport of #24575 to 6.8. All 8 commits are cherry-picked with
-x.KeyboardStateTrackerkept modifier state in a persistent dictionary, updated only by matched key down/key up pairs. That caused two bugs on WebAssembly:Downfor the rest of the session. Opening dev tools with Ctrl+Shift+I reliably triggers this.CoreWindow.GetKeyStatethen reported Ctrl as held, so aDataGridtreated plain arrows as Ctrl+Arrow.Lockedflickering during auto-repeat.Lockedwas toggled on every key down, and a held key repeats key downs with no key up in between.The fixes, the same as #24575:
Downstate.Differences from #24575. Two commits conflicted because master has since been refactored around them. In both, the commit's own lines are unchanged:
fix(wasm): Raise key up for the soft keyboard Enter key: master reaches the focused text box throughITextBoxHost/core.Owner, while 6.8 still usesTextBox. The key-up raise is applied to 6.8'sTextBoxform.fix(x11): Enable detectable auto-repeat: master creates its windows through the graphics negotiation pipeline, while 6.8 still has its explicit Vulkan, GL and EGL renderer selection. The per-connectionXkbSetDetectableAutoRepeatcall goes right after the second display connection opens, as on master, ahead of 6.8's renderer selection.Validation:
Given_KeyboardStateTrackerpasses 12/12 onservicing/6.8, which is every test in the file.servicing/6.8:Uno.UI.Runtime.Skia.WebAssembly.Browserruntime, C# and TypeScript;Uno.UI.Runtime.Skia.X11runtime;KeyboardStateProbesample.PR Checklist ✅
Given_KeyboardStateTrackerunit tests and theKeyboardStateProbesample, both from fix(wasm): Stuck and flickering keyboard modifier state #24575.Screenshots Compare Test Runresults.🤖 Generated with Claude Code
This is an automatic backport of pull request #25155 done by [Mergify](https://mergify.com).