HiDPI: fix wrong window size after DPI change
Current code doesn't take the custom margins into account, it will cause windows with custom margins have wrong size after DPI change. Amends commit 2cfca7fd1911cc82a22763152c04c65bc05bc19a Change-Id: I80b01c030a63d02cf66f105785df7c3f590481b5 Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io> (cherry picked from commit 67284763e7ce0d12650b652e92dfd022a8affb1d) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
parent
08a0f332b5
commit
c3f04ebfa9
@ -1968,7 +1968,13 @@ void QWindowsWindow::handleDpiScaledSize(WPARAM wParam, LPARAM lParam, LRESULT *
|
||||
const qreal scale = QHighDpiScaling::roundScaleFactor(qreal(dpi) / QWindowsScreen::baseDpi) /
|
||||
QHighDpiScaling::roundScaleFactor(qreal(savedDpi()) / QWindowsScreen::baseDpi);
|
||||
const QMargins margins = QWindowsGeometryHint::frame(window(), style(), exStyle(), dpi);
|
||||
const QSize windowSize = (geometry().size() * scale).grownBy(margins);
|
||||
// We need to update the custom margins to match the current DPI, because
|
||||
// we don't want our users manually hook into this message just to set a
|
||||
// new margin, but here we can't call setCustomMargins() directly, that
|
||||
// function will change the window geometry which conflicts with what we
|
||||
// are currently doing.
|
||||
m_data.customMargins *= scale;
|
||||
const QSize windowSize = (geometry().size() * scale).grownBy(margins + customMargins());
|
||||
SIZE *size = reinterpret_cast<SIZE *>(lParam);
|
||||
size->cx = windowSize.width();
|
||||
size->cy = windowSize.height();
|
||||
|
Loading…
x
Reference in New Issue
Block a user