Fix Settings window off-screen after disconnecting high-DPI monitor#4342
Draft
Fix Settings window off-screen after disconnecting high-DPI monitor#4342
Conversation
Copilot
AI
changed the title
[WIP] Fix Settings window not opening after disconnecting 4K monitor
Fix Settings window off-screen after disconnecting high-DPI monitor
Mar 10, 2026
- Fix IsPositionValid to use SystemParameters.VirtualScreen* (DIP units) instead of MonitorInfo.WorkingArea (physical pixels) to avoid DPI coordinate mismatch on high-DPI and mixed-DPI multi-monitor setups. - Fix AdjustWindowPosition and SetWindowPosition to correctly calculate the max boundary as VirtualScreenTop + VirtualScreenHeight - ActualHeight (was VirtualScreenHeight - ActualHeight), which incorrectly allowed windows to extend beyond the bottom/right edge when VirtualScreenTop or VirtualScreenLeft were non-zero (e.g., monitors above/left of primary). Co-authored-by: VictoriousRaptor <10308169+VictoriousRaptor@users.noreply.github.com>
31c47e6 to
a8e755e
Compare
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.
IsPositionValidto use DIP-basedSystemParameters.VirtualScreen*instead of physical pixelMonitorInfo.WorkingArea(DPI mismatch)AdjustWindowPositionmax boundary:VirtualScreenTop + VirtualScreenHeight - ActualHeight(not justVirtualScreenHeight - ActualHeight)SetWindowPositionmax boundary the same wayOriginal prompt
💡 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.
Summary by cubic
Prevents the Settings window from opening off-screen after disconnecting a high‑DPI monitor. Normalizes window math to DIP, clamps within the full virtual screen (including negative origins), and saves display metrics to recover safely after DPI/resolution changes.
SystemParameters.VirtualScreen*(DIP) for position validation and clamping in Settings window; fix max bounds toVirtualScreenTop/Left + VirtualScreenHeight/Width - ActualHeight/Widthto handle non‑zero virtual origins.Win32Helper.TransformPixelsToDIPcall sites with per‑monitorMonitorInfo.TransformPixelsToDIPin Main/Settings windows;Win32Helper.TransformPixelsToDIPnow returns doubles (no rounding).PreviousScreenWidth/Heightand newPreviousDpiX/Y; adjust position on startup when screen size or DPI changed;AdjustPositionForResolutionChangenow scales by virtual screen ratios only (removed DPI factor).MonitorInfo.TransformPixelsToDIP(point/rect) usingGetDpiForMonitor(Effective DPI) and helpersSaveWindowPositionAndDisplayMetrics/SaveCurrentDisplayMetrics.IsPositionValid; integer rounding in pixel→DIP conversion; DPI ratio scaling in resolution adjustment.Written for commit 386f2b4. Summary will update on new commits.