Repository navigation
fix(macos): recover cursor stranded off-screen after display change - #522
Open
ShimmerGlass wants to merge 2 commits into
Open
ShimmerGlass wants to merge 2 commits into
ShimmerGlass wants to merge 2 commits into
Conversation
When the display configuration changes, the cursor can end up at a position not covered by any active display. clamp_to_screen_space then failed to find the current display, logged "could not get current display!" and returned the position unchanged, so every subsequent motion event was dropped and the cursor stayed stuck. Fall back to the nearest active display so the cursor is clamped back onto a valid screen. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Extract the selection logic into a pure nearest_display function taking display bounds so it can be tested without real displays. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
I believe this fixes another issue I found when using lan-mouse between 2 mac's, but I'll test. Essentially, the mouse jumps to the left portion of the client screen after crossing from the server. I can go back to the other machine, but the right portion of the client's screen remains an area that I can't interact with the mouse, until I restart lan mouse on the client. |
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.
Summary
When the macOS display configuration changes while a remote client is controlling the Mac, the cursor can be left at a position that no active display covers.
clamp_to_screen_spaceininput-emulation/src/macos.rsthen can't find the current display. It logscould not get current display!and returns the position unchanged. Every later motion event hits the same path, so:This PR adds
get_nearest_display: when the cursor isn't on any display, it picks the closest active display (fromCGDisplay::active_displays()). The cursor is then clamped onto that display, so the next motion moves it back on screen. The warning remains only for the case where macOS reports no active displays at all.Related: #487 handles display hotplug on the capture side (
input-capture/src/macos.rs). This PR fixes the emulation side, and the two don't overlap.Testing
cargo fmt,cargo clippy -p input-emulation --all-targets(no new warnings),cargo buildnearest_display(selection logic extracted into a pure function over display bounds): no displays, point on a display, exclusive max edge, cursor left on a removed display, point off a corner.cargo test -p input-emulationpasses.🤖 Generated with Claude Code