From e8a474ba7d277d8c72cf2085dd94414eb485f7c4 Mon Sep 17 00:00:00 2001 From: Momoyama Date: Mon, 25 May 2026 03:33:25 +0800 Subject: [PATCH] fix(macos): warp cursor to center on leave to fix first-move jump When macOS is the primary screen, hotkey switching to a secondary screen can leave the local cursor baseline away from the hidden-cursor center. The first physical mouse movement is then interpreted as a large secondary-screen delta. Align macOS primary leave behavior with the Windows and X11 implementations by logging and warping the cursor to the primary-screen center before marking the screen off screen. OSXScreen::warpCursor also updates m_xCursor and m_yCursor, so the next motion delta starts from the expected center baseline. Impact is limited to macOS primary/server leave handling; macOS secondary/client leave behavior and non-macOS builds are unchanged. --- src/lib/platform/OSXScreen.mm | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/lib/platform/OSXScreen.mm b/src/lib/platform/OSXScreen.mm index 04c5d920a..12c04e668 100644 --- a/src/lib/platform/OSXScreen.mm +++ b/src/lib/platform/OSXScreen.mm @@ -798,6 +798,8 @@ void OSXScreen::leave() if (m_isPrimary) { avoidHesitatingCursor(); + LOG_VERBOSE("centering cursor on leave: %+d, %+d", m_xCenter, m_yCenter); + warpCursor(m_xCenter, m_yCenter); } // now off screen