Repository navigation
Fit the main window to the monitor's work area at startup - #4
Merged
Merged
Conversation
WPF sizes are DPI-scaled, so the nominal 1600x1000 window overflowed the screen at high display scaling (eg. 2560x1440 at 150% is ~1707x920 units), hiding the titlebar. On startup, shrink the window (and its minimum size, if needed) to fit the work area of its monitor, and center it there. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01KaEsnLMDyw72GZ8a6ZxAGq
Drop the MonitorFromWindow/GetMonitorInfo interop in favour of pure WPF, to keep the windowing code portable. Size and position are now set in the constructor, before the window is created. Caps the startup size at 80% of the work area. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01KaEsnLMDyw72GZ8a6ZxAGq
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.
Testers reported that on some displays the window opens bigger than the screen and the title bar can't be reached. One case was 2560×1440.
Cause
WPF sizes are in 1/96-inch units, and the display's scale setting multiplies them. The window's nominal size of 1600×1000 therefore grows with the scale. On 2560×1440 at 150%, the work area (the screen minus the taskbar) is only about 1707×928 units, so the window is too tall to fit.
CenterScreenthen centers it anyway, which puts the title bar above the top of the screen.Fix
New
WindowFitting.FitToWorkArea(). It is pure WPF, with no P/Invoke, so the code stays portable. The constructor calls it before the window is created. It:SystemParameters.WorkArea, the work area of the primary monitor, which is where new windows open by default;MinWidthandMinHeightwhen they're bigger than the work area, so a small, high-scale screen can't still clip the window;CenterScreen.Known limitation: on a multi-monitor setup where the app opens on a secondary screen with a different scale from the primary, the size is worked out from the primary screen. The first push on this PR handled that case with
MonitorFromWindowandGetMonitorInfo. That code was dropped in favour of portability.Expected sizes:
Testing
🤖 Generated with Claude Code
https://claude.ai/code/session_01KaEsnLMDyw72GZ8a6ZxAGq