LizardByte / LizardByte/libvirtualhid
macOS: Mouse confined to main display when streaming a secondary monitor
まだ誰も着手していません。
- 主要言語
- C++
- スター
- 54
- フォーク
- 15
- 平均マージ
- 11時間 32分
- マージ済み PR(30日)
- 34
説明
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
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
調査の方向性
src/platform/macos/macos_backend.cpp の、384 行目付近にある MacosInputState::display の初期化と、684 行目付近にある post_mouse() 内の座標のクランプから始めます。セカンダリのストリーミングされたディスプレイで再現し、macOS のメインディスプレイを変更せずに、マウス座標が選択したディスプレイ全体をカバーすることを確認します。
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- cpp, macos
- 領域
- desktop, operating-systems
- issue の種類
- バグ
- 難易度
- 3/5
- 見積もり時間
- 1〜2日
- 活発さ
- 活発
- 明瞭さ
- 明確に書かれている
- 初心者へのやさしさ
- 78/100