summaryrefslogtreecommitdiffstats
path: root/src/plugins/platforms/windows/qwindowswindow.cpp
diff options
context:
space:
mode:
authorMorten Sørvig <morten.sorvig@qt.io>2022-06-13 17:33:16 +0200
committerTor Arne Vestbø <tor.arne.vestbo@qt.io>2022-06-16 23:01:04 +0200
commit077eddb3e1aaba1517d67e7c83574c16e971dc67 (patch)
tree55234b906d04bf1a6e1b3a0b7a02b839300cdac8 /src/plugins/platforms/windows/qwindowswindow.cpp
parent7037f4620fb59b669d32fbce0ef79aabe38a716a (diff)
Windows QPA: Update screen on child window DPI change
Windows does not send WM_DPICHANGED to child windows, which means that the normal DPI change handling code does not run for QWindows which are embedded in a foreign, non-Qt, window. Add code which handles WM_DPICHANGED_AFTERPARENT. This event is sent to all child windows, but not the top-level window. Call checkForScreenChanged() here, similar to what the WM_DPICHANGED code does. This commit does not add code to resize the child window, since it is uncertain if this is the responsibility of the window which receives WM_DPICHANGED, or of each child window. Done-with: Tor Arne Vestbø <tor.arne.vestbo@qt.io> Pick-to: 6.4 Task-number: QTBUG-103383 Change-Id: Icf85dd0afa806609dbbe0ffc36efbc5127962c39 Reviewed-by: <stefan.wastl@native-instruments.de> Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
Diffstat (limited to 'src/plugins/platforms/windows/qwindowswindow.cpp')
-rw-r--r--src/plugins/platforms/windows/qwindowswindow.cpp14
1 files changed, 12 insertions, 2 deletions
diff --git a/src/plugins/platforms/windows/qwindowswindow.cpp b/src/plugins/platforms/windows/qwindowswindow.cpp
index 61d512a33f..c953abbc61 100644
--- a/src/plugins/platforms/windows/qwindowswindow.cpp
+++ b/src/plugins/platforms/windows/qwindowswindow.cpp
@@ -2007,6 +2007,14 @@ void QWindowsWindow::handleDpiChanged(HWND hwnd, WPARAM wParam, LPARAM lParam)
}
}
+void QWindowsWindow::handleDpiChangedAfterParent(HWND hwnd)
+{
+ // FIXME: refactor, do we really need this?
+ setSavedDpi(GetDpiForWindow(hwnd));
+
+ checkForScreenChanged(QWindowsWindow::FromDpiChange);
+}
+
static QRect normalFrameGeometry(HWND hwnd)
{
WINDOWPLACEMENT wp;
@@ -2150,12 +2158,14 @@ static inline bool equalDpi(const QDpi &d1, const QDpi &d2)
void QWindowsWindow::checkForScreenChanged(ScreenChangeMode mode)
{
- if (parent() || QWindowsScreenManager::isSingleScreen())
+ if ((parent() && !parent()->isForeignWindow()) || QWindowsScreenManager::isSingleScreen())
return;
QPlatformScreen *currentScreen = screen();
+ auto topLevel = isTopLevel_sys() ? m_data.hwnd : GetAncestor(m_data.hwnd, GA_ROOT);
const QWindowsScreen *newScreen =
- QWindowsContext::instance()->screenManager().screenForHwnd(m_data.hwnd);
+ QWindowsContext::instance()->screenManager().screenForHwnd(topLevel);
+
if (newScreen == nullptr || newScreen == currentScreen)
return;
// For screens with different DPI: postpone until WM_DPICHANGE