fix(macOS): move the pointer once per relative packet - #5778
Open
RodrickOMG wants to merge 1 commit into
Open
RodrickOMG wants to merge 1 commit into
RodrickOMG wants to merge 1 commit into
Conversation
The libvirtualhid macOS backend performed three conflicting pointer updates per relative motion packet: a CGEvent carrying both an absolute location and kCGMouseEventDeltaX/Y (deltas run through pointer acceleration and were computed from the unclamped position), followed by CGWarpMouseCursorPosition(), which shifts the baseline the next packet reads. Relative motion therefore collapsed to near zero with visible jitter, while button and scroll events -- which are never warped -- kept working. Motion was also clamped to a single display. Resolve relative motion against the live cursor position and post exactly one event with no warp on top. Re-base on the server position only on the first packet or after a gap: CGEventGetLocation() reports what the window server has already committed, so re-reading it for every packet in a 500-1000 Hz burst makes each packet overwrite the previous one's movement. Accumulate the chain locally in between instead. Clamp to the full active-display layout, select the event type from the actual button state so drags keep working, and carry the live modifier flags so a drag started while holding Shift/Option/Ctrl keeps them on every motion event that follows the button press. Fall back to the libvirtualhid path when Accessibility is not granted, so behaviour there is unchanged. Windows and Linux are unaffected.
Member
|
I think you're trying to fix some of the same things as LizardByte/libvirtualhid#145 and #5739 Can you test #5739 ? |
|
Author
|
Thanks for the pointers! I looked into this on my setup (macOS, single display, Moonlight on Windows):
I haven't tested #5739 yet. |
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.




The libvirtualhid macOS backend performed three conflicting pointer updates per relative motion packet: a CGEvent carrying both an absolute location and kCGMouseEventDeltaX/Y (deltas run through pointer acceleration and were computed from the unclamped position), followed by CGWarpMouseCursorPosition(), which shifts the baseline the next packet reads. Relative motion therefore collapsed to near zero with visible jitter, while button and scroll events -- which are never warped -- kept working. Motion was also clamped to a single display.
Resolve relative motion against the live cursor position and post exactly one event with no warp on top. Re-base on the server position only on the first packet or after a gap: CGEventGetLocation() reports what the window server has already committed, so re-reading it for every packet in a 500-1000 Hz burst makes each packet overwrite the previous one's movement. Accumulate the chain locally in between instead.
Clamp to the full active-display layout, select the event type from the actual button state so drags keep working, and carry the live modifier flags so a drag started while holding Shift/Option/Ctrl keeps them on every motion event that follows the button press. Fall back to the libvirtualhid path when Accessibility is not granted, so behaviour there is unchanged.
Windows and Linux are unaffected.
Description
Screenshot
Issues Fixed or Closed
Roadmap Issues
Type of Change
Checklist
AI Usage
See our AI usage policy.