Resize the window when the screen's dpi changes
That's what the MSDN documentation say one should do in the handler for WM_DPICHANGED [ChangeLog][QtGui][Windows] Windows are now automatically resized when they are moved on a screen to adapt to the new pixel ratio. Task-number: QTBUG-55510 Task-number: QTBUG-48242 Change-Id: I7688f12165f76585d75686e2e94b0fc562627be2 Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
This commit is contained in:
parent
2b34aefcf0
commit
cd2b5f1ada
@ -56,6 +56,10 @@
|
|||||||
# define WM_GESTURE 0x0119
|
# define WM_GESTURE 0x0119
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifndef WM_DPICHANGED
|
||||||
|
# define WM_DPICHANGED 0x02E0
|
||||||
|
#endif
|
||||||
|
|
||||||
QT_BEGIN_NAMESPACE
|
QT_BEGIN_NAMESPACE
|
||||||
|
|
||||||
namespace QtWindows
|
namespace QtWindows
|
||||||
@ -96,6 +100,7 @@ enum WindowsEventType // Simplify event types
|
|||||||
FocusInEvent = WindowEventFlag + 17,
|
FocusInEvent = WindowEventFlag + 17,
|
||||||
FocusOutEvent = WindowEventFlag + 18,
|
FocusOutEvent = WindowEventFlag + 18,
|
||||||
WhatsThisEvent = WindowEventFlag + 19,
|
WhatsThisEvent = WindowEventFlag + 19,
|
||||||
|
DpiChangedEvent = WindowEventFlag + 21,
|
||||||
MouseEvent = MouseEventFlag + 1,
|
MouseEvent = MouseEventFlag + 1,
|
||||||
MouseWheelEvent = MouseEventFlag + 2,
|
MouseWheelEvent = MouseEventFlag + 2,
|
||||||
CursorEvent = MouseEventFlag + 3,
|
CursorEvent = MouseEventFlag + 3,
|
||||||
@ -266,6 +271,8 @@ inline QtWindows::WindowsEventType windowsEventType(UINT message, WPARAM wParamI
|
|||||||
#endif
|
#endif
|
||||||
case WM_GESTURE:
|
case WM_GESTURE:
|
||||||
return QtWindows::GestureEvent;
|
return QtWindows::GestureEvent;
|
||||||
|
case WM_DPICHANGED:
|
||||||
|
return QtWindows::DpiChangedEvent;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -1088,6 +1088,15 @@ bool QWindowsContext::windowsProc(HWND hwnd, UINT message,
|
|||||||
return true;
|
return true;
|
||||||
#endif
|
#endif
|
||||||
} break;
|
} break;
|
||||||
|
case QtWindows::DpiChangedEvent: {
|
||||||
|
platformWindow->setFlag(QWindowsWindow::WithinDpiChanged);
|
||||||
|
const RECT *prcNewWindow = reinterpret_cast<RECT *>(lParam);
|
||||||
|
SetWindowPos(hwnd, NULL, prcNewWindow->left, prcNewWindow->top,
|
||||||
|
prcNewWindow->right - prcNewWindow->left,
|
||||||
|
prcNewWindow->bottom - prcNewWindow->top, SWP_NOZORDER | SWP_NOACTIVATE);
|
||||||
|
platformWindow->clearFlag(QWindowsWindow::WithinDpiChanged);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
#if !defined(QT_NO_SESSIONMANAGER)
|
#if !defined(QT_NO_SESSIONMANAGER)
|
||||||
case QtWindows::QueryEndSessionApplicationEvent: {
|
case QtWindows::QueryEndSessionApplicationEvent: {
|
||||||
QWindowsSessionManager *sessionManager = platformSessionManager();
|
QWindowsSessionManager *sessionManager = platformSessionManager();
|
||||||
|
@ -2114,8 +2114,12 @@ void QWindowsWindow::setFrameStrutEventsEnabled(bool enabled)
|
|||||||
|
|
||||||
void QWindowsWindow::getSizeHints(MINMAXINFO *mmi) const
|
void QWindowsWindow::getSizeHints(MINMAXINFO *mmi) const
|
||||||
{
|
{
|
||||||
|
// We don't apply the min/max size hint as we change the dpi, because we did not adjust the
|
||||||
|
// QScreen of the window yet so we don't have the min/max with the right ratio
|
||||||
|
if (!testFlag(QWindowsWindow::WithinDpiChanged)) {
|
||||||
const QWindowsGeometryHint hint(window(), m_data.customMargins);
|
const QWindowsGeometryHint hint(window(), m_data.customMargins);
|
||||||
hint.applyToMinMaxInfo(m_data.hwnd, mmi);
|
hint.applyToMinMaxInfo(m_data.hwnd, mmi);
|
||||||
|
}
|
||||||
|
|
||||||
if ((testFlag(WithinMaximize) || (window()->windowState() == Qt::WindowMinimized))
|
if ((testFlag(WithinMaximize) || (window()->windowState() == Qt::WindowMinimized))
|
||||||
&& (m_data.flags & Qt::FramelessWindowHint)) {
|
&& (m_data.flags & Qt::FramelessWindowHint)) {
|
||||||
|
@ -205,7 +205,8 @@ public:
|
|||||||
MaximizeToFullScreen = 0x80000,
|
MaximizeToFullScreen = 0x80000,
|
||||||
InputMethodDisabled = 0x100000,
|
InputMethodDisabled = 0x100000,
|
||||||
Compositing = 0x200000,
|
Compositing = 0x200000,
|
||||||
HasBorderInFullScreen = 0x400000
|
HasBorderInFullScreen = 0x400000,
|
||||||
|
WithinDpiChanged = 0x800000,
|
||||||
};
|
};
|
||||||
|
|
||||||
QWindowsWindow(QWindow *window, const QWindowsWindowData &data);
|
QWindowsWindow(QWindow *window, const QWindowsWindowData &data);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user