Skip to content

macOS: Mouse confined to main display when streaming a secondary monitor #134

Description

@ethanlee16

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@cb72dff
  • 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 6fdb8bd.

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

class MacosInputState {

Mouse coordinate clamping

OperationStatus post_mouse(

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions