Skip to content

Commit

Permalink
impr: Allow closing menus by clicking on title bar on Windows
Browse files Browse the repository at this point in the history
  • Loading branch information
WerWolv committed Feb 3, 2024
1 parent ab02cb0 commit 3555fc0
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion main/gui/source/window/win_window.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ namespace hex {
static LONG_PTR s_oldWndProc;
static float s_titleBarHeight;
static Microsoft::WRL::ComPtr<ITaskbarList4> s_taskbarList;
static bool s_mouseButtonDown = false;

void nativeErrorMessage(const std::string &message) {
log::fatal(message);
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit 3555fc0

Please sign in to comment.