summaryrefslogtreecommitdiffstats
path: root/src/gui/kernel/qguiapplication.cpp
diff options
context:
space:
mode:
authorMorten Johan Sørvig <morten.sorvig@qt.io>2021-06-22 09:18:13 +0200
committerMorten Johan Sørvig <morten.sorvig@qt.io>2021-08-06 13:02:44 +0200
commit6336b5350b68e6430a7585d6658a9d653689186f (patch)
treeae53accd525bc4268637435a9bdb3f28dab6b30e /src/gui/kernel/qguiapplication.cpp
parentf9883865606b7b31396f673fd07a163d911c61f5 (diff)
Improve WM_DPICHANGED handling
Resize QPlatformWindow on DPI change, so that QWindow size can stay approximately constant. For example, a 100x100 QWindow at 100% scaling will have a 100x100 QPlatformWindow. If the scaling is changed to 200% then the QPlatformWindow is resized to 200x200, while the size of the QWindow stays at at 100x100. In practice the QWindow size will also change slightly, due to inaccuracies in how we adjust for the size of the non-client window area. This will be addressed in a later commit. We can get DPI change independently of screen change, so no resizing should happen in screen change events. Disable the resize code in QGuiApplication for Q_OS_WIN, and remove the WithinDpiChanged flag. The new flow for handling DPI change is: 1) Send screen change (if any), so that the correct screen will be used when calculating scale factors during the following resize. 2) Resize the native window, which will trigger geometry change events, possibly also for the QWindow. 3) Resize child windows; WM_DPICHANGED is sent to top-level windows only. Fixes: QTBUG-89294 Pick-to: 6.2 Change-Id: I0e2d44bae72d20ebdafc3d410db7be9964ad851b Reviewed-by: Oliver Wolff <oliver.wolff@qt.io>
Diffstat (limited to 'src/gui/kernel/qguiapplication.cpp')
-rw-r--r--src/gui/kernel/qguiapplication.cpp7
1 files changed, 6 insertions, 1 deletions
diff --git a/src/gui/kernel/qguiapplication.cpp b/src/gui/kernel/qguiapplication.cpp
index e7bd2b8358..e966d7962f 100644
--- a/src/gui/kernel/qguiapplication.cpp
+++ b/src/gui/kernel/qguiapplication.cpp
@@ -2526,11 +2526,16 @@ void QGuiApplicationPrivate::processWindowScreenChangedEvent(QWindowSystemInterf
else // Fall back to default behavior, and try to find some appropriate screen
topLevelWindow->setScreen(nullptr);
}
- // we may have changed scaling, so trigger resize event if needed
+
+ // We may have changed scaling; trigger resize event if needed,
+ // except on Windows, where we send resize events during WM_DPICHANGED
+ // event handling. FIXME: unify DPI change handling across all platforms.
+#ifndef Q_OS_WIN
if (window->handle()) {
QWindowSystemInterfacePrivate::GeometryChangeEvent gce(window, QHighDpi::fromNativePixels(window->handle()->geometry(), window));
processGeometryChangeEvent(&gce);
}
+#endif
}
}