From fce791bd563134b793ddd79b45c91b7d59e14c7b Mon Sep 17 00:00:00 2001 From: Neil Date: Tue, 29 Nov 2022 10:22:23 +1100 Subject: Bug [#2344]. When GDI scaling is active, ensure correct monitor used for determining scale factor. Function name changed to avoid possibility of confusion with Win32 API. --- win32/PlatWin.cxx | 4 ++-- win32/PlatWin.h | 2 +- win32/ScintillaWin.cxx | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) (limited to 'win32') diff --git a/win32/PlatWin.cxx b/win32/PlatWin.cxx index b52aa477a..0b36c42da 100644 --- a/win32/PlatWin.cxx +++ b/win32/PlatWin.cxx @@ -374,7 +374,7 @@ struct FontDirectWrite : public FontWin { } -HMONITOR MonitorFromWindow(HWND hWnd) noexcept { +HMONITOR MonitorFromWindowHandleScaling(HWND hWnd) noexcept { constexpr DWORD monitorFlags = MONITOR_DEFAULTTONEAREST; if (!fnSetThreadDpiAwarenessContext) { @@ -398,7 +398,7 @@ int GetDeviceScaleFactorWhenGdiScalingActive(HWND hWnd) noexcept { PLATFORM_ASSERT(fnGetWindowDpiAwarenessContext && fnGetScaleFactorForMonitor); if (fnAreDpiAwarenessContextsEqual(DPI_AWARENESS_CONTEXT_UNAWARE_GDISCALED, fnGetWindowDpiAwarenessContext(hWnd))) { const HWND hRootWnd = ::GetAncestor(hWnd, GA_ROOT); // Scale factor applies to entire (root) window. - const HMONITOR hMonitor = MonitorFromWindow(hRootWnd, MONITOR_DEFAULTTONEAREST); + const HMONITOR hMonitor = MonitorFromWindowHandleScaling(hRootWnd); DEVICE_SCALE_FACTOR deviceScaleFactor; if (S_OK == fnGetScaleFactorForMonitor(hMonitor, &deviceScaleFactor)) return (static_cast(deviceScaleFactor) + 99) / 100; // increase to first integral multiple of 1 diff --git a/win32/PlatWin.h b/win32/PlatWin.h index aa16e9f89..1391723dd 100644 --- a/win32/PlatWin.h +++ b/win32/PlatWin.h @@ -43,7 +43,7 @@ inline HWND HwndFromWindow(const Window &w) noexcept { void *PointerFromWindow(HWND hWnd) noexcept; void SetWindowPointer(HWND hWnd, void *ptr) noexcept; -HMONITOR MonitorFromWindow(HWND hWnd) noexcept; +HMONITOR MonitorFromWindowHandleScaling(HWND hWnd) noexcept; UINT DpiForWindow(WindowID wid) noexcept; int GetDeviceScaleFactorWhenGdiScalingActive(HWND hWnd) noexcept; diff --git a/win32/ScintillaWin.cxx b/win32/ScintillaWin.cxx index efbe1f000..42927433f 100644 --- a/win32/ScintillaWin.cxx +++ b/win32/ScintillaWin.cxx @@ -606,7 +606,7 @@ bool ScintillaWin::UpdateRenderingParams(bool force) noexcept { } } const HWND hRootWnd = ::GetAncestor(MainHWND(), GA_ROOT); - const HMONITOR monitor = Internal::MonitorFromWindow(hRootWnd); + const HMONITOR monitor = Internal::MonitorFromWindowHandleScaling(hRootWnd); if (!force && monitor == hCurrentMonitor && renderingParams->defaultRenderingParams) { return false; } -- cgit v1.2.3