From 9e5103e040cc620a9daef4a0e9271055543ec430 Mon Sep 17 00:00:00 2001 From: Yuhang Zhao <2546789017@qq.com> Date: Thu, 2 Apr 2020 13:53:14 +0800 Subject: [PATCH] DPI improve. Signed-off-by: Yuhang Zhao <2546789017@qq.com> --- winnativeeventfilter.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/winnativeeventfilter.cpp b/winnativeeventfilter.cpp index 9892e72..4056366 100644 --- a/winnativeeventfilter.cpp +++ b/winnativeeventfilter.cpp @@ -334,13 +334,13 @@ bool WinNativeEventFilter::nativeEventFilter(const QByteArray &eventType, const int titlebarHeight_userDefined = _data->windowData.titlebarHeight; // These values should be DPI-aware. - const LONG bw = borderWidth_userDefined > 0 ? borderWidth_userDefined + const LONG bw = borderWidth_userDefined > 0 ? qRound64(windowDpr(_hWnd) * borderWidth_userDefined) : borderWidth(_hWnd); const LONG bh = borderHeight_userDefined > 0 - ? borderHeight_userDefined + ? qRound64(windowDpr(_hWnd) * borderHeight_userDefined) : borderHeight(_hWnd); const LONG tbh = titlebarHeight_userDefined > 0 - ? titlebarHeight_userDefined + ? qRound64(windowDpr(_hWnd) * titlebarHeight_userDefined) : titlebarHeight(_hWnd); const bool isInsideWindow = (mouse.x > 0) && (mouse.x < ww) && (mouse.y > 0) && (mouse.y < wh); const bool isTitlebar = isInsideWindow && (mouse.y < tbh) && @@ -635,7 +635,7 @@ int WinNativeEventFilter::getSystemMetricsForWindow(HWND handle, if (m_GetSystemMetricsForDpi) { return m_GetSystemMetricsForDpi(index, getDpiForWindow(handle)); } else { - return GetSystemMetrics(index) * getDprForWindow(handle); + return qRound(GetSystemMetrics(index) * getDprForWindow(handle)); } }