From fa1f540e6c64ae66623cff579cd4de30d594ffdb Mon Sep 17 00:00:00 2001 From: ocornut Date: Thu, 3 Jun 2021 16:07:22 +0200 Subject: [PATCH] Docking: Amend 91704b7, window->DockXXX booleans not properly cleared when window not docked. (#4177, #3982, #1497, #1061) Fix issue with freshly split windows/nodes incorrectly returning true to IsWindowAppearing(). --- imgui.cpp | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/imgui.cpp b/imgui.cpp index 8593f7f4..10d2464a 100644 --- a/imgui.cpp +++ b/imgui.cpp @@ -6148,6 +6148,10 @@ bool ImGui::Begin(const char* name, bool* p_open, ImGuiWindowFlags flags) // Docking currently override constraints g.NextWindowData.Flags &= ~ImGuiNextWindowDataFlags_HasSizeConstraint; } + else + { + window->DockIsActive = window->DockNodeIsVisible = window->DockTabIsVisible = false; + } // Update the Appearing flag (again) if (window->DockTabIsVisible && !dock_tab_was_visible && dock_node_was_visible && !window->Appearing) @@ -15457,6 +15461,9 @@ void ImGui::BeginDocked(ImGuiWindow* window, bool* p_open) ImGuiContext* ctx = GImGui; ImGuiContext& g = *ctx; + // Clear fields ahead so most early-out paths don't have to do it + window->DockIsActive = window->DockNodeIsVisible = window->DockTabIsVisible = false; + const bool auto_dock_node = GetWindowAlwaysWantOwnTabBar(window); if (auto_dock_node) { @@ -15506,14 +15513,9 @@ void ImGui::BeginDocked(ImGuiWindow* window, bool* p_open) // If the window has been orphaned, transition the docknode to an implicit node processed in DockContextNewFrameUpdateDocking() ImGuiDockNode* root_node = DockNodeGetRootNode(node); if (root_node->LastFrameAlive < g.FrameCount) - { DockContextProcessUndockWindow(ctx, window); - } else - { window->DockIsActive = true; - window->DockNodeIsVisible = window->DockTabIsVisible = false; - } return; } @@ -15526,8 +15528,8 @@ void ImGui::BeginDocked(ImGuiWindow* window, bool* p_open) // FIXME-DOCK: replace ->HostWindow NULL compare with something more explicit (~was initially intended as a first frame test) if (node->HostWindow == NULL) { - window->DockIsActive = (node->State == ImGuiDockNodeState_HostWindowHiddenBecauseWindowsAreResizing); - window->DockNodeIsVisible = window->DockTabIsVisible = false; + if (node->State == ImGuiDockNodeState_HostWindowHiddenBecauseWindowsAreResizing) + window->DockIsActive = true; if (node->Windows.Size > 1) DockNodeHideWindowDuringHostWindowCreation(window); return;