Skip to content

Keep the assigned monitor when a player is minimized or hidden - #19

Open
Harry3342138 wants to merge 1 commit into
twibster:mainfrom
Harry3342138:fix/minimized-window-monitor
Open

Harry3342138 wants to merge 1 commit into
twibster:mainfrom
Harry3342138:fix/minimized-window-monitor

Conversation

@Harry3342138

Copy link
Copy Markdown

Minimizing a player such as QQ Music can change its audio output: the minimized window has a tiny/off-screen rectangle, so FindMainWindowForProcess drops it and routing may fall back to the system default or another window, such as desktop lyrics.

This change retains the last known monitor while the tracked player window is minimized or hidden. Cold-start minimized windows are identified using GetWindowPlacement and located with MonitorFromWindow. Restored windows still follow normal dragging. Cached handles are checked against their owner, disconnected monitors get a nearest-monitor fallback, and sessions that disappear release their cached state.

Validation:

  • 16 deterministic checks link the production MonitorService and fake only the Win32 boundary. The original implementation failed the minimize/hide cases; the patch passes all checks.
  • 12 real Win32 checks passed on a Windows desktop with two monitors, including minimized startup, tray hiding, a lyrics window on the other display, and restore/move behavior.
  • Manually reproduced with QQ Music; both monitors now keep their assigned speaker after minimizing.
  • Release build passes without warnings. The deterministic suite is added to CI; the interactive native suite is documented for local use.

A window that is already fully hidden to the tray before ScreenSound observes it still has no remembered screen; restoring it once establishes the location.

@coderabbitai

coderabbitai Bot commented Sep 27, 2026

Copy link
Copy Markdown

Important

  • 🔍 Trigger review

This repository does not receive automatic reviews because it has fewer than 10 stars.

⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Advanced

Run ID: 37d423d2-a044-4551-9e3d-c5c9bb76444f


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant