Skip to content

fix(hook): normalize Windows cursor position to DIP scale - #1246

Open
fly530 wants to merge 1 commit into
AprilNEA:masterfrom
fly530:fix/windows-ring-dpi-scaling
Open

fix(hook): normalize Windows cursor position to DIP scale#1246
fly530 wants to merge 1 commit into
AprilNEA:masterfrom
fly530:fix/windows-ring-dpi-scaling

Conversation

@fly530

@fly530 fly530 commented Sep 2, 2026

Copy link
Copy Markdown

Summary

Actions Ring overlay drifted away from the cursor on Windows displays scaled above 100% (e.g. 150%), while it stayed centered at 100%.

Changes

  • openlogi-hook: cursor_position() on Windows resolves the cursor's monitor via MonitorFromPoint and divides the raw GetCursorPos physical-pixel result by that monitor's GetDpiForMonitor scale factor, returning DIP coordinates that match GPUI's own (already logical) display bounds — the same resolution-independent space macOS/Linux already report.

Testing

  • cargo check -p openlogi-hook
  • cargo clippy -p openlogi-hook --all-targets -- -D warnings
  • cargo test -p openlogi-hook (20 passed)
  • cargo fmt --all -- --check
  • Hardware-verified: built openlogi-desktop/openlogi-agent/openlogi-overlay in release and confirmed the Actions Ring stays centered on the cursor at 150% Windows display scaling.

GetCursorPos reports physical pixels, but the overlay matches it
against GPUI's own display bounds, which are logical (DIP) pixels on
Windows. At 100% scaling the two happen to coincide, but at any other
scale factor the mismatch pushes the Actions Ring off the cursor.

cursor_position() now resolves the cursor's monitor via
MonitorFromPoint and divides by its GetDpiForMonitor scale factor
before returning, matching the resolution-independent points macOS
and Linux already report.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_018w4EfPAZ6Xus9sGMS3V87K
@greptile-apps

greptile-apps Bot commented Sep 2, 2026

Copy link
Copy Markdown

Greptile Summary

This PR converts Windows cursor coordinates from physical pixels to display-independent coordinates using the effective DPI of the cursor’s monitor.

  • Enables the required Windows GDI and HiDPI API bindings.
  • Resolves the cursor’s monitor and queries its effective DPI.
  • Falls back to the default 96 DPI when the query fails or returns invalid values.
  • Documents the cross-platform logical-coordinate contract for CursorPosition.

Confidence Score: 5/5

The PR appears safe to merge, with no concrete blocking or independently actionable non-blocking issue identified.

The changed Windows path validates cursor and DPI API results, preserves a safe 96-DPI fallback, and returns coordinates in the logical space documented for existing overlay consumers.

Important Files Changed

Filename Overview
crates/openlogi-hook/src/windows.rs Normalizes Windows cursor coordinates using the containing monitor’s effective DPI, with validation and a 96-DPI fallback; no concrete changed-code failure was established.
crates/openlogi-hook/src/lib.rs Clarifies that cursor positions use the logical coordinate space expected by GPUI consumers.
crates/openlogi-hook/Cargo.toml Enables the windows-sys GDI and HiDPI features required by the new monitor DPI calls.

Reviews (1): Last reviewed commit: "fix(hook): normalize Windows cursor posi..." | Re-trigger Greptile

@davidbudnick davidbudnick added type: bug Something is broken or behaves incorrectly platform: windows Windows-specific issue labels Sep 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

platform: windows Windows-specific issue type: bug Something is broken or behaves incorrectly

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants