LizardByte / LizardByte/libvirtualhid
macOS: Mouse confined to main display when streaming a secondary monitor
Dieses Issue hat noch niemand übernommen.
- Vorherrschende Sprache
- C++
- Sterne
- 54
- Forks
- 15
- Ø Merge
- 11 Std. 32 Min.
- Gemergte PRs (30 T.)
- 34
Beschreibung
Describe the Bug
When streaming a secondary monitor (set in Sunshine config), keyboard input and mouse clicks work, but the cursor cannot move normally across the streamed display. It moves vertically along the left edge and appears pinned horizontally at x=0.
Switching between Moonlight’s relative and absolute mouse modes does not resolve the issue. I want to stream the secondary monitor without making it the macOS main display.
Expected Behavior
The cursor should be able to reach the entire streamed secondary display without changing which monitor is the macOS main display.
Actual behavior
Keyboard input and clicks reach the host. Mouse positioning is incorrect; in testing, the cursor becomes pinned to the streamed display’s left edge while still moving vertically.
Additional Context
Environment
- Sunshine: 2026.906.222525
- Commit: LizardByte/sunshine@cb72dffa3233c5815cd5ba88f09f049dd679ba75
- Installation: Homebrew, running as a user service
- Host: macOS Sonoma 14.8.5, Apple Silicon
- Client: Moonlight on macOS
- Capture: macOS screen capture
- Encoder: VideoToolbox
Suspected cause
The bundled libvirtualhid revision with my build of Sunshine is 6fdb8bd4de3b68d96c30e5303ac2ebb333c09746.
Its macOS backend initializes MacosInputState::display using CGMainDisplayID(). In post_mouse(), it clamps both mouse coordinates to CGDisplayBounds(state_->display). Both relative and absolute motion paths use this function.
This appears to constrain injected mouse movement to the main display rather than allowing movement on the selected secondary display.
Main-display initialization
https://github.com/LizardByte/libvirtualhid/blob/6fdb8bd4de3b68d96c30e5303ac2ebb333c09746/src/platform/macos/macos_backend.cpp#L384
Mouse coordinate clamping
https://github.com/LizardByte/libvirtualhid/blob/6fdb8bd4de3b68d96c30e5303ac2ebb333c09746/src/platform/macos/macos_backend.cpp#L684
Beitragsleitfaden
Erste Schritte
- Lies das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreib ins Issue, dass du es übernimmst — das erspart doppelte Arbeit.
- Forke das Repository und arbeite in einem Branch.
- Öffne einen Pull Request, der die Issue-Nummer nennt.
Rechercherichtung
Beginne in src/platform/macos/macos_backend.cpp bei der Initialisierung von MacosInputState::display nahe Zeile 384 und bei der Koordinatenbegrenzung in post_mouse() nahe Zeile 684. Reproduziere das Problem mit einem sekundären gestreamten Display und überprüfe, dass die Mauskoordinaten das ausgewählte Display abdecken, ohne das macOS-Hauptdisplay zu ändern.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Bewertung
- Tech-Stack
- cpp, macos
- Bereich
- desktop, operating-systems
- Issue-Typ
- Bug
- Schwierigkeit
- 3/5
- Geschätzter Aufwand
- 1-2 Tage
- Aktivitätsstatus
- Aktiv
- Klarheit
- Klar beschrieben
- Anfängerfreundlichkeit
- 78/100