From 5778d4540f0b522946c84c8ba601456f2d440f78 Mon Sep 17 00:00:00 2001
From: Sine Striker <trueful@163.com>
Date: 周三, 08 5月 2024 13:58:59 +0800
Subject: [PATCH] Fix a mistake

---
 src/core/contexts/win32windowcontext.cpp |    9 ++++++---
 1 files changed, 6 insertions(+), 3 deletions(-)

diff --git a/src/core/contexts/win32windowcontext.cpp b/src/core/contexts/win32windowcontext.cpp
index e32142e..9d37d7c 100644
--- a/src/core/contexts/win32windowcontext.cpp
+++ b/src/core/contexts/win32windowcontext.cpp
@@ -1389,6 +1389,7 @@
                                     // until the menu returns
                                     iconButtonClickTime = ::GetTickCount64();
                                     *result = ::DefWindowProcW(hWnd, message, wParam, lParam);
+                                    iconButtonClickTime = 0;
                                     if (iconButtonClickLevel & IconButtonTriggersClose) {
                                         ::PostMessageW(hWnd, WM_SYSCOMMAND, SC_CLOSE, 0);
                                     }
@@ -2105,7 +2106,10 @@
                 const POINT nativeLocalPos = getNativePosFromMouse();
                 const QPoint qtScenePos =
                     QHighDpi::fromNativeLocalPosition(point2qpoint(nativeLocalPos), m_windowHandle);
-                if (isInTitleBarDraggableArea(qtScenePos)) {
+                WindowAgentBase::SystemButton sysButtonType = WindowAgentBase::Unknown;
+                if (isInTitleBarDraggableArea(qtScenePos) ||
+                    (isInSystemButtons(qtScenePos, &sysButtonType) &&
+                     sysButtonType == WindowAgentBase::WindowIcon)) {
                     shouldShowSystemMenu = true;
                     nativeGlobalPos = nativeLocalPos;
                     ::ClientToScreen(hWnd, &nativeGlobalPos);
@@ -2209,7 +2213,6 @@
                 ::UnhookWindowsHookEx(mouseHook);
 
                 // Emulate the Windows icon button's behavior
-                static uint32_t doubleClickTime = ::GetDoubleClickTime();
                 if (!res && mouseClickPos.has_value()) {
                     POINT nativeLocalPos = mouseClickPos.value();
                     ::ScreenToClient(hWnd, &nativeLocalPos);
@@ -2219,7 +2222,7 @@
                     if (isInSystemButtons(qtScenePos, &sysButtonType) &&
                         sysButtonType == WindowAgentBase::WindowIcon) {
                         iconButtonClickLevel |= IconButtonClicked;
-                        if (::GetTickCount64() - iconButtonClickTime <= doubleClickTime) {
+                        if (::GetTickCount64() - iconButtonClickTime <= ::GetDoubleClickTime()) {
                             iconButtonClickLevel |= IconButtonTriggersClose;
                         }
                     }

--
Gitblit v1.9.1