From 6f856ce495872bb202be03c056fdbcd13ec162f3 Mon Sep 17 00:00:00 2001 From: Ilya Fedin Date: Sat, 18 Jun 2022 08:37:54 +0400 Subject: [PATCH] Use ScreenToClient for point convertion in WM_NCHITTEST --- ui/platform/win/ui_window_win.cpp | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/ui/platform/win/ui_window_win.cpp b/ui/platform/win/ui_window_win.cpp index 89c2793..1f02692 100644 --- a/ui/platform/win/ui_window_win.cpp +++ b/ui/platform/win/ui_window_win.cpp @@ -24,6 +24,7 @@ #include #include +#include Q_DECLARE_METATYPE(QMargins); @@ -513,12 +514,9 @@ bool WindowHelper::handleNativeEvent( return false; } - const auto p = MAKEPOINTS(lParam); - auto r = RECT(); - GetWindowRect(_handle, &r); - const auto mapped = QPoint( - p.x - r.left + _marginsDelta.left(), - p.y - r.top + _marginsDelta.top()); + POINT p{ GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam) }; + ScreenToClient(_handle, &p); + const auto mapped = QPoint(p.x, p.y) / window()->devicePixelRatioF(); *result = [&] { if (!window()->rect().contains(mapped)) { return HTTRANSPARENT;