diff options
author | Morten Johan Sørvig <morten.sorvig@qt.io> | 2021-09-23 19:49:20 +0200 |
---|---|---|
committer | Morten Johan Sørvig <morten.sorvig@qt.io> | 2021-10-07 14:22:55 +0200 |
commit | 2cfca7fd1911cc82a22763152c04c65bc05bc19a (patch) | |
tree | 0dea6573ec3e63b9492cada670f9c31e05976a10 /src/plugins/platforms/windows/qwindowscontext.cpp | |
parent | cd96d870118d15734a61a019f69ef5f0269bbe05 (diff) |
Handle WM_GETDPISCALEDSIZE
By handling WM_GETDPISCALEDSIZE we can keep QWindow’s
device independent size constant across DPI changes.
This is done by scaling QPlatformWindow’s native size
such that the change of scale factor and change of
QPlatformWindow size cancels out.
Qt now handles DPI change using two events:
WM_GETDPISCALEDSIZE: Compute the new size for the window.
WM_DPICHANGED: Apply the new DPI and window geometry.
The reason for this complication is that Windows retains
control over the window position during the DPI change,
in order to e.g. accurately track the cursor position
during a screen change.
The default WM_GETDPISCALEDSIZE implementation (provided
by Windows) scales the win32 window size linearly with
the DPI change. We want to use linear scaling as well,
however the win32 window size includes the margins, which
do not change linearly as the DPI changes.
Instead, scale the QPlatformWindow size, and then add
the new margins.
Pick-to: 6.2
Change-Id: I4f225be8fad56b1fa77e9e3cfd6538a206589d73
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
Diffstat (limited to 'src/plugins/platforms/windows/qwindowscontext.cpp')
-rw-r--r-- | src/plugins/platforms/windows/qwindowscontext.cpp | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/src/plugins/platforms/windows/qwindowscontext.cpp b/src/plugins/platforms/windows/qwindowscontext.cpp index 91fb80dc28..1c75f7f7d2 100644 --- a/src/plugins/platforms/windows/qwindowscontext.cpp +++ b/src/plugins/platforms/windows/qwindowscontext.cpp @@ -1453,6 +1453,9 @@ bool QWindowsContext::windowsProc(HWND hwnd, UINT message, return true; #endif } break; + case QtWindows::DpiScaledSizeEvent: + platformWindow->handleDpiScaledSize(wParam, lParam, result); + return true; case QtWindows::DpiChangedEvent: platformWindow->handleDpiChanged(hwnd, wParam, lParam); return true; |