Skip to content

fix: restore the desk layout with the TV detached first - #134

Merged
lippdev merged 3 commits into
lippdev:mainfrom
nextestudios:fix/restore-layout-order
Oct 1, 2026
Merged

lippdev merged 3 commits into
lippdev:mainfrom
nextestudios:fix/restore-layout-order

Conversation

@nextestudios

Copy link
Copy Markdown
Contributor

Summary

After Back to the PC, the desk layout came back wrong: with two stacked monitors and the TV off, the second monitor ended up beside where it was (touching the first one diagonally) instead of right below it.

Cause: restore re-enabled every screen of the backup, including the ones that were off (the TV), applied the saved positions while the TV was still part of the desktop, and only detached the TV last. Windows keeps the positions around a screen that's on and re-flows the others when it leaves.

  • Only the screens that were on come back (monitorsToVerify); the ones that were off are detached before any position is applied (and not at all if the originals failed to come back, so the PC is never left without a picture).
  • The saved layout is then applied to a desktop that already has its final screens, checked against the backup (new pure DisplayIdentity.LayoutMismatches) and retried up to three times.
  • LoadLayout flushes the registry's display settings, which can bring a just-detached screen back. After it, anything meant to stay off that is on is detached again (two rounds), and if that moved the others the positions are set with a new CcdHelper.SetPositions: one CCD call that only touches active paths, so it never re-attaches a screen.
  • The log now lists the screens meant to stay off, says when one came back and when positions were off or fixed by CCD; a monitor with no current mode is logged instead of silently skipped.
  • docs/TESTING.md: a restore-layout checklist (stacked monitors + TV off, repeated cycles, a TV that was on before, an original screen that doesn't come back).

Validation

  • New DisplayIdentityTests: layout check passes when every screen is where it was, flags a screen that slid aside, one that is off/missing, and ignores backups without positions.
  • Verified on a real PC with 2 desk monitors + a TV (build from my fork): the layout comes back identical and the TV stays off.
  • App build and dotnet test are left to CI.

🤖 Generated with Claude Code

nextestudios and others added 3 commits September 30, 2026 23:43
Restore re-enabled every screen of the backup (including the ones that were
off, the TV), applied the saved positions, and only then detached the TV.
With the TV still part of the desktop, Windows kept the positions around it
and re-flowed the other screens when it left, so a screen could end up
beside where it was (stacked monitors sliding apart).

Now only the screens that were on come back, the ones that were off are
detached before any position is applied, and the saved layout is applied
to a desktop that already has its final screens. The result is checked
against the backup (new DisplayIdentity.LayoutMismatches) and retried up to
three times; if the original screens didn't come back the TV stays on so the
PC is never left without a picture. A monitor with no current mode is logged
instead of silently skipped.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
LoadLayout flushes the registry's display settings, which can bring a screen
that was just detached (the TV) back. After applying the layout, detach again
whatever should be off and is on, then put the positions back with CCD, which
only touches active screens and never re-attaches one. The log now says which
screens are meant to stay off and when one came back.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ No new issues found.

Reviewed changes The restore sequence and CCD position correction for returning to the desk display layout were reviewed, along with the associated tests, manual test checklist, and changelog entries.

  • Restore ordering Re-enables displays that were active in the backup, detaches previously-off displays before restoring positions, and retries when layout loading re-enables them.
  • Layout validation and correction Compares restored active-display positions with the backup and uses active-path CCD positioning when needed.
  • Coverage and documentation Adds pure layout mismatch tests and manual checks for display-topology restore scenarios.

Pullfrog  | View workflow run | Using GPT Luna | 𝕏

@lippdev
lippdev merged commit 6aa4ab5 into lippdev:main Oct 1, 2026
4 checks passed
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.

2 participants