8000 Fix macOS cursor grab warp position by 73v3 · Pull Request #629 · not-fl3/miniquad · GitHub
[go: up one dir, main page]

Skip to content

Fix macOS cursor grab warp position - #629

Merged
not-fl3 merged 1 commit into
not-fl3:masterfrom
73v3:fix-macos-cursor-grab-warp
May 20, 2026
Merged

not-fl3 merged 1 commit into
not-fl3:masterfrom
73v3:fix-macos-cursor-grab-warp

Conversation

@73v3
@73v3 73v3 commented May 18, 2026
Copy link
Copy Markdown
Contributor

Fixes incorrect cursor warp position on macOS when cursor grab is enabled.

Related Macroquad issue: not-fl3/macroquad#858

Problem

On macOS, enabling cursor grab can warp the cursor to an incorrect vertical position, often near the Dock/taskbar, instead of the center of the application content area.

The previous implementation computed the warp point from the outer NSWindow frame and then passed that through transform_mouse_point(). This mixes AppKit window/frame coordinates with CoreGraphics cursor-warp coordinates and can produce an incorrect Y position, especially for non-square windows.

Fix

Use the actual content view bounds, convert the view-center point through AppKit using convertPoint:toView: and convertRectToScreen:, then flip the Y coordinate for CoreGraphics before calling CGWarpMouseCursorPosition.

This avoids manually combining outer window frame coordinates, titlebar/border offsets, scale factors, and screen-space conversion.

Tested

Tested locally on macOS Apple Silicon with a Macroquad-based app using set_cursor_grab(true).

Before this patch:

  • enabling cursor grab warped the OS cursor near the Dock/taskbar;
  • first-person/camera-style mouse control was broken.

After this patch:

  • enabling cursor grab no longer moves the cursor to the Dock/taskbar area;
  • the cursor remains correctly positioned in the game view;
  • relative mouse/camera movement works correctly.

@not-fl3
not-fl3 commented May 20, 2026
Copy link
Copy Markdown
Owner

Thanks for PR!

@not-fl3
not-fl3 merged commit 1e38188 into not-fl3:master May 20, 2026
11 checks passed
@73v3
73v3 deleted the fix-macos-cursor-grab-warp branch May 20, 2026 19:34
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.

2 participants

0