Fix Windows maximize geometry at high DPI - #18254
Open
nx111 wants to merge 1 commit into
Open
Conversation
On Windows, DWM can report stale or out-of-range extended frame bounds during maximize and DPI transitions. Applying those values unconditionally can distort the working area and preserve stale startup geometry. Validate the reported extended frame before using it, avoid recalculating geometry after native maximize has selected the work-area rectangle, and ignore suggested WM_DPICHANGED rectangles while maximized or fullscreen. This keeps native maximize and monitor-DPI transitions under Windows control without changing normal windowed resizing.
kasper93
reviewed
Jul 11, 2026
| &frame, sizeof(RECT)) == S_OK && | ||
| rect_w(frame) > 0 && rect_h(frame) > 0 && | ||
| frame.left >= wnd_rect->left && frame.top >= wnd_rect->top && | ||
| frame.right <= wnd_rect->right && frame.bottom <= wnd_rect->bottom) |
kasper93
reviewed
Jul 11, 2026
| // Native maximize has already selected the work-area rectangle. | ||
| // Re-entering geometry calculation here can overwrite it with | ||
| // stale startup bounds, especially on a high-DPI display. | ||
| if (wParam != SIZE_MAXIMIZED) { |
Member
There was a problem hiding this comment.
Won't it break the maximize state change in general, it won't trigger resize anymore, so title bar size will not be recalculated.
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.
Problem
On Windows with PerMonitorV2 and fractional display scaling,
WM_SIZEandWM_DPICHANGEDcan arrive after the operating system has already selected thenative maximized geometry.
mpv may then recalculate the window using stale startup geometry. At the same
time, DWM can return invalid extended frame bounds, and applying the suggested
WM_DPICHANGEDrectangle while maximized or fullscreen can disturb the nativewindow state.
This can leave a maximized window offset from the monitor work area or with
blank margins around the content.
Changes
SIZE_MAXIMIZED.WM_DPICHANGEDrectangle while maximized or fullscreen.This keeps native maximize and DPI transitions under Windows control while
preserving the existing behavior for normal windowed resizing.
Testing
3840x2160 display and 250% scaling.