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.
This commit is contained in:
Vadim Zeitlin
2026-06-02 03:34:42 +02:00
parent 0ce04fca49
commit 5aba16a7ce
+11 -1
View File
@@ -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