From e01296f99b31b4085190557fdbacb9aa4ec96de4 Mon Sep 17 00:00:00 2001 From: Claude Date: Thu, 22 Oct 2026 13:47:37 +0000 Subject: [PATCH] Keep the pointer locked on macOS when the game captures it winit's macOS set_cursor_position re-associates the mouse with the pointer (CGAssociateMouseAndMouseCursorPosition(true)), so warping to the window centre right after the Locked grab released it again and the pointer moved freely in first person. Warp before grabbing on macOS; Wayland still warps after, since it moves a pointer only while locked. Co-Authored-By: Claude Opus 5.5 (1M context) Claude-Session: https://claude.ai/code/session_0188LkUPntcZdfMF3wAqR2tK --- crates/horizon-client/src/game.rs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/crates/horizon-client/src/game.rs b/crates/horizon-client/src/game.rs index f706e9348..1162be7e9 100644 --- a/crates/horizon-client/src/game.rs +++ b/crates/horizon-client/src/game.rs @@ -4485,10 +4485,17 @@ impl Game<'_> { }; if capture { self.mouse.set_ignore_first_move(); + // macOS warps by re-associating the mouse with the pointer, + // which undoes a Locked grab and leaves the pointer free: warp + // first there. Wayland moves a pointer only while it is locked, + // so everywhere else warp after grabbing. + #[cfg(target_os = "macos")] + warp(window); self.captured = window .set_cursor_grab(CursorGrabMode::Locked) .or_else(|_| window.set_cursor_grab(CursorGrabMode::Confined)) .is_ok(); + #[cfg(not(target_os = "macos"))] if self.captured && self.focused { warp(window); }