fix: restore the desk layout with the TV detached first - #134
Merged
Merged
Conversation
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>
Contributor
There was a problem hiding this comment.
✅ 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.
GPT Luna | 𝕏
lippdev
approved these changes
Oct 1, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

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.
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).DisplayIdentity.LayoutMismatches) and retried up to three times.LoadLayoutflushes 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 newCcdHelper.SetPositions: one CCD call that only touches active paths, so it never re-attaches a screen.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
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.dotnet testare left to CI.🤖 Generated with Claude Code