From 10ebda0b5e6fde71977377eb660e2d4cc73554dd Mon Sep 17 00:00:00 2001 From: ocornut Date: Thu, 29 Jan 2026 18:55:30 +0100 Subject: [PATCH] Docking, Viwport: Fixed a regression in 1.92.4 where partially moving a floating docking node with split over the main viewport would set the window in an invalid state. This was revealed by better merging in dfe308b (#8948) but isn't technically caused by it. Added a agressive assert in UpdateTryMergeWindowIntoHostViewport() For good measure. --- docs/CHANGELOG.txt | 4 ++++ imgui.cpp | 4 +++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/docs/CHANGELOG.txt b/docs/CHANGELOG.txt index 62f2def28..1fa07fe2a 100644 --- a/docs/CHANGELOG.txt +++ b/docs/CHANGELOG.txt @@ -245,6 +245,10 @@ Docking+Viewports Branch: - Demo: rework 'Dockspace' demo to increase clarity and put more emphasis on the basic path of simply calling `DockSpaceOverViewport()`. - Viewports: + - Fixed a regression in 1.92.4 where partially moving a floating docking node + with horizontal/vertical split over the main viewport would set the window in + an invalid state in some situations, making user unable to further interact + with the window. - Fixed a regression in 1.92.4 which could cause combos/popups window from appearing under their parent viewport if their geometry overlapped the main viewport. (#8948, #9172, #9131, #9128) diff --git a/imgui.cpp b/imgui.cpp index 547aeff6c..8319700b3 100644 --- a/imgui.cpp +++ b/imgui.cpp @@ -5365,7 +5365,7 @@ void ImGui::StopMouseMovingWindow() // Try to merge the window back into the main viewport. // This works because MouseViewport should be != MovingWindow->Viewport on release (as per code in UpdateViewports) if (g.ConfigFlagsCurrFrame & ImGuiConfigFlags_ViewportsEnable) - UpdateTryMergeWindowIntoHostViewport(window, g.MouseViewport); + UpdateTryMergeWindowIntoHostViewport(window->RootWindowDockTree, g.MouseViewport); // Restore the mouse viewport so that we don't hover the viewport _under_ the moved window during the frame we released the mouse button. if (!IsDragDropPayloadBeingAccepted()) @@ -16553,6 +16553,7 @@ static bool IsViewportAbove(ImGuiViewportP* potential_above, ImGuiViewportP* pot static bool ImGui::UpdateTryMergeWindowIntoHostViewport(ImGuiWindow* window, ImGuiViewportP* viewport_dst) { ImGuiContext& g = *GImGui; + IM_ASSERT(window == window->RootWindowDockTree); ImGuiViewportP* viewport_src = window->Viewport; // Current viewport if (viewport_src == viewport_dst) return false; @@ -16576,6 +16577,7 @@ static bool ImGui::UpdateTryMergeWindowIntoHostViewport(ImGuiWindow* window, ImG } // Move to the existing viewport, Move child/hosted windows as well (FIXME-OPT: iterate child) + IMGUI_DEBUG_LOG_VIEWPORT("[viewport] Window '%s' merge into Viewport 0X%08X\n", window->Name, viewport_dst->ID); if (window->ViewportOwned) for (int n = 0; n < g.Windows.Size; n++) if (g.Windows[n]->Viewport == viewport_src)