Skip to content

Fix remote trackpad cursor drifting on multi-display setups - #310

Open
hrsong99 wants to merge 1 commit into
sameerasw:mainfrom
hrsong99:fix/remote-cursor-multi-display
Open

hrsong99 wants to merge 1 commit into
sameerasw:mainfrom
hrsong99:fix/remote-cursor-multi-display

Conversation

@hrsong99

Copy link
Copy Markdown

Problem

With a second display attached, the Android trackpad (Remote Control) moves the Mac cursor in one direction only. In my case it went straight down no matter which way I swiped. The Android app sends correct mouse_move deltas; logcat shows positive and negative dx/dy.

simulateMouseRelativeMove converts NSEvent.mouseLocation to CoreGraphics coordinates with cachedScreenHeight, read once at launch from NSScreen.main (the focused screen). CoreGraphics global coordinates are relative to the primary display (NSScreen.screens[0]). When they differ (here: a 1080pt TV focused at launch, a 956pt built-in as primary), every event adds the 124pt height difference, which outweighs the real delta. simulateMouseClick has the same flaw with NSScreen.main, so clicks land off by the same amount.

Fix

Read the current position with CGEvent(source: nil)?.location, which is already in global CoreGraphics coordinates. That removes the conversion and the cached height. Net −6 lines in MacRemoteManager.swift.

Testing

  • I checked that CGEvent(source: nil)?.location matches (mouseLocation.x, screens[0].frame.height - mouseLocation.y) on a two-display setup.
  • I typechecked the changed file. I didn't do a full app build.
  • Workaround that confirms the cause: making the TV the primary display, so both heights match, makes the trackpad work.

🤖 Generated with Claude Code

The mouse move and click handlers flipped NSEvent.mouseLocation into
CoreGraphics coordinates using the height of NSScreen.main (cached once
at launch for moves). CoreGraphics global coordinates are relative to
the primary display, so when the focused screen at launch has a
different height than the primary one, every mouse_move adds that
height difference and the cursor slides in one direction (e.g. straight
down with a 1080pt TV next to a 956pt built-in display). Clicks land
off by the same amount.

Read the current position with CGEvent(source: nil)?.location, which is
already in global CoreGraphics coordinates.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

This branch has not been deployed

No deployments
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.

1 participant