From e7aa0dec5bbecf80ed762853cbe4c37fbd34b0a6 Mon Sep 17 00:00:00 2001 From: ocornut Date: Tue, 30 Sep 2025 18:27:20 +0200 Subject: [PATCH] Viewports: fixed issue in UpdateTryMergeWindowIntoHostViewport(). (#8948) Amend dfe308b --- imgui.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/imgui.cpp b/imgui.cpp index 65a9385cf..2cd8fcdea 100644 --- a/imgui.cpp +++ b/imgui.cpp @@ -16337,6 +16337,7 @@ static bool ImGui::GetWindowAlwaysWantOwnViewport(ImGuiWindow* window) // Heuristic, see #8948: depends on how backends handle OS-level parenting. +// FIXME-VIEWPORTS: if ImGuiBackendFlags_HasParentViewportId if set, we should consider ->ParentViewportId as primary source of truth. 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. @@ -16362,8 +16363,9 @@ static bool ImGui::UpdateTryMergeWindowIntoHostViewport(ImGuiWindow* window, ImG { if (viewport_2 == viewport || viewport_2 == window->Viewport) continue; - if (IsViewportAbove(viewport_2, viewport) && viewport_2->GetMainRect().Overlaps(window->Rect())) - return false; + if (viewport_2->GetMainRect().Overlaps(window->Rect())) + if (IsViewportAbove(viewport_2, viewport) && !IsViewportAbove(viewport_2, window->Viewport)) + return false; } // Move to the existing viewport, Move child/hosted windows as well (FIXME-OPT: iterate child)