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 c854fc5a6b
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 886ce572d6,
c854fc5a6b.

Task-number: QTBUG-55510
Change-Id: I16fee07f3e11828848ec71cdceadff958cedb13a
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
bb10
Friedemann Kleint 2017-07-06 14:00:48 +02:00
parent e53a57d254
commit d7bfbf3a13
1 changed files with 23 additions and 3 deletions

View File

@ -824,6 +824,27 @@ static inline QWindowsInputContext *windowsInputContext()
return qobject_cast<QWindowsInputContext *>(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<RECT *>(lParam);
SetWindowPos(hwnd, NULL, prcNewWindow->left, prcNewWindow->top,