[PR #1225] [MERGED] Keep the pointer locked on macOS in first person #3432

Closed
opened 2026-11-03 04:09:29 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/horizon-rust/horizon/pull/1225
Author: @pirut
Created: 10/22/2026
Status: ✅ Merged
Merged: 10/22/2026
Merged by: @ludovic111

Base: main ← Head: claude/upstream-macos-pointer-lock


📝 Commits (1)

  • e01296f Keep the pointer locked on macOS when the game captures it

📊 Changes

1 file changed (+7 additions, -0 deletions)

View changed files

📝 crates/horizon-client/src/game.rs (+7 -0)

📄 Description

Requested by JR

What and why

On macOS the pointer is not locked to the window in first person: it moves freely across the screen and can leave the window.

Game::capture grabs with CursorGrabMode::Locked and then warps the pointer to the window centre. On macOS, winit 0.30's set_cursor_position ends with CGAssociateMouseAndMouseCursorPosition(true), which undoes the lock the grab just set. This warps before grabbing on macOS. Other platforms keep warping after the grab, since Wayland moves a pointer only while it is locked.

Fixes #1224

Vanilla reference

MouseHandler.grabMouse → InputConstants.grabOrReleaseMouse, which calls glfwSetCursorPos before glfwSetInputMode(GLFW_CURSOR, GLFW_CURSOR_DISABLED): the same warp-then-grab order this uses on macOS. No harness: pointer grabbing is windowing, not gameplay.

Self-check

pr_ready (tools/pr_ready.py --base FETCH_HEAD on Mac, against FETCH_HEAD at b88218d01, 3 min 34 s)

Check Result
Scope ✅ 1 files, +7 −0
Cargo.lock ✅ unchanged
Public tree ✅
Python tests ➖ no Python change
rustfmt ✅ (5 s)
clippy ✅ (1 min 12 s)
tests: horizon-client ✅ 1108 passed (2 min 10 s)
doc tests ✅ 0 passed (6 s)
tokens.css up to date ➖ theme untouched
launcher rustfmt ➖ launcher untouched
launcher clippy ➖ launcher untouched
launcher tests ➖ launcher untouched
Parity ➖ not run (no vanilla data here): CI's parity job picks the affected harnesses
Label player-facing: feature if players get something new, no label for a fix (release-now if urgent)

Built and unit-tested on macOS arm64 (Apple M4 Pro).

🤖 Generated with Claude Code


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/horizon-rust/horizon/pull/1225 **Author:** [@pirut](https://github.com/pirut) **Created:** 10/22/2026 **Status:** ✅ Merged **Merged:** 10/22/2026 **Merged by:** [@ludovic111](https://github.com/ludovic111) **Base:** `main` ← **Head:** `claude/upstream-macos-pointer-lock` --- ### 📝 Commits (1) - [`e01296f`](https://github.com/horizon-rust/horizon/commit/e01296f99b31b4085190557fdbacb9aa4ec96de4) Keep the pointer locked on macOS when the game captures it ### 📊 Changes **1 file changed** (+7 additions, -0 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-client/src/game.rs` (+7 -0) </details> ### 📄 Description <!-- claude-projects-attribution: {"github_login":"pirut"} --> _Requested by **JR**_ ## What and why On macOS the pointer is not locked to the window in first person: it moves freely across the screen and can leave the window. `Game::capture` grabs with `CursorGrabMode::Locked` and then warps the pointer to the window centre. On macOS, winit 0.30's `set_cursor_position` ends with `CGAssociateMouseAndMouseCursorPosition(true)`, which undoes the lock the grab just set. This warps before grabbing on macOS. Other platforms keep warping after the grab, since Wayland moves a pointer only while it is locked. Fixes #1224 ## Vanilla reference `MouseHandler.grabMouse` → `InputConstants.grabOrReleaseMouse`, which calls `glfwSetCursorPos` before `glfwSetInputMode(GLFW_CURSOR, GLFW_CURSOR_DISABLED)`: the same warp-then-grab order this uses on macOS. No harness: pointer grabbing is windowing, not gameplay. ## Self-check **pr_ready** (`tools/pr_ready.py --base FETCH_HEAD` on Mac, against FETCH_HEAD at b88218d01, 3 min 34 s) | Check | Result | | --- | --- | | Scope | ✅ 1 files, +7 −0 | | Cargo.lock | ✅ unchanged | | Public tree | ✅ | | Python tests | ➖ no Python change | | rustfmt | ✅ (5 s) | | clippy | ✅ (1 min 12 s) | | tests: horizon-client | ✅ 1108 passed (2 min 10 s) | | doc tests | ✅ 0 passed (6 s) | | tokens.css up to date | ➖ theme untouched | | launcher rustfmt | ➖ launcher untouched | | launcher clippy | ➖ launcher untouched | | launcher tests | ➖ launcher untouched | | Parity | ➖ not run (no vanilla data here): CI's parity job picks the affected harnesses | | Label | player-facing: `feature` if players get something new, no label for a fix (`release-now` if urgent) | Built and unit-tested on macOS arm64 (Apple M4 Pro). 🤖 Generated with [Claude Code](https://claude.com/claude-code) --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-11-03 04:09:29 +07:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
horizon-rust/horizon#3432
No description provided.