|
|
|
@ -2802,7 +2802,23 @@ void ImGui::EndFrame()
|
|
|
|
|
// With right mouse button we close popups without changing focus
|
|
|
|
|
// (The left mouse button path calls FocusWindow which will lead NewFrame->CloseInactivePopups to trigger)
|
|
|
|
|
if (g.IO.MouseClicked[1])
|
|
|
|
|
CloseInactivePopups(g.HoveredWindow);
|
|
|
|
|
{
|
|
|
|
|
// Find the top-most window between HoveredWindow and the front most Modal Window.
|
|
|
|
|
// This is where we can trim the popup stack.
|
|
|
|
|
ImGuiWindow* modal = GetFrontMostModalRootWindow();
|
|
|
|
|
bool hovered_window_above_modal = false;
|
|
|
|
|
if (modal == NULL)
|
|
|
|
|
hovered_window_above_modal = true;
|
|
|
|
|
for (int i = g.Windows.Size - 1; i >= 0 && hovered_window_above_modal == false; i--)
|
|
|
|
|
{
|
|
|
|
|
ImGuiWindow* window = g.Windows[i];
|
|
|
|
|
if (window == modal)
|
|
|
|
|
break;
|
|
|
|
|
if (window == g.HoveredWindow)
|
|
|
|
|
hovered_window_above_modal = true;
|
|
|
|
|
}
|
|
|
|
|
CloseInactivePopups(hovered_window_above_modal ? g.HoveredWindow : modal);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -3588,7 +3604,7 @@ static void CloseInactivePopups(ImGuiWindow* ref_window)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
// When popups are stacked, clicking on a lower level popups puts focus back to it and close popups above it.
|
|
|
|
|
// Don't close our own child popup windows
|
|
|
|
|
// Don't close our own child popup windows.
|
|
|
|
|
int n = 0;
|
|
|
|
|
if (ref_window)
|
|
|
|
|
{
|
|
|
|
@ -3601,6 +3617,7 @@ static void CloseInactivePopups(ImGuiWindow* ref_window)
|
|
|
|
|
if (popup.Window->Flags & ImGuiWindowFlags_ChildWindow)
|
|
|
|
|
continue;
|
|
|
|
|
|
|
|
|
|
// Trim the stack if popups are not direct descendant of the reference window (which is often the NavWindow)
|
|
|
|
|
bool has_focus = false;
|
|
|
|
|
for (int m = n; m < g.OpenPopupStack.Size && !has_focus; m++)
|
|
|
|
|
has_focus = (g.OpenPopupStack[m].Window && g.OpenPopupStack[m].Window->RootWindow == ref_window->RootWindow);
|
|
|
|
@ -3616,9 +3633,9 @@ static ImGuiWindow* GetFrontMostModalRootWindow()
|
|
|
|
|
{
|
|
|
|
|
ImGuiContext& g = *GImGui;
|
|
|
|
|
for (int n = g.OpenPopupStack.Size-1; n >= 0; n--)
|
|
|
|
|
if (ImGuiWindow* front_most_popup = g.OpenPopupStack.Data[n].Window)
|
|
|
|
|
if (front_most_popup->Flags & ImGuiWindowFlags_Modal)
|
|
|
|
|
return front_most_popup;
|
|
|
|
|
if (ImGuiWindow* popup = g.OpenPopupStack.Data[n].Window)
|
|
|
|
|
if (popup->Flags & ImGuiWindowFlags_Modal)
|
|
|
|
|
return popup;
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|