From baa5c34b55caafb893196181e1b9c1f725b641b2 Mon Sep 17 00:00:00 2001 From: WerWolv Date: Thu, 5 Oct 2023 08:55:54 +0200 Subject: [PATCH] fix: Reset popup position back on screen if it's outside of it Closes #1348 --- main/gui/source/window/window.cpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/main/gui/source/window/window.cpp b/main/gui/source/window/window.cpp index b62b9d2df..d9e782c9e 100644 --- a/main/gui/source/window/window.cpp +++ b/main/gui/source/window/window.cpp @@ -657,6 +657,18 @@ namespace hex { if (ImGui::GetWindowSize().x > ImGui::GetStyle().FramePadding.x * 10) sizeSet = true; + // Reset popup position if it's outside the main window when multi-viewport is not enabled + // If not done, the popup will be stuck outside the main window and cannot be accessed anymore + if ((ImGui::GetIO().ConfigFlags & ImGuiConfigFlags_ViewportsEnable) == ImGuiConfigFlags_None) { + const auto currWindowPos = ImGui::GetWindowPos(); + const auto minWindowPos = ImHexApi::System::getMainWindowPosition() - ImGui::GetWindowSize(); + const auto maxWindowPos = ImHexApi::System::getMainWindowPosition() + ImHexApi::System::getMainWindowSize(); + if (currWindowPos.x > maxWindowPos.x || currWindowPos.y > maxWindowPos.y || currWindowPos.x < minWindowPos.x || currWindowPos.y < minWindowPos.y) { + positionSet = false; + GImGui->MovingWindow = nullptr; + } + } + ImGui::EndPopup(); } else { popupDisplaying = false;