summaryrefslogtreecommitdiff
path: root/widget/windows/WinUtils.cpp
diff options
context:
space:
mode:
authorMoonchild <moonchild@palemoon.org>2020-10-06 09:23:59 +0000
committerMoonchild <moonchild@palemoon.org>2020-10-06 09:23:59 +0000
commitbda6f1a93f915f4156bc344651dcfc9b7bb3b9ee (patch)
treee9029ee3547f541cb6d7c175c7e185e1529025dc /widget/windows/WinUtils.cpp
parent521f2b476c3cac4cbdd0eee676a0dfedaa537041 (diff)
downloaduxp-bda6f1a93f915f4156bc344651dcfc9b7bb3b9ee.tar.gz
Issue #1606 - Add support for multi-monitor DPI awareness v2 (W10 1706+)
Diffstat (limited to 'widget/windows/WinUtils.cpp')
-rw-r--r--widget/windows/WinUtils.cpp20
1 files changed, 15 insertions, 5 deletions
diff --git a/widget/windows/WinUtils.cpp b/widget/windows/WinUtils.cpp
index 28033193fc..a43c92b699 100644
--- a/widget/windows/WinUtils.cpp
+++ b/widget/windows/WinUtils.cpp
@@ -449,10 +449,20 @@ WinUtils::Initialize()
if (IsWin10OrLater()) {
HMODULE user32Dll = ::GetModuleHandleW(L"user32");
if (user32Dll) {
- sEnableNonClientDpiScaling = (EnableNonClientDpiScalingProc)
- ::GetProcAddress(user32Dll, "EnableNonClientDpiScaling");
- sSetThreadDpiAwarenessContext = (SetThreadDpiAwarenessContextProc)
- ::GetProcAddress(user32Dll, "SetThreadDpiAwarenessContext");
+ auto getThreadDpiAwarenessContext = (decltype(GetThreadDpiAwarenessContext)*)
+ ::GetProcAddress(user32Dll, "GetThreadDpiAwarenessContext");
+ auto areDpiAwarenessContextsEqual = (decltype(AreDpiAwarenessContextsEqual)*)
+ ::GetProcAddress(user32Dll, "AreDpiAwarenessContextsEqual");
+ if (getThreadDpiAwarenessContext && areDpiAwarenessContextsEqual &&
+ areDpiAwarenessContextsEqual(getThreadDpiAwarenessContext(),
+ DPI_AWARENESS_CONTEXT_PER_MONITOR_AWARE)) {
+ // Only per-monitor DPI awareness v1 requires these workarounds.
+ // Since this was introduced in Win 8.1 we'll need to keep this indefinitely.
+ sEnableNonClientDpiScaling = (EnableNonClientDpiScalingProc)
+ ::GetProcAddress(user32Dll, "EnableNonClientDpiScaling");
+ sSetThreadDpiAwarenessContext = (SetThreadDpiAwarenessContextProc)
+ ::GetProcAddress(user32Dll, "SetThreadDpiAwarenessContext");
+ }
}
}
@@ -468,7 +478,7 @@ LRESULT WINAPI
WinUtils::NonClientDpiScalingDefWindowProcW(HWND hWnd, UINT msg,
WPARAM wParam, LPARAM lParam)
{
- if (msg == WM_NCCREATE && sEnableNonClientDpiScaling) {
+ if (msg == WM_NCCREATE) {
sEnableNonClientDpiScaling(hWnd);
}
return ::DefWindowProcW(hWnd, msg, wParam, lParam);