diff --git a/docs/CHANGELOG.txt b/docs/CHANGELOG.txt index b6ad8677..8ca48176 100644 --- a/docs/CHANGELOG.txt +++ b/docs/CHANGELOG.txt @@ -148,6 +148,9 @@ Docking+Viewports Branch: - Docking: Internals: fixed DockBuilderCopyDockSpace() crashing when windows not in the remapping list are docked on the left or top side of a split. (#6035) +- Docking: fixed DockSpace() with ImGuiDockNodeFlags_KeepAliveOnly marking current window + as written to, even if it doesn't technically submit an item. This allow using KeepAliveOnly + from any window location. (#6037) - Backends: OSX: fixed typo in ImGui_ImplOSX_GetWindowSize that would cause issues when resiing from OS decorations, if they are enabled on secondary viewports. (#6009) [@sivu] - Backends: Metal: fixed secondary viewport rendering. (#6015) [@dmirty-kuzmenko] diff --git a/imgui.cpp b/imgui.cpp index 5b44042d..8f278b79 100644 --- a/imgui.cpp +++ b/imgui.cpp @@ -17218,11 +17218,12 @@ void ImGui::SetWindowDock(ImGuiWindow* window, ImGuiID dock_id, ImGuiCond cond) // Create an explicit dockspace node within an existing window. Also expose dock node flags and creates a CentralNode by default. // The Central Node is always displayed even when empty and shrink/extend according to the requested size of its neighbors. // DockSpace() needs to be submitted _before_ any window they can host. If you use a dockspace, submit it early in your app. +// When ImGuiDockNodeFlags_KeepAliveOnly is set, nothing is submitted in the current window (function may be called from any location). ImGuiID ImGui::DockSpace(ImGuiID id, const ImVec2& size_arg, ImGuiDockNodeFlags flags, const ImGuiWindowClass* window_class) { ImGuiContext* ctx = GImGui; ImGuiContext& g = *ctx; - ImGuiWindow* window = GetCurrentWindow(); + ImGuiWindow* window = GetCurrentWindowRead(); if (!(g.IO.ConfigFlags & ImGuiConfigFlags_DockingEnable)) return 0; @@ -17231,6 +17232,8 @@ ImGuiID ImGui::DockSpace(ImGuiID id, const ImVec2& size_arg, ImGuiDockNodeFlags // If for whichever reason this is causing problem we would need to ensure that DockNodeUpdateTabBar() ends up clearing NextSelectedTabId even if SkipItems=true. if (window->SkipItems) flags |= ImGuiDockNodeFlags_KeepAliveOnly; + if ((flags & ImGuiDockNodeFlags_KeepAliveOnly) == 0) + window = GetCurrentWindow(); // call to set window->WriteAccessed = true; IM_ASSERT((flags & ImGuiDockNodeFlags_DockSpace) == 0); IM_ASSERT(id != 0);