Repository navigation
fix(windows): Hit-test a press where the button went down - #2107
Conversation
A resting sprite's idle wait can be a second long, and the tick was hit-testing the cursor it found on waking. The hook records the button-down point, the same fact XI2 already returns from press_point. Co-authored-by: Oded Messer <odedmesser@gmail.com>
The back-off comment now matches the button wake. A press that is not yet a Grab stays on the active clock on Windows only. Co-authored-by: Oded Messer <odedmesser@gmail.com>
The quick-grab leaf looked for cursor( and the log writes cursor=, so it never kept a press whose cursor had already left. Travel now starts at that press point, which the hit-test was already using. Co-authored-by: Oded Messer <odedmesser@gmail.com>
|
Updated the verification line. e2e-windows run 41925888003 passed — Cursor agent (Grok), on @omesser's behalf. |
omesser
left a comment
There was a problem hiding this comment.
Soft CLEARED
Tip: a56c0eb4
CLEARED means this can merge. Both items from my last review are done, and the diff is unchanged since that review, so there is nothing new to check.
What changed since my review — the body only; the code is the same a56c0eb4 I read.
What is wrong — nothing.
Soft-FIX
- None.
Non-blocking
- None left. The body is one copy of Why / What changed / How to verify, and the sign-off is last.
Evidence I checked
- e2e-windows run 41925888003 is
successata56c0eb4c6fcbbf7f56e7c1712fde994c064f9a0, on windows-latest. Its log setsSCENARIOS: quick-grab, printsok: press (512,675) on the sprite, cursor already (467,450), thenPASS: evidence in ...fidget-scenario-quick-grab-20261104-223415 (1435ms)andquick-grab PASS. The press lands on the sprite before the cursor moves, which is the case this PR exists for. - The PR body cites that run at this tip and no longer cites 41508195877, which failed in tray warmup at
4eb6f391before any scenario ran. Coder's account of that run matches the log. cargo test -p fidget --bin fidget press_origin: 7 passed.cargo test -p fidget-core --lib input::: 28 passed.
— Cursor agent (Architect), on @omesser's behalf.
omesser
left a comment
There was a problem hiding this comment.
Soft CLEARED (unchanged)
Tip: a56c0eb4
Still CLEARED at this tip; this answers the "is all that new code necessary" question, not a new verdict.
Most of it, yes. The runtime side is about 185 lines of Rust, roughly half of it comments: a 43-line press record, a 69-line hook, ~45 lines in frame_loop.rs, and ~45 of glue across platform.rs and input.rs. The rest of the 550 is the 179-line Windows scenario and 8 unit tests.
It has to be an OS hook. A press that lands before a tick still has click-through on, so the webview never receives a pointerdown and overlay_primary stays silent, which is why the Shell's existing second witness cannot cover this case. Windows was also the only platform with no input seam: X11 has XI2, macOS has the event tap.
What is genuinely smaller than it looks, and one risk:
PointerEdgeandedge_ofserve one caller. Six of the eight tests hang offPressRecord(store, expire, consume), which is the part that carries a rule; the enum is only a shape.press_wakesis a second listener seam besideinput_events, which staysNoneon Windows. That is the honest choice once motion must not wake the loop, but the loop now has two receivers and two hung-up flags.- Risk: a
WH_MOUSE_LLhook sits in the system input path. It is safe today (a mutex store, a non-blockingtry_send,CallNextHookEx), and it has to stay that way, because a blocking call inheardwould stall the machine's mouse.
Non-blocking: WAKE is a OnceLock, so if the frame loop ever restarted, the new receiver would get no wakes and the old thread would stay hooked. There is one run_frame_loop call site today.
— Cursor agent (Architect), on @omesser's behalf.
Why
On Windows, the idle frame loop can sleep for a second. A user who presses a resting Character and immediately drags away can leave its bounds before the next tick. Hit-testing the later cursor position misses the Grab.
What changed
quick-grab.win.ps1. It presses and leaves the sprite without waiting for the hit-test flip, then checks the captured origin and ensuing Grab.How to verify
cargo test -p fidget --bin fidget press_originpasses 7 tests, including consumed and expired origins.cargo test -p fidget-core --lib input::passes 28 tests, including travel from the captured press origin.quick-grabon windows-latest ata56c0eb4. The earlier run failed during tray warmup before a scenario started.Closes #2057
— Cursor agent (Codex), on @omesser's behalf.