From 7acc5fc02ea0da88329247fde14fbf7bdadb3cf8 Mon Sep 17 00:00:00 2001 From: WerWolv Date: Sat, 24 May 2025 11:57:02 +0200 Subject: [PATCH] impr: Make title bar backdrop actually a backdrop and not an overlay --- .../source/content/window_decoration.cpp | 72 +++++++++---------- 1 file changed, 36 insertions(+), 36 deletions(-) diff --git a/plugins/builtin/source/content/window_decoration.cpp b/plugins/builtin/source/content/window_decoration.cpp index c29e3e243..b63cb8d10 100644 --- a/plugins/builtin/source/content/window_decoration.cpp +++ b/plugins/builtin/source/content/window_decoration.cpp @@ -407,6 +407,42 @@ namespace hex::plugin::builtin { ON_SCOPE_EXIT { ImGui::PopStyleVar(); }; #endif + if (ImGui::BeginMainMenuBar()) { + drawTitleBarBackDrop(); + ImGui::Dummy({}); + + ImGui::PopStyleVar(2); + + drawTitleBar(); + + #if defined(OS_MACOS) + if (ImHexApi::System::isBorderlessWindowModeEnabled()) { + const auto windowSize = ImHexApi::System::getMainWindowSize(); + const auto menuUnderlaySize = ImVec2(windowSize.x, ImGui::GetCurrentWindowRead()->MenuBarHeight); + + ImGui::SetCursorPos(ImVec2()); + + // Prevent window from being moved unless title bar is hovered + + if (!ImGui::IsAnyItemHovered()) { + const auto cursorPos = ImGui::GetCursorScreenPos(); + if (ImGui::IsMouseHoveringRect(cursorPos, cursorPos + menuUnderlaySize) && ImGui::IsMouseDoubleClicked(ImGuiMouseButton_Left)) { + macosHandleTitlebarDoubleClickGesture(window); + } + + macosSetWindowMovable(window, true); + } else { + macosSetWindowMovable(window, false); + + } + } + #endif + + ImGui::EndMainMenuBar(); + } else { + ImGui::PopStyleVar(2); + } + auto window = ImHexApi::System::getMainWindowHandle(); menu::enableNativeMenuBar(s_useNativeMenuBar); if (menu::beginMainMenuBar()) { @@ -447,42 +483,6 @@ namespace hex::plugin::builtin { menu::endMainMenuBar(); } menu::enableNativeMenuBar(false); - - if (ImGui::BeginMainMenuBar()) { - drawTitleBarBackDrop(); - ImGui::Dummy({}); - - ImGui::PopStyleVar(2); - - drawTitleBar(); - - #if defined(OS_MACOS) - if (ImHexApi::System::isBorderlessWindowModeEnabled()) { - const auto windowSize = ImHexApi::System::getMainWindowSize(); - const auto menuUnderlaySize = ImVec2(windowSize.x, ImGui::GetCurrentWindowRead()->MenuBarHeight); - - ImGui::SetCursorPos(ImVec2()); - - // Prevent window from being moved unless title bar is hovered - - if (!ImGui::IsAnyItemHovered()) { - const auto cursorPos = ImGui::GetCursorScreenPos(); - if (ImGui::IsMouseHoveringRect(cursorPos, cursorPos + menuUnderlaySize) && ImGui::IsMouseDoubleClicked(ImGuiMouseButton_Left)) { - macosHandleTitlebarDoubleClickGesture(window); - } - - macosSetWindowMovable(window, true); - } else { - macosSetWindowMovable(window, false); - - } - } - #endif - - ImGui::EndMainMenuBar(); - } else { - ImGui::PopStyleVar(2); - } } void drawToolbar() {