From 5aba16a7ceff07b3381510f8138b7aef8f06ee85 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Tue, 2 Jun 2026 03:34:42 +0200 Subject: [PATCH] Decrease the size of non-resizeable TLWs on DPI change We avoid decreasing the size of the TLW on DPI change to preserve the user-set size, but this logic doesn't apply to non-resizeable windows as the user couldn't have changed their size, so do shrink them. Closes #26485. --- src/msw/nonownedwnd.cpp | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/msw/nonownedwnd.cpp b/src/msw/nonownedwnd.cpp index 0b4684ce32..4897cb1c83 100644 --- a/src/msw/nonownedwnd.cpp +++ b/src/msw/nonownedwnd.cpp @@ -311,7 +311,17 @@ bool wxNonOwnedWindow::HandleDPIChange(const wxSize& newDPI, const wxRect& newRe { const wxSize minSize = ClientToWindowSize(sizer->GetMinSize()); wxSize diff = minSize - newRect.GetSize(); - diff.IncTo(wxSize(0, 0)); + + // We don't want to shrink the window as if the user had increased + // it beyond its minimum size, we should not make it smaller again + // just because the DPI has changed, but if the window is not + // resizeable, then we do want to make it exactly of its minimum + // size because the user couldn't resize it and making it bigger + // than needed would just show unnecessary extra empty space. + if ( HasFlag(wxRESIZE_BORDER) ) + { + diff.IncTo(wxSize(0, 0)); + } // Use wxRect::Inflate() to ensure that the center of the bigger // rectangle is at the same position as the center of the proposed