From 50036371a3c1d35c2f9312bc3055ac0180408496 Mon Sep 17 00:00:00 2001 From: Yuhang Zhao <2546789017@qq.com> Date: Sun, 11 Oct 2020 11:35:57 +0800 Subject: [PATCH] Update. Signed-off-by: Yuhang Zhao <2546789017@qq.com> --- winnativeeventfilter.cpp | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/winnativeeventfilter.cpp b/winnativeeventfilter.cpp index 1110580..48a41f3 100644 --- a/winnativeeventfilter.cpp +++ b/winnativeeventfilter.cpp @@ -1848,16 +1848,18 @@ bool WinNativeEventFilter::nativeEventFilter(const QByteArray &eventType, // https://code.qt.io/cgit/qt/qtbase.git/tree/src/plugins/platforms/windows/qwindowscontext.cpp break; case WM_CONTEXTMENU: { - const int bh = getSystemMetric(msg->hwnd, SystemMetric::BorderHeight, true); - const int tbh = getSystemMetric(msg->hwnd, SystemMetric::TitleBarHeight, true); // If the context menu is brought up from the keyboard, lParam // will be -1. const LPARAM lParam = (msg->lParam == -1) ? WNEF_EXECUTE_WINAPI_RETURN(GetMessagePos, 0) : msg->lParam; - const int mouseY = GET_Y_LPARAM(lParam); - const bool isTitleBar = mouseY <= (tbh + bh); + const POINT globalMouse{GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam)}; + POINT localMouse = globalMouse; + WNEF_EXECUTE_WINAPI(ScreenToClient, msg->hwnd, &localMouse) + const int bh = getSystemMetric(msg->hwnd, SystemMetric::BorderHeight, true); + const int tbh = getSystemMetric(msg->hwnd, SystemMetric::TitleBarHeight, true); + const bool isTitleBar = localMouse.y <= (tbh + bh); if (isTitleBar && !IsFullScreen(msg->hwnd)) { - displaySystemMenu(msg->hwnd, false, GET_X_LPARAM(lParam), mouseY); + displaySystemMenu(msg->hwnd, false, globalMouse.x, globalMouse.y); // WM_CONTEXTMENU message has no return value. return true; } else {