diff options
author | Morten Johan Sørvig <morten.sorvig@qt.io> | 2021-06-25 13:14:13 +0200 |
---|---|---|
committer | Morten Johan Sørvig <morten.sorvig@qt.io> | 2021-08-06 13:02:44 +0200 |
commit | f9883865606b7b31396f673fd07a163d911c61f5 (patch) | |
tree | c657feec13012865628dc6f31149c000f6cf411d /src/plugins/platforms/windows/qwindowscontext.cpp | |
parent | 7d7b484429f2a8a23b0d15e5fbfca18f6553b1bf (diff) |
Track current window DPI
The WM_DPICHANGED event gives us the new DPI, but we
also need the current DPI in order to determine the
scale factor corresponding to the DPI change.
Pick-to: 6.2
Change-Id: Ia61388415f57aa739397d3125b8751952e8fd392
Reviewed-by: Oliver Wolff <oliver.wolff@qt.io>
Diffstat (limited to 'src/plugins/platforms/windows/qwindowscontext.cpp')
-rw-r--r-- | src/plugins/platforms/windows/qwindowscontext.cpp | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/src/plugins/platforms/windows/qwindowscontext.cpp b/src/plugins/platforms/windows/qwindowscontext.cpp index 983fc9d47b..f24ab02b87 100644 --- a/src/plugins/platforms/windows/qwindowscontext.cpp +++ b/src/plugins/platforms/windows/qwindowscontext.cpp @@ -218,6 +218,7 @@ void QWindowsUser32DLL::init() getWindowDpiAwarenessContext = (GetWindowDpiAwarenessContext)library.resolve("GetWindowDpiAwarenessContext"); getAwarenessFromDpiAwarenessContext = (GetAwarenessFromDpiAwarenessContext)library.resolve("GetAwarenessFromDpiAwarenessContext"); systemParametersInfoForDpi = (SystemParametersInfoForDpi)library.resolve("SystemParametersInfoForDpi"); + getDpiForWindow = (GetDpiForWindow)library.resolve("GetDpiForWindow"); } } @@ -1474,6 +1475,10 @@ bool QWindowsContext::windowsProc(HWND hwnd, UINT message, #endif } break; case QtWindows::DpiChangedEvent: { + + const UINT dpi = HIWORD(wParam); + platformWindow->setSavedDpi(dpi); + // Try to apply the suggested size first and then notify ScreenChanged // so that the resize event sent from QGuiApplication incorporates it // WM_DPICHANGED is sent with a size that avoids resize loops (by |