Skip to content

fix(windows): Hit-test a press where the button went down - #2107

Merged
omesser merged 4 commits into
mainfrom
cursor/fix-2057-windows-quick-grab-335f
Nov 5, 2026
Merged

omesser merged 4 commits into
mainfrom
cursor/fix-2057-windows-quick-grab-335f

Conversation

@omesser

@omesser omesser commented Nov 2, 2026 •

Copy link
Copy Markdown
Owner

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

  • Capture the button-down position in a Windows mouse hook and wake the idle loop on button edges.
  • Hit-test and measure drag travel from that position. An unresolved Windows press keeps the 16 ms clock until the gesture resolves. Motion keeps the existing idle polling caps.
  • Consume captured positions once and expire them after two seconds, so a dropped hook cannot keep aiming later clicks at an old position. Read the captured point when the button state reports a press.
  • Add and document 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_origin passes 7 tests, including consumed and expired origins.
  • cargo test -p fidget-core --lib input:: passes 28 tests, including travel from the captured press origin.
  • Pre-commit passes, including workspace clippy.
  • e2e-windows run 41925888003 passed quick-grab on windows-latest at a56c0eb4. The earlier run failed during tray warmup before a scenario started.

Closes #2057

— Cursor agent (Codex), on @omesser's behalf.

cursoragent and others added 2 commits November 2, 2026 18:30
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>
@omesser omesser added bug Something isn't working e2e-windows Run the live Windows e2e scenarios on this pull request windows Run the Windows compile job on this pull request labels Nov 2, 2026 — with Cursor
omesser

This comment was marked as outdated.

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>
@omesser omesser removed the e2e-windows Run the live Windows e2e scenarios on this pull request label Nov 2, 2026
@omesser omesser added the e2e-windows Run the live Windows e2e scenarios on this pull request label Nov 2, 2026 — with Cursor
omesser

This comment was marked as outdated.

@omesser omesser removed the e2e-windows Run the live Windows e2e scenarios on this pull request label Nov 2, 2026
@omesser omesser added the e2e-windows Run the live Windows e2e scenarios on this pull request label Nov 2, 2026 — with Cursor
omesser

This comment was marked as outdated.

@cursor

cursor Bot commented Nov 4, 2026

Copy link
Copy Markdown

Updated the verification line. e2e-windows run 41925888003 passed quick-grab on windows-latest at a56c0eb4.

— Cursor agent (Grok), on @omesser's behalf.

@omesser omesser left a comment

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 success at a56c0eb4c6fcbbf7f56e7c1712fde994c064f9a0, on windows-latest. Its log sets SCENARIOS: quick-grab, prints ok: press (512,675) on the sprite, cursor already (467,450), then PASS: evidence in ...fidget-scenario-quick-grab-20261104-223415 (1435ms) and quick-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 4eb6f391 before 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 omesser left a comment

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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:

  • PointerEdge and edge_of serve one caller. Six of the eight tests hang off PressRecord (store, expire, consume), which is the part that carries a rule; the enum is only a shape.
  • press_wakes is a second listener seam beside input_events, which stays None on 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_LL hook sits in the system input path. It is safe today (a mutex store, a non-blocking try_send, CallNextHookEx), and it has to stay that way, because a blocking call in heard would 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.

@omesser
omesser merged commit 901d4ad into main Nov 5, 2026
11 checks passed
@omesser
omesser deleted the cursor/fix-2057-windows-quick-grab-335f branch November 5, 2026 14:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working e2e-windows Run the live Windows e2e scenarios on this pull request windows Run the Windows compile job on this pull request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix(windows): A quick press-and-drag on a resting sprite can miss the Grab

2 participants