fix: Reset popup position back on screen if it's outside of it

Closes #1348
This commit is contained in:
WerWolv 2023-10-05 08:55:54 +02:00
parent d19d812ccb
commit baa5c34b55
1 changed files with 12 additions and 0 deletions

View File

@ -657,6 +657,18 @@ namespace hex {
if (ImGui::GetWindowSize().x > ImGui::GetStyle().FramePadding.x * 10) if (ImGui::GetWindowSize().x > ImGui::GetStyle().FramePadding.x * 10)
sizeSet = true; 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(); ImGui::EndPopup();
} else { } else {
popupDisplaying = false; popupDisplaying = false;