Skip to content

Add opt-in touchscreen mouse independence and focus restoration - #729

Open
dhwon0916 wants to merge 2 commits into
mgth:masterfrom
dhwon0916:codex/touchscreen-support
Open

dhwon0916 wants to merge 2 commits into
mgth:masterfrom
dhwon0916:codex/touchscreen-support

Conversation

@dhwon0916

Copy link
Copy Markdown

Problem and behavior

Touching a secondary touchscreen can relocate the shared Windows cursor and take keyboard focus away from the app being used with the physical mouse. This adds an opt-in touchscreen mode that saves the mouse position and restores it when physical mouse movement resumes, with separately optional typing-focus restoration.

Changes

  • Keep existing behavior by default. Advanced touch preferences are available only after enabling mouse independence.
  • Add configurable focus delay (120 ms default), restore-on-mouse-movement mode, display selection, modifier override, and per-app focus rules separate from general exclusions.
  • Add an optional stylus toggle. Pen hover preserves the mouse anchor without triggering focus restoration.
  • Handle native touchscreen HID input for apps that consume touch without mouse promotion, including Electron AppBar panels. AppBar work-area changes preserve pending restoration when full monitor bounds are unchanged; moving/hiding a panel during a swipe no longer misidentifies the desktop as the touched app.
  • Keep buffers and queues bounded, use nonblocking engine access, preserve foreign cursor confinement, and cancel pending work on state/input changes. No keyboard hook or synthetic keystrokes are added.
  • Persist the new options across the C# UI, protocol, Rust layout/store, and registry. Include regression tests and documentation; update shared oracle snapshots for the new default values.
  • Unsubscribe disposed Options view models from daemon events to avoid retaining them.

Validation

The application source and tests in this branch match tested commit c994341 from my fork; only the fork-specific release launchers are omitted.

  • 442 Rust tests passed across lbm-hook, lbm-engine, lbm-layout, lbm-store, and lbm-zones.
  • 367 C# display-layout tests and 361 Avalonia UI tests passed.
  • Interactive Windows tests restored an editor across processes, including stale swipe coordinates; 500 restorations kept native handle usage at 140. Windows initially denied the test fixture foreground activation; the repeat passed.
  • Clippy with warnings denied, formatting, whitespace checks, and Windows release builds passed.
  • Mouse-position and typing-focus restoration after AppBar swipes were confirmed on my touchscreen hardware.

Physical stylus behavior still needs hardware validation. Pen apps that consume input without tagged mouse events are not covered by the touchscreen-only HID observer. Windows or individual apps can still refuse focus restoration. Linux runtime behavior was not hardware-tested.

This contribution contains source, tests, snapshots, and documentation only. No release binaries, ZIPs, diagnostic recordings, or fork-specific release launchers are included.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants