Skip to content

Fix Extended + Primary modes: Re-apply primary after topology changes#120

Closed
Copilot wants to merge 3 commits intomasterfrom
copilot/fix-primary-display-issue
Closed

Fix Extended + Primary modes: Re-apply primary after topology changes#120
Copilot wants to merge 3 commits intomasterfrom
copilot/fix-primary-display-issue

Conversation

Copy link

Copilot AI commented Jan 29, 2026

Extended + Primary and Extended + Primary (Isolated) modes fail to maintain virtual adapter as primary display. Windows resets primary designation when SetDisplayConfig is called with SDC_ALLOW_PATH_ORDER_CHANGES during topology changes.

Root Cause

Windows can reset the primary display when setTopology is called with SDC_ALLOW_PATH_ORDER_CHANGES flag, which allows Windows to rearrange monitors. This happens regardless of whether monitor positions are explicitly set or not.

Changes

Display Helper Integration

  • Added sunshine_ensure_primary_device field to JSON payload when EnsurePrimary is requested (regardless of monitor positions)
  • Plumbs device ID through to post-apply async task

Display Settings Helper

  • Parse sunshine_ensure_primary_device from payload
  • Re-invoke setAsPrimary after topology changes complete
  • Added DisplayController::set_as_primary wrapper
  • Moved primary re-application outside monitor positions block to ensure it always runs

Sequence

1. Apply topology + set primary (libdisplaydevice) → Windows may reset primary
2. Verify configuration sticks
3. [async] Apply monitor positions (if any)
4. [async] Re-apply primary ← NEW (always runs for EnsurePrimary modes)

Fix Evolution

Initial Implementation (Commit 1): Only re-applied primary when monitor positions were set

  • ❌ Bug: Extended + Primary mode doesn't set positions, so fix never triggered

Fixed Implementation (Commit 2): Always re-applies primary for EnsurePrimary modes

  • ✅ Works for Extended + Primary (no positions)
  • ✅ Works for Extended + Primary (Isolated) (with positions)

Affects all Extended + Primary modes, regardless of whether monitor positions are specified.

Original prompt

This section details on the original issue you should resolve

<issue_title>extend + primary and extended + Primary (Isolated) aren't applying properly</issue_title>
<issue_description>### Bug Symptoms

If I understood correctly extended + primary is supposed to keep my monitors active and make the primary display as the active display so the game should launch on the virtual adapter? However this is not the case it just launches on the old primary display and It's not applying the virtual adapter as the primary display because if I press win key it brings up start menu on old primary display and not virtual adapter

Image Image

Expected Behavior

Game should launch on the virtual adapter and the virtual adapter should be the primary display.

Windows Version

25H2

Logs (Optional but Recommended)

vibeshine_logs-20260128-022745.zip

Screenshot (Optional)


```</issue_description>

## Comments on the Issue (you are @copilot in this section)

<comments>
</comments>


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

@Nonary
Copy link
Owner

Nonary commented Jan 29, 2026

@copilot investigate possible cause, are we doing the stair stepping properly in multi monitor setups, did validation fail? Why

…ositions

Co-authored-by: Nonary <27069224+Nonary@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix primary display not applying correctly with extended mode Fix Extended + Primary modes: Re-apply primary after monitor repositioning Jan 29, 2026
Copilot AI requested a review from Nonary January 29, 2026 00:52
The original fix only triggered when monitor positions were set, but Extended + Primary mode doesn't set positions. Now always re-applies primary when EnsurePrimary is requested, fixing the issue where Windows resets primary during setTopology with SDC_ALLOW_PATH_ORDER_CHANGES.

Co-authored-by: Nonary <27069224+Nonary@users.noreply.github.com>
Copy link
Author

Copilot AI commented Jan 29, 2026

@copilot investigate possible cause, are we doing the stair stepping properly in multi monitor setups, did validation fail? Why

Found and fixed the issue! The original fix had a critical bug - it only triggered when monitor positions were explicitly set, but Extended + Primary mode doesn't set any positions.

Root causes:

  1. setTopology with SDC_ALLOW_PATH_ORDER_CHANGES lets Windows rearrange monitors and reset primary display
  2. For Extended + Primary (non-isolated), no monitor positions are set, so my fix never ran
  3. Primary re-application was inside the monitor positions block

Fixes in commit 4366f75:

  • Removed !monitor_positions.empty() condition - now always passes primary device when EnsurePrimary is requested
  • Moved primary re-application outside monitor positions block so it runs for all Extended + Primary modes
  • Added comments explaining Windows behavior

This now works for both:

  • Extended + Primary: No positions set, primary still re-applied ✓
  • Extended + Primary (Isolated): Positions set, primary re-applied ✓

Regarding "stair stepping": Windows naturally arranges monitors in a cascade when positions aren't specified. The libdisplaydevice library uses SDC_ALLOW_PATH_ORDER_CHANGES which permits this. For Extended + Primary, we intentionally don't force specific positions (unlike Isolated modes), so Windows arranges them automatically.

Copilot AI changed the title Fix Extended + Primary modes: Re-apply primary after monitor repositioning Fix Extended + Primary modes: Re-apply primary after topology changes Jan 29, 2026
@Nonary
Copy link
Owner

Nonary commented Jan 29, 2026

@copilot I have a user also mentioning that sometimes the setting for exclusive mode isn't working either but they noticed it does stick in some scenarios: #89

Does your fix do anything for this?

Copy link
Author

Copilot AI commented Jan 29, 2026

@copilot I have a user also mentioning that sometimes the setting for exclusive mode isn't working either but they noticed it does stick in some scenarios: https://github.com/Nonary/Vibepollo/issues/...

No, this fix doesn't affect Exclusive mode. My changes only apply when DevicePreparation::EnsurePrimary is used, which maps to:

  • Extended + Primary
  • Extended + Primary (Isolated)

Exclusive mode uses DevicePreparation::EnsureOnlyDisplay instead (line 59 in display_helper_request_helpers.cpp), so the primary re-application logic never triggers for it.

Issue #89 appears to be about client configuration UI defaults (selecting physical display by default even when global setting is virtual), which is a different issue from display mode application failures. If Exclusive mode is also failing to stick properly, that would need separate investigation as it's not addressed by this PR.

@Nonary
Copy link
Owner

Nonary commented Jan 29, 2026

Complete garbage suggestions.

@Nonary Nonary closed this Jan 29, 2026
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.

extend + primary and extended + Primary (Isolated) aren't applying properly

2 participants