Skip to content

feat(windows): expose native touch input to Cx::touch_controls - #2638

Merged
Hona merged 1 commit into
devfrom
feat/windows-native-touch-controls
Nov 27, 2026
Merged

Hona merged 1 commit into
devfrom
feat/windows-native-touch-controls

Conversation

@Hona

@Hona Hona commented Nov 27, 2026

Copy link
Copy Markdown
Member

Fixes #1410

Summary

  • Per-window native primary pointer mode: HostState now tracks PrimaryPointer (Hover vs Touch) per window/runtime and exposes it through Cx::touch_controls() and Cx::hover_none(). Views (and memos) that read either accessor automatically re-run when the pointer mode changes, while views that do not read them incur zero extra commits (preserving Tx::live_only() on touch gestures).
  • Windows native touch, pen, mouse, and tablet posture (crates/rune/src/platform/win32/touch_input.rs):
    • Classifies WM_TOUCH and WM_POINTERDOWN/WM_POINTERUPDATE/WM_POINTERUP (GetPointerType: PT_TOUCH vs PT_PEN/PT_MOUSE/PT_TOUCHPAD) in a lightweight Win32 window subclass installed on both windows and overlays, so finger touch activates Cx::touch_controls() while Windows pen/stylus input keeps precision hover mode without breaking pen clicks or drags.
    • Distinguishes touch-promoted (0xFF51_5780..=0xFF51_57FF) vs pen-promoted (0xFF51_5700..=0xFF51_577F) legacy mouse messages via GetMessageExtraInfo() MI_WP_SIGNATURE bit 7, keeping promoted messages suppressed while preventing touch promotion from flipping back to mouse mode.
    • Probes initial Windows tablet posture (SM_MAXIMUMTOUCHES, SM_DIGITIZER ready + touch bits, SM_CONVERTIBLESLATEMODE, SM_MOUSEPRESENT) and watches WM_SETTINGCHANGE (ConvertibleSlateMode / UserInteractionMode), updating only on initial sample or actual posture transitions so focus changes on hybrid touchscreen laptops keep live touch mode intact.
  • Cross-platform & headless: Live finger touch (WindowEvent::Touch / Runtime::touch) switches to Touch and mouse/trackpad/wheel/pen input switches back to Hover on all native targets; LayerHost on iOS starts in touch mode; Runtime::touch_controls() and Runtime::set_touch_controls(bool) support headless tests and embedded hosts; wasm32 keeps its browser CSS media-query implementation unchanged.

Verification

  • cargo check -p rune --lib (Windows) — pass
  • cargo check -p rune --target wasm32-unknown-unknown --lib — pass (0 new warnings)
  • cargo test -p rune --lib -- touch_input::tests controls_tests runtime::input::touch edge_drag platform_events — 76 passed, 0 failed (covering Windows system metrics, MI_WP_SIGNATURE mouse/pen/touch classification, WM_TOUCH vs WM_POINTER* pen/touch routing, WM_SETTINGCHANGE area matching, tablet posture transitions, memo invalidation, unread zero-commit gating, and existing touch/pinch/edge-drag suites).
  • Not verified on hardware: real Windows touchscreen / 2-in-1 slate-mode / Surface Pen hardware and iOS/macOS/Linux touchscreens were not run locally.

- Track per-window native PrimaryPointer (Hover vs Touch) in HostState and expose it through Cx::touch_controls() and Cx::hover_none(), re-running views and memos only when read.
- On Windows, classify WM_TOUCH and WM_POINTER* (PT_TOUCH vs PT_PEN/PT_MOUSE/PT_TOUCHPAD) via a lightweight window subclass, distinguish touch-promoted vs pen-promoted mouse messages via MI_WP_SIGNATURE bit 7, and reconcile Windows tablet posture (SM_MAXIMUMTOUCHES, SM_DIGITIZER, SM_CONVERTIBLESLATEMODE, SM_MOUSEPRESENT, and WM_SETTINGCHANGE for ConvertibleSlateMode / UserInteractionMode) without clobbering live touch mode on focus changes.
- Add Runtime::touch_controls() / Runtime::set_touch_controls() (and default iOS LayerHost to touch controls), keeping web CSS media query behavior unchanged.
@Hona
Hona merged commit 2c9bc18 into dev Nov 27, 2026
2 checks passed
@Hona
Hona deleted the feat/windows-native-touch-controls branch November 27, 2026 15:15
pascalandr added a commit to NeuralNomadsAI/rune that referenced this pull request Nov 27, 2026
Upstream merged the first Android slice (anomalyco#2662, closing anomalyco#2647): the winit
activity feature, the getloadavg gate and an android workflow. Taken from
upstream: runq.rs, the Android target section of rune's Cargo.toml (the
fork's JNI, NDK and AccessKit dependencies now sit in it), android.yml and
the changelog entry; the fork's own S0 entry goes.

Also from upstream since the last merge:
- Cx::touch_controls and hover_none read the host's primary pointer
  (anomalyco#2638). The fork's cfg(android) constants go; the Android LayerHost
  calls set_touch_controls(true), as the iOS one does.
- rune-text's prewarm_system_fonts (anomalyco#2660): Android's backend answers it
  with nothing to build ahead.
- rav1d without assembly (anomalyco#2641): an x86_64 library with avif links
  without -Wl,-Bsymbolic, so ANDROID.md's note about it goes.

Kept over upstream in android.yml: the android/** push trigger and the apk
job, which builds the Kotlin host with the example.

Checked: clippy for both Android targets (let_underscore_must_use allowed,
as rune-core fails it upstream), an x86_64 cdylib with avif links,
check-wasm, cargo check, file-size, rune lib tests 4087 passed with the 4
failures upstream dev has on Windows (and one more that passes alone).
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.

Windows: expose native touch input to Cx::touch_controls

1 participant