windows qpa: Handle invisible child windows gracefully on dpi changes

Fixes: QTBUG-96466
Pick-to: 6.2
Change-Id: I58d90e85b4bb837df2dc5fd89abe984dadcd468d
Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
This commit is contained in:
Oliver Wolff 2021-09-30 11:04:48 +02:00
parent 95ef193715
commit 8d6e825ddf

View File

@ -1474,6 +1474,8 @@ bool QWindowsContext::windowsProc(HWND hwnd, UINT message,
// Scale child QPlatformWindow size. Windows sends WM_DPICHANGE to top-level windows only. // Scale child QPlatformWindow size. Windows sends WM_DPICHANGE to top-level windows only.
for (QWindow *childWindow : platformWindow->window()->findChildren<QWindow *>()) { for (QWindow *childWindow : platformWindow->window()->findChildren<QWindow *>()) {
QWindowsWindow *platformChildWindow = static_cast<QWindowsWindow *>(childWindow->handle()); QWindowsWindow *platformChildWindow = static_cast<QWindowsWindow *>(childWindow->handle());
if (!platformChildWindow)
continue;
QRect currentGeometry = platformChildWindow->geometry(); QRect currentGeometry = platformChildWindow->geometry();
QRect scaledGeometry = QRect(currentGeometry.topLeft() * scale, currentGeometry.size() * scale); QRect scaledGeometry = QRect(currentGeometry.topLeft() * scale, currentGeometry.size() * scale);
platformChildWindow->setGeometry(scaledGeometry); platformChildWindow->setGeometry(scaledGeometry);