From f573ebf31a04d1ab953e8dec4aedacd15d7b588a Mon Sep 17 00:00:00 2001 From: Rokas Kupstys Date: Tue, 26 Jul 2022 12:35:44 +0300 Subject: [PATCH] Docking+Viewports: Fix undocking window node causing parent viewport to become unresponsive. (#5503) Amend 67be485e, Somehow ties to 58f5092c + 0eb45a05 (#4310) Unsure of exact chain of event but this caused a parent link msimatch between the time of the MouseMoving test in AddUpdateViewport() setting _NoInputs on the wrong parent., and the release clearing _NoInputs on the rght one. --- docs/CHANGELOG.txt | 2 ++ imgui.cpp | 16 ++++++++-------- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/docs/CHANGELOG.txt b/docs/CHANGELOG.txt index 2966f0f6d459..f01e3629d03c 100644 --- a/docs/CHANGELOG.txt +++ b/docs/CHANGELOG.txt @@ -146,6 +146,8 @@ Docking+Viewports Branch: - Docking: Fixed regression introduced in v1.87 when docked window content not rendered while switching between with CTRL+Tab. [@rokups] - Docking: Fixed amending into an existing tab bar from rendering invisible items. (#5515) +- Docking+Viewports: Fixed undocking window node causing parent viewports to become unresponsive + in certain situation (e.g. hidden tab bar). (#5503) [@rokups] - Backends: GLFW: Fixed leftover static variable preventing from changing or reinitializing backend while application is running. (#4616, #5434) [@rtoumazet] diff --git a/imgui.cpp b/imgui.cpp index b2c2fd0dcef1..1cdfd055b2fe 100644 --- a/imgui.cpp +++ b/imgui.cpp @@ -14460,14 +14460,6 @@ void ImGui::DockContextProcessUndockNode(ImGuiContext* ctx, ImGuiDockNode* node) new_node->SizeRef = node->SizeRef; DockNodeMoveWindows(new_node, node); DockSettingsRenameNodeReferences(node->ID, new_node->ID); - for (int n = 0; n < new_node->Windows.Size; n++) - { - ImGuiWindow* window = new_node->Windows[n]; - window->Flags &= ~ImGuiWindowFlags_ChildWindow; - if (window->ParentWindow) - window->ParentWindow->DC.ChildWindows.find_erase(window); - UpdateWindowParentAndRootLinks(window, window->Flags, NULL); - } node = new_node; } else @@ -14480,6 +14472,14 @@ void ImGui::DockContextProcessUndockNode(ImGuiContext* ctx, ImGuiDockNode* node) node->ParentNode->AuthorityForViewport = ImGuiDataAuthority_Window; // The node that stays in place keeps the viewport, so our newly dragged out node will create a new viewport node->ParentNode = NULL; } + for (int n = 0; n < node->Windows.Size; n++) + { + ImGuiWindow* window = node->Windows[n]; + window->Flags &= ~ImGuiWindowFlags_ChildWindow; + if (window->ParentWindow) + window->ParentWindow->DC.ChildWindows.find_erase(window); + UpdateWindowParentAndRootLinks(window, window->Flags, NULL); + } node->AuthorityForPos = node->AuthorityForSize = ImGuiDataAuthority_DockNode; node->Size = FixLargeWindowsWhenUndocking(node->Size, node->Windows[0]->Viewport); node->WantMouseMove = true;