From 6a1aa2c13e7aec38816e03dc5b2134b0d2da166c Mon Sep 17 00:00:00 2001 From: WerWolv Date: Wed, 13 Aug 2025 22:17:37 +0200 Subject: [PATCH] impr: Close context menus on focus loss --- plugins/builtin/source/content/events.cpp | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/plugins/builtin/source/content/events.cpp b/plugins/builtin/source/content/events.cpp index 701aee155..2a41dd95d 100644 --- a/plugins/builtin/source/content/events.cpp +++ b/plugins/builtin/source/content/events.cpp @@ -326,8 +326,16 @@ namespace hex::plugin::builtin { if (ctx == nullptr) return; - if (ImGui::IsPopupOpen("", ImGuiPopupFlags_AnyPopup)) + if (ImGui::IsPopupOpen("", ImGuiPopupFlags_AnyPopup)) { + for (const auto& popup : ctx->OpenPopupStack) { + if (!(popup.Window->Flags & ImGuiWindowFlags_Modal)) { + ctx->OpenPopupStack.erase_unsorted(&popup); + log::debug("Closing popup '{}' because the main window lost focus", popup.Window->Name ? popup.Window->Name : "Unknown Popup"); + break; + } + } return; + } if (ImGui::IsAnyItemHovered()) return;