Repository navigation
Description
Problem
The frame loop learns about input from snapshots, not events. Each tick it reads the cursor (app.cursor_position(), src-tauri/src/frame_loop.rs ~715) and the button state (platform::buttons_down(), ~825), then works out press and release by comparing with the previous tick (~828). The per-OS listeners never give the loop their events:
- X11: the XI2 listener wakes the loop and stores a press position (
platform/x11/input_events.rspress_point). - macOS: the event tap wakes the loop on the same
input_eventschannel once Input Monitoring is on. - Windows:
input_eventsis alwaysNone. #2107 added aWH_MOUSE_LLhook on a second channel (press_wakes), plusplatform/press_origin.rs(a stored press with a 2 s expiry) andresolving_press(cfg!(not(unix)), ~2213), which keeps Windows on the 16 ms clock until a press resolves.
So every OS that sleeps between ticks needs its own way to recover where a press really happened. That is how #2057 came about, and #2107 patched it for Windows only. The result is per-OS press-origin code, a consuming once-per-tick buttons_down() read ("a second read eats the edge"), and cfg branches spread through the shared frame loop.
Proposal
Have each OS deliver one ordered stream of input events through a single platform interface: press and release (with button and position) and motion (with position). The core consumes each event as it happens instead of comparing tick snapshots. The shared frame loop has no cfg branches for input, and the idle loop blocks on that stream instead of polling with back-off.
Once that lands, delete press_point, press_origin.rs, the separate Windows press_wakes channel, resolving_press, and the cfg(not(unix)) input sites in frame_loop.rs. Pointer::began_at in crates/core/src/input.rs stays and is fed from the event position.
Wayland has no global listener, and macOS has none until Input Monitoring is granted. They keep polling, but the poller should go through the same interface and emit synthesized events, so the core sees one shape either way.
Measure first
Windows currently listens for button edges only. Feeding it motion through the hook means every mouse move on the system goes through fidget's hook thread. Before building, measure fidget's CPU use and wakeups with a motion-reporting hook against today's back-off polling, on DESKTOP-UQIE144, while the sprite is idle and the mouse is moving. Also confirm the hook callback stays far below the LowLevelHooksTimeout limit, so Windows never drops the hook silently. If motion through the hook costs too much, the fallback is the same event interface with Windows sending button events plus a throttled motion sample.
Done when
- One platform input-event interface. X11, macOS (tap), Windows (hook) and the polling fallback all feed it, and the frame loop has no input
cfgbranches. - The listed press-origin machinery is deleted, and hit-testing and drag travel use the position carried by the press event.
- The Windows motion cost is measured and recorded in the PR.
-
quick-grabpasses on e2e-windows, and the existing X11 and macOS grab and poke scenarios pass live.
— Cursor agent (Architect), on @omesser's behalf.
Metadata
Metadata
Assignees
Labels
Projects
- StatusShow more project fieldsTodo
Activity