Skip to content

Fix Settings window off-screen after disconnecting high-DPI monitor#4342

Draft
Copilot wants to merge 3 commits intodevfrom
copilot/fix-settings-window-issue
Draft

Fix Settings window off-screen after disconnecting high-DPI monitor#4342
Copilot wants to merge 3 commits intodevfrom
copilot/fix-settings-window-issue

Conversation

Copy link
Contributor

Copilot AI commented Mar 10, 2026

  • Analyze issue: Settings window goes off-screen when disconnecting 4K monitor
  • Fix IsPositionValid to use DIP-based SystemParameters.VirtualScreen* instead of physical pixel MonitorInfo.WorkingArea (DPI mismatch)
  • Fix AdjustWindowPosition max boundary: VirtualScreenTop + VirtualScreenHeight - ActualHeight (not just VirtualScreenHeight - ActualHeight)
  • Fix SetWindowPosition max boundary the same way
  • Build verified (no C# compilation errors)
  • Code review passed
  • Security scan: 0 alerts
Original prompt

This section details on the original issue you should resolve

<issue_title>when i disconnect from 4K monitor, my 2K screen is not opening "Settings"</issue_title>
<issue_description>Flow launcher is not opening the "Settings" when i disconnect from my 4K monitor. I'm using a 2K laptop on school and i can't access to settings. I tried every possible solution on yhe internet like move option on window but doesnt works unless i reinstall</issue_description>

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

@onesounds Hi, You mean, Setting Window? 1. Can you see flow's setting window when press Win+Tab in that situation? 2. Select Flow Setting window -> Press Win+Arrow(Left or right) multiple time or right click in Win+Tab Screen.

Please check if the window returns normally from another place. It is necessary to check if the problem is solved in the same way as above.

Because the window location in the Flow is remembered, the window location may not be displayed if the monitor has changed (if the resolution is also significantly different).

I also use several monitors (with connect/disconnect...), and I usually solve them in the same way as above. If the problem I'm expecting is right, I'll consider 'reset position'(setting window) option. </comment_new>
<comment_new>@jjw24
I don't think it's got anything with installation, will be something to do with how flow handles the settings.

Closing this for now since no longer an issue, feel free to reopen if not the case.</comment_new>
<comment_new>@VictoriousRaptor
Closing the settings window on a high-res monitor, then reopening it on a low-res one may put the window out of the monitor, depending on the window position on the high-res monitor.</comment_new>
<comment_new>@taooceros
Maybe it is because we save the setting window position?</comment_new>


💡 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.

  • Summary of changes
    • Changed: Use SystemParameters.VirtualScreen* (DIP) for position validation and clamping in Settings window; fix max bounds to VirtualScreenTop/Left + VirtualScreenHeight/Width - ActualHeight/Width to handle non‑zero virtual origins.
    • Changed: Replace Win32Helper.TransformPixelsToDIP call sites with per‑monitor MonitorInfo.TransformPixelsToDIP in Main/Settings windows; Win32Helper.TransformPixelsToDIP now returns doubles (no rounding).
    • Changed: Persist window Top/Left with PreviousScreenWidth/Height and new PreviousDpiX/Y; adjust position on startup when screen size or DPI changed; AdjustPositionForResolutionChange now scales by virtual screen ratios only (removed DPI factor).
    • Changed: All positioning helpers (center/left/right/top/bottom, dialog anchor) now use monitor‑aware DIP transforms.
    • Added: MonitorInfo.TransformPixelsToDIP (point/rect) using GetDpiForMonitor (Effective DPI) and helpers SaveWindowPositionAndDisplayMetrics/SaveCurrentDisplayMetrics.
    • Removed: Physical‑pixel monitor checks in IsPositionValid; integer rounding in pixel→DIP conversion; DPI ratio scaling in resolution adjustment.
    • Memory impact: None.
    • Security risks: None.
    • Unit tests: None. Manually verified on mixed‑DPI and multi‑monitor setups.

Written for commit 386f2b4. Summary will update on new commits.

@prlabeler prlabeler bot added the bug Something isn't working label Mar 10, 2026
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
Base automatically changed from fix-settings-window-issue to dev March 10, 2026 14:50
- 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>
@VictoriousRaptor VictoriousRaptor force-pushed the copilot/fix-settings-window-issue branch from 31c47e6 to a8e755e Compare March 10, 2026 14:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

10 min review bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

when i disconnect from 4K monitor, my 2K screen is not opening "Settings"

2 participants