From 357532958f2e806c69c96f018333a45e65e35201 Mon Sep 17 00:00:00 2001
From: Zhao Yuhang <2546789017@qq.com>
Date: 周二, 07 5月 2024 22:17:53 +0800
Subject: [PATCH] improve sysmenu behavior

---
 src/core/contexts/win32windowcontext.cpp |   10 ++++++++--
 1 files changed, 8 insertions(+), 2 deletions(-)

diff --git a/src/core/contexts/win32windowcontext.cpp b/src/core/contexts/win32windowcontext.cpp
index 171a348..ffbcf24 100644
--- a/src/core/contexts/win32windowcontext.cpp
+++ b/src/core/contexts/win32windowcontext.cpp
@@ -2128,8 +2128,14 @@
         if (shouldShowSystemMenu) {
             bool triggeredByIconButton = iconButtonClickTime > 0;
             if (triggeredByIconButton) {
-                // TODO: Adjust `nativeGlobalPos` to (0, realTitleBarHeight)
-                // hint: use m_delgegate->mapGeometryToScene
+                POINT menuPos{ 0, static_cast<LONG>(getTitleBarHeight(hWnd)) };
+                if (const auto tb = titleBar()) {
+                    auto titleBarHeight = qreal(m_delegate->mapGeometryToScene(tb).height());
+                    titleBarHeight *= m_windowHandle->devicePixelRatio();
+                    menuPos.y = qRound(titleBarHeight);
+                }
+                ::ClientToScreen(hWnd, &menuPos);
+                nativeGlobalPos = menuPos;
             }
             bool res = showSystemMenu_sys(hWnd, nativeGlobalPos, broughtByKeyboard,
                                           m_delegate->isHostSizeFixed(m_host));

--
Gitblit v1.9.1