From d7bfbf3a13029e26145c64acfe2e5e09f6faba3f Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Thu, 6 Jul 2017 14:00:48 +0200 Subject: Windows QPA: Further restrict windows for WM_DPICHANGED Exclude popups among other non-applicable windows types from resizing in WM_DPICHANGED. When resizing was enabled for non-fixed size windows by c854fc5a6be1e94d2ea313a1d0ef637bc3df178f it turned out that context menus were truncated when moving an application from a high resolution to a low resolution monitor. Factor out a function to check for the applicable window types. Amends 886ce572d628e7cd98cc39edcc930ffae951e95e, c854fc5a6be1e94d2ea313a1d0ef637bc3df178f. Task-number: QTBUG-55510 Change-Id: I16fee07f3e11828848ec71cdceadff958cedb13a Reviewed-by: Alexandru Croitor --- src/plugins/platforms/windows/qwindowscontext.cpp | 26 ++++++++++++++++++++--- 1 file changed, 23 insertions(+), 3 deletions(-) diff --git a/src/plugins/platforms/windows/qwindowscontext.cpp b/src/plugins/platforms/windows/qwindowscontext.cpp index a042212dd3..7115d074c9 100644 --- a/src/plugins/platforms/windows/qwindowscontext.cpp +++ b/src/plugins/platforms/windows/qwindowscontext.cpp @@ -824,6 +824,27 @@ static inline QWindowsInputContext *windowsInputContext() return qobject_cast(QWindowsIntegration::instance()->inputContext()); } + +// Child windows, fixed-size windows or pop-ups and similar should not be resized +static inline bool resizeOnDpiChanged(const QWindow *w) +{ + bool result = false; + if (w->isTopLevel()) { + switch (w->type()) { + case Qt::Window: + case Qt::Dialog: + case Qt::Sheet: + case Qt::Drawer: + case Qt::Tool: + result = !w->flags().testFlag(Qt::MSWindowsFixedSizeDialogHint); + break; + default: + break; + } + } + return result; +} + /*! \brief Main windows procedure registered for windows. @@ -1106,9 +1127,8 @@ bool QWindowsContext::windowsProc(HWND hwnd, UINT message, #endif } break; case QtWindows::DpiChangedEvent: { - if (platformWindow->window()->flags().testFlag(Qt::MSWindowsFixedSizeDialogHint)) - return false; // Fixed-size window should not be resized - + if (!resizeOnDpiChanged(platformWindow->window())) + return false; platformWindow->setFlag(QWindowsWindow::WithinDpiChanged); const RECT *prcNewWindow = reinterpret_cast(lParam); SetWindowPos(hwnd, NULL, prcNewWindow->left, prcNewWindow->top, -- cgit v1.2.3