Repository navigation
feat(injection): Add keyboard input injection on Skia - #23970
Conversation
|
Claude finished @MartinZikmund's task in 4m 25s —— View job PR Review: feat(injection): Add keyboard input injection on SkiaTasks:
Review SummaryVerdict: ship — the architecture is sound and the approach of joining at Inline findings posted (4 substantive, 1 informational):
Cross-cutting notes (no matching diff line):
|
|
🤖 Your WebAssembly Skia Sample App stage site is ready! Visit it here: https://unowasmprstaging.z20.web.core.windows.net/pr-23970/wasm-skia-net9/index.html |
|
🤖 Your Docs stage site is ready! Visit it here: https://unodocsprstaging.z13.web.core.windows.net/pr-23970/docs/index.html |
|
The build 225873 found UI Test snapshots differences: Details
|
|
|
749d749 to
fbe3858
Compare
|
Claude finished @MartinZikmund's task in 3m 43s —— View job PR Review: feat(injection): Add keyboard input injection on SkiaTasks:
Review SummaryVerdict: fix-first — the architecture and approach are sound; a small cluster of issues from the prior review were not addressed and need fixing before merge. Inline findings (5 posted):
What's correct:
|
|
🤖 Your WebAssembly Skia Sample App stage site is ready! Visit it here: https://unowasmprstaging.z20.web.core.windows.net/pr-23970/wasm-skia-net9/index.html |
fbe3858 to
7db720c
Compare
|
Claude finished @MartinZikmund's task in 4m 10s —— View job PR Review: feat(injection): Add keyboard input injection on SkiaTasks:
Review SummaryVerdict: fix-first — the two new commits ( Inline findings (4 posted):
Cross-cutting notes (not in diff, cannot post inline):
What's correct in the new commits:
|
|
The build 229579 found UI Test snapshots differences: Details
|
Implements InputInjector.InjectKeyboardInput on all Skia targets by joining the input pipeline at InputManager.KeyboardManager, the single chokepoint every Skia host already feeds through IUnoKeyboardInputSource. Injected keys therefore get focus routing, accelerators, Tab navigation and text input for free, with no per-host changes. Keyboard injection targets the active window, mirroring the foreground-window behavior of the Windows implementation. The injector registration moves from the managed pointer manager into the InputManager constructor and now tracks every ContentRoot on the thread, so a second window is reachable. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01VqgzbwoDgQg8h23MRQamNr (cherry picked from commit 7657e7a)
UnicodeText assumed every surrogate was part of a valid pair, so char.ConvertToUtf32 threw whenever a lone surrogate reached layout. That happens transiently whenever a surrogate pair arrives one code unit at a time, which is how a pair is typed, injected, or committed by an IME. The step also advanced by two for a lone low surrogate, skipping the following character. Unpaired surrogates now render as the replacement character instead of throwing. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01VqgzbwoDgQg8h23MRQamNr (cherry picked from commit 73b13d1)
Covers typing into the focused element, Shift casing, Ctrl+A select-all without a character, accelerator matching via injected modifier keys, Tab focus movement, Unicode and surrogate pairs, bare key-up, ordering and KeyStatus. When_InjectKey_Raises_CharacterReceived is the discriminating test: it cannot pass through TestServices.KeyboardHelper, which raises routed events directly on an element and so never reaches the only CharacterReceived raise site. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01VqgzbwoDgQg8h23MRQamNr (cherry picked from commit 2aed440)
InjectMouseInput hardcoded VirtualKeyModifiers.None, so a modifier held through InjectKeyboardInput never reached the pointer args and Ctrl+Click could not be composed from the two injection APIs. Modifiers now default from the tracked keyboard state. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01VqgzbwoDgQg8h23MRQamNr (cherry picked from commit 75a187f)
Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01VqgzbwoDgQg8h23MRQamNr (cherry picked from commit bbb38bb)
- Mark InjectKeyboardInput [NotImplemented] for __WASM__ and IS_UNIT_TESTS. The native WASM (DOM) head defines HAS_INPUT_INJECTOR but has no keyboard body, so the API silently no-opped there while advertising itself implemented. Runtime tests are now gated on __SKIA__ so the WASM leg no longer runs them. - Hold injector targets weakly. The per-thread list is appended from every InputManager constructor, so strong references pinned each closed window's visual tree for the process lifetime and defeated ContentRoot teardown. - Validate a keyboard batch before dispatching any of it. Throwing mid-batch left injected modifier keys latched in the process-wide KeyboardStateTracker with no key-up to release them. - Make the Caps Lock latch process-wide. TryCreate() mints a new injector per call, so per-instance state silently reset between them. - Always scan for the active window instead of skipping the scan for a single target, and log when no window reports active. - Match TextBox's AltGr and Apple-layout rules when synthesizing characters, so injection cannot produce a character the platform never would. - Require the UI thread: injection drives the routed-event pipeline and reads shared keyboard state, neither of which is thread-safe. Tests no longer pass vacuously when no injector is available, and cover Caps Lock latching and batch validation. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01VqgzbwoDgQg8h23MRQamNr (cherry picked from commit d62b0e1)
- ArgumentException now reports "input" as paramName instead of a method name. - InjectKeyboardInputAsync validates the whole batch before dispatching, so the no-partial-delivery contract of the synchronous overload holds there too. - Caps Lock toggling moves behind a static helper, keeping the static write out of the instance method. - Logging uses this.Log().Warn(...), matching the rest of the file, and the KeyboardManager init error no longer says "PointerManager". - The surrogate-pair test releases VK 255 instead of leaving it latched down. - Documented why the XamlIsland skip uses Assert.Inconclusive. - Dropped an unused using from IInputInjectorTarget. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01QmZ63vuPQNDmg8H6nSGFSq
Real input reads the OS key state after the transition is applied, so a Shift key-down already reports Shift. The tracker is only updated once the routed event reaches UIElement, so injected args reported stale modifiers. Also resolves the Unicode key (255) before querying WasKeyDown, which was previously looked up against VirtualKey 0. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_012PF59BzvEyASdeFtsFHrox
Select-all is Cmd+A on Apple keyboards, so the hardcoded Ctrl+A failed on macOS and iOS. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_012PF59BzvEyASdeFtsFHrox
An unpaired surrogate in a test name or assertion message made the whole NUnit results document unwritable on WebAssembly, where it is POSTed to a server that encodes as UTF-16. The shard then aborted with "Root element is missing" and no diagnostics. Escape non-XML characters when generating the document, and stop passing lone surrogates as data-row values. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_012PF59BzvEyASdeFtsFHrox
Releasing one side of Shift, Control, Menu or Windows cleared the whole modifier even while the opposite side was still held, both on the release event and, through KeyboardStateTracker's aggregate key, on later input. The aggregate Shift/Control/Menu state now stays down while either side is, matching Win32 GetKeyState. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Both keyboard injection overloads now go through one validation helper, and target lookups drop collected window references instead of only pruning when a new window registers. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Canceling InjectKeyboardInputAsync mid-batch left injected modifiers latched. Also document synchronous delivery and the UI-thread requirement as differences from Windows. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01YY8tbyuyYCBAZWQQkpQyiL
Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01YY8tbyuyYCBAZWQQkpQyiL
0522126 to
b5ab665
Compare
|
Claude finished @MartinZikmund's task in 36s —— View job PR Review: feat(injection): Add keyboard input injection on SkiaVerdict: ship. I posted no inline comments. The two newest commits are Latest Copilot findings (open on the PR):
Cross-cutting: nothing new beyond what earlier rounds already confirmed fixed. |
Addressed PR comments up to this pointRebased onto current
Local validation: Skia desktop (net10.0) runtime tests @morning4coffe-dev, your overlapping left/right modifier finding was addressed in the Sep 24 round (fix + runtime/unit tests). Could you take another look when you get a chance? 🙏 |
|
The build 238518 found UI Test snapshots differences: Details
|
|
🤖 Your Docs stage site is ready! Visit it here: https://unodocsprstaging.z13.web.core.windows.net/pr-23970/docs/index.html |
GitHub Issue: closes #12962
PR Type:
✨ Feature
What changed? 🚀
InputInjector.InjectKeyboardInputwas unimplemented on every Uno target — the generated stub threw. This implements it for all Skia targets.The implementation joins the input pipeline at
InputManager.KeyboardManager, the single chokepoint every Skia host already feeds throughIUnoKeyboardInputSource. Injected keys therefore get focus routing, accelerators, Tab navigation and text input for free, with no per-host changes.Keyboard injection targets the active window, mirroring the foreground-window behavior of the Windows implementation. The injector registration moves from the managed pointer manager into the
InputManagerconstructor and now tracks everyContentRooton the thread, so a second window is reachable.Also included:
UnicodeTextassumed every surrogate was part of a valid pair, sochar.ConvertToUtf32threw whenever a lone surrogate reached layout — which happens transiently whenever a surrogate pair arrives one code unit at a time, i.e. exactly how a pair is typed, injected, or committed by an IME. Unpaired surrogates now render as the replacement character.specs/keyboard-injection-design.mdcovering the pipeline entry point, window targeting, and the documented differences from Windows (in-process only, no IME composition, invariant US layout unlessUnicodeis used, no automatic key repeat, synchronous delivery).Non-Skia targets keep the previous behavior: the new
IInputInjectorTargetkeyboard members follow the existing pointer pattern (cross-platform explicit interface implementation delegating to apartial voidthat only the Skia file implements), so they compile to a no-op everywhere else.PR Checklist ✅
Screenshots Compare Test Runresults.