From d26bcc1abea7ea46a57dbdd208b3f90c454c24cb Mon Sep 17 00:00:00 2001 From: WerWolv Date: Sat, 24 May 2025 23:10:53 +0200 Subject: [PATCH] fix: Menu bar being gone on the Web build --- .../source/content/window_decoration.cpp | 68 ++++++++++--------- 1 file changed, 36 insertions(+), 32 deletions(-) diff --git a/plugins/builtin/source/content/window_decoration.cpp b/plugins/builtin/source/content/window_decoration.cpp index 272d0b441..57eba9d55 100644 --- a/plugins/builtin/source/content/window_decoration.cpp +++ b/plugins/builtin/source/content/window_decoration.cpp @@ -402,8 +402,6 @@ namespace hex::plugin::builtin { ImGui::PushStyleVar(ImGuiStyleVar_FrameBorderSize, 0.0F); ImGui::SetNextWindowScroll(ImVec2(0, 0)); - auto window = ImHexApi::System::getMainWindowHandle(); - #if defined(OS_MACOS) ImGui::PushStyleVar(ImGuiStyleVar_FramePadding, ImVec2(ImGui::GetStyle().FramePadding.x, 8_scaled)); ON_SCOPE_EXIT { ImGui::PopStyleVar(); }; @@ -412,39 +410,10 @@ namespace hex::plugin::builtin { 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()) { if (ImHexApi::System::isBorderlessWindowModeEnabled()) { @@ -484,6 +453,41 @@ namespace hex::plugin::builtin { menu::endMainMenuBar(); } menu::enableNativeMenuBar(false); + + if (ImGui::BeginMainMenuBar()) { + 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() {