Skip to content

Follow the host cursor on cursor events - #142

Open
thtltntdmrhttn wants to merge 1 commit into
NearFrame:mainfrom
thtltntdmrhttn:host-cursor-position
Open

thtltntdmrhttn wants to merge 1 commit into
NearFrame:mainfrom
thtltntdmrhttn:host-cursor-position

Conversation

@thtltntdmrhttn

Copy link
Copy Markdown

What this does

Fixes #131.

With a mouse plugged into the host, the host's cursor moves but OpenParsec's cursor stays wherever touch last left it, and the next touch drags the real cursor back to that spot. handleCursorEvent only took the host's position when the cursor came back from hidden.

Now it takes the position from every absolute, visible cursor event, clamped to the frame. Two cases are skipped:

  • an event within 0.3s of our own sendMousePosition, since that is just our own move coming back
  • anything before setFrame has run for the connection, because the SDK has no dimensions to scale the position with yet (the reconnect path in ParsecView.swift re-sends them for the same reason)

The old prevHidden block is folded into this, so the position is set in one place.

One limit: the host only sends a cursor event when the pointer changes shape or visibility, not on every move (parsec.h describes CLIENT_EVENT_CURSOR as "a cursor mode change or image update"). So with a host mouse the cursor catches up in steps, each time it crosses a text field, a link or a window edge. It does not glide.

If you want the host's pointer to move smoothly, turn on "Display pointer trails" in the Windows mouse settings on the host. Windows then draws the pointer into the stream itself. That works without this change too, and might be worth a line in the README for anyone who lands on #75.

How you tested it

M1 iPad Pro 11", iPadOS 26.6.1, sideloaded builds of this change. Host is Windows 11 with Parsec 150-105c, streaming a virtual display at the iPad's resolution, with an MX Master 4 plugged into the host. Touchpad mode.

  • Host mouse: the cursor now jumps to where the host pointer is when the pointer changes shape. Before, it never moved.
  • Host mouse, then a tap or a drag from the iPad: lands where the cursor is drawn.
  • Finger only: same as before.
  • Mouse paired to the iPad over Bluetooth: same as before.
  • Pointer trails on the host: the host pointer shows in the stream and moves smoothly.

Not tested: a macOS host, a game that captures the pointer, Direct touch mode, and I didn't specifically check the cursor position after a reconnect.

Logs

None.

handleCursorEvent only took the host's position when the cursor came back from hidden, so a mouse plugged into the host left our cursor behind (NearFrame#131). take it on every absolute, visible cursor event instead, except right after our own move
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.

Client cursor doesn't follow host-driven mouse moves (mouse plugged into the host)

1 participant