From 3555fc01c599448d8d0f86fe2e7afaab014b2dde Mon Sep 17 00:00:00 2001 From: WerWolv Date: Sat, 3 Feb 2024 20:19:39 +0100 Subject: [PATCH] impr: Allow closing menus by clicking on title bar on Windows --- main/gui/source/window/win_window.cpp | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/main/gui/source/window/win_window.cpp b/main/gui/source/window/win_window.cpp index f7805d7ee..1c273f4f3 100644 --- a/main/gui/source/window/win_window.cpp +++ b/main/gui/source/window/win_window.cpp @@ -33,6 +33,7 @@ namespace hex { static LONG_PTR s_oldWndProc; static float s_titleBarHeight; static Microsoft::WRL::ComPtr s_taskbarList; + static bool s_mouseButtonDown = false; void nativeErrorMessage(const std::string &message) { log::fatal(message); @@ -131,6 +132,12 @@ namespace hex { switch (uMsg) { case WM_MOUSELAST: break; + case WM_NCLBUTTONDOWN: + s_mouseButtonDown = true; + break; + case WM_NCLBUTTONUP: + s_mouseButtonDown = false; + break; case WM_NCACTIVATE: case WM_NCPAINT: // Handle Windows Aero Snap @@ -222,12 +229,14 @@ namespace hex { return HTBOTTOMRIGHT; case RegionClient: default: - if (cursor.y < (window.top + s_titleBarHeight * 2)) { + if (cursor.y < (window.top + s_titleBarHeight * 2) && !s_mouseButtonDown) { if (hoveredWindowName == "##MainMenuBar" || hoveredWindowName == "ImHexDockSpace") { if (!ImGui::IsAnyItemHovered()) { return HTCAPTION; } } + } else { + return HTCLIENT; } break;