mirror of
https://github.com/ocornut/imgui.git
synced 2026-01-11 00:04:24 +00:00
Viewports: fixed an issue inferring Z-order when attempting to merge a viewport back in the the main/hosting viewport. (#8948)
This commit is contained in:
parent
1ad9de5aae
commit
dfe308bc53
2 changed files with 19 additions and 7 deletions
21
imgui.cpp
21
imgui.cpp
|
|
@ -16326,6 +16326,15 @@ static bool ImGui::GetWindowAlwaysWantOwnViewport(ImGuiWindow* window)
|
|||
return false;
|
||||
}
|
||||
|
||||
|
||||
// Heuristic, see #8948: depends on how backends handle OS-level parenting.
|
||||
static bool IsViewportAbove(ImGuiViewportP* potential_above, ImGuiViewportP* potential_below)
|
||||
{
|
||||
if (potential_above->LastFocusedStampCount > potential_below->LastFocusedStampCount || potential_above->ParentViewportId == potential_below->ID) // FIXME: Should follow the ParentViewportId list.
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
static bool ImGui::UpdateTryMergeWindowIntoHostViewport(ImGuiWindow* window, ImGuiViewportP* viewport)
|
||||
{
|
||||
ImGuiContext& g = *GImGui;
|
||||
|
|
@ -16340,14 +16349,12 @@ static bool ImGui::UpdateTryMergeWindowIntoHostViewport(ImGuiWindow* window, ImG
|
|||
if (GetWindowAlwaysWantOwnViewport(window))
|
||||
return false;
|
||||
|
||||
// FIXME: Can't use g.WindowsFocusOrder[] for root windows only as we care about Z order. If we maintained a DisplayOrder along with FocusOrder we could..
|
||||
for (ImGuiWindow* window_behind : g.Windows)
|
||||
for (ImGuiViewportP* viewport_2 : g.Viewports)
|
||||
{
|
||||
if (window_behind == window)
|
||||
break;
|
||||
if (window_behind->WasActive && window_behind->ViewportOwned && !(window_behind->Flags & ImGuiWindowFlags_ChildWindow))
|
||||
if (window_behind->Viewport->GetMainRect().Overlaps(window->Rect()))
|
||||
return false;
|
||||
if (viewport_2 == viewport || viewport_2 == window->Viewport)
|
||||
continue;
|
||||
if (IsViewportAbove(viewport_2, viewport) && viewport_2->GetMainRect().Overlaps(window->Rect()))
|
||||
return false;
|
||||
}
|
||||
|
||||
// Move to the existing viewport, Move child/hosted windows as well (FIXME-OPT: iterate child)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue