Skip to content

fix: cursor jumps to center of main display on multi-monitor macOS - #206

Open
BH3GEI wants to merge 1 commit into
symless:masterfrom
BH3GEI:fix/primary-enter-cursor-warp-race
Open

fix: cursor jumps to center of main display on multi-monitor macOS#206
BH3GEI wants to merge 1 commit into
symless:masterfrom
BH3GEI:fix/primary-enter-cursor-warp-race

Conversation

@BH3GEI

@BH3GEI BH3GEI commented Jun 16, 2026

Copy link
Copy Markdown

Summary

On a multi-monitor macOS setup (e.g. 3 screens), when switching back from a secondary machine to the primary (server) screen, the cursor sometimes jumps to the center of the main display instead of appearing at the correct position on the edge screen.

Root cause: In PrimaryClient::enter(), warpCursor(xAbs, yAbs) was called before m_screen->enter(mask). The warp generates a mouse-move event that is processed by OSXScreen::onMouseMove() while m_isOnScreen is still false, causing the cursor to be re-warped to m_xCenter/m_yCenter (center of the main display).

Fix: Swap the call order — call enter() first (which sets m_isOnScreen = true), then warpCursor(). This ensures the warp-generated mouse event is handled as a normal on-screen motion rather than triggering the off-screen re-centering logic.

Test plan

  • macOS server (3 monitors: 1 primary + 2 stacked right) + Windows client on right edge
  • Switch to Windows, move mouse around, switch back — cursor appears at correct edge position
  • Verified cursor no longer jumps to center of main display on return
  • Protocol version unchanged (v1.8), compatible with existing 1.14.x clients

When switching back to the primary (macOS) screen, the cursor would
jump to the center of the main display instead of appearing at the
correct edge position. This was caused by a race condition in
PrimaryClient::enter(): warpCursor() was called before enter(),
so the warp-generated mouse event was processed while m_isOnScreen
was still false, causing onMouseMove() to re-center the cursor.

Fix: call enter() before warpCursor() so m_isOnScreen is true
when the warp event arrives.
@nbolton

nbolton commented Jun 17, 2026

Copy link
Copy Markdown
Member

Thanks for the PR, I will review. Is this relevant to upstream Deskflow?

@sithlord48

Copy link
Copy Markdown
Contributor

It would as we are using the same logic here imho this should move to Deskflow.

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.

3 participants