Skip to content

Record backend input events in the event hook - #12720

Open
tilladam wants to merge 3 commits into
slint-ui:masterfrom
tilladam:mcp/record-backend-input
Open

Record backend input events in the event hook#12720
tilladam wants to merge 3 commits into
slint-ui:masterfrom
tilladam:mcp/record-backend-input

Conversation

@tilladam

Copy link
Copy Markdown
Contributor

What

Feeds real backend input (winit and Qt) through the window_event_hook so
that user-generated pointer, wheel and key events are observable to the hook,
each reported exactly once with its true dispatch result.

Previously the hook only saw events that were replayed through the public
Window::dispatch_event_with_result; input that arrived directly from the
backend and went straight into process_mouse_input / process_key_input
was invisible to it.

How

  • WindowInner gains two #[doc(hidden)] helpers,
    process_mouse_input_and_notify and process_key_input_and_notify, which
    run the normal internal dispatch and then notify the hook with the event's
    public WindowEvent representation and its WindowEventDispatchResult.
  • A shared notify_window_event helper does the context/hook lookup;
    dispatch_event_with_result is refactored to reuse it (no behavior change).
  • The winit and Qt backends map each raw input event to its public
    WindowEvent and route it through the new helpers.
  • PointerExited is reported as Accepted unconditionally, matching the
    existing teardown-event semantics in dispatch_event_with_result.
  • In Qt, a drag-leave is deliberately kept off the recording path (via a new
    drag_leave_event) so it is not mis-recorded as a pointer exit.

Tests

Adds dispatch_result_tests coverage in the testing backend asserting that
the new backend helpers notify the hook exactly once with the correct result
for pointer, key and pointer-exit events.

Notes / follow-ups

  • Depends on / pairs with the one-line winit fix "winit: propagate the key
    auto-repeat flag to KeyEvent" (separate PR). This PR is independent and
    green on its own — it reads winit's event.repeat to emit
    KeyPressRepeated for recording — but the two are best merged together,
    the repeat fix first.
  • Touch and gesture input (winit Touch, Qt pinch/rotation, multi-touch) is
    not recorded: the public platform::WindowEvent has no variant for it.
    Left as a follow-up.
  • Scroll phase does not round-trip through the public PointerScrolled
    variant, which has no phase field.

@tilladam
tilladam force-pushed the mcp/record-backend-input branch from d3e3ff8 to b19e620 Compare July 30, 2026 19:22
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.

1 participant