diff --git a/imgui.cpp b/imgui.cpp index 267ae676..9bad7a0a 100644 --- a/imgui.cpp +++ b/imgui.cpp @@ -6070,9 +6070,13 @@ bool ImGui::Begin(const char* name, bool* p_open, ImGuiWindowFlags flags) window->BeginCount++; g.NextWindowData.Clear(); + // When we are about to select this tab (which will only be visible on the _next frame_), flag it with a non-zero HiddenFramesCannotSkipItems. + // This will have the important effect of actually returning true in Begin() and not setting SkipItems, allowing an earlier submission of the window contents. + // This is analogous to regular windows being hidden from one frame. + // It is especially important as e.g. nested TabBars would otherwise generate flicker in the form of one empty frame, or focus requests won't be processed. if (window->DockIsActive && !window->DockTabIsVisible) { - if (window->LastFrameJustFocused == g.FrameCount) // This may be a better a generalization for the code in BeginDocked() setting the same field. + if (window->LastFrameJustFocused == g.FrameCount) window->HiddenFramesCannotSkipItems = 1; else window->HiddenFramesCanSkipItems = 1; @@ -13527,14 +13531,6 @@ void ImGui::BeginDocked(ImGuiWindow* window, bool* p_open) if (node->VisibleWindow == window) window->DockTabIsVisible = true; - // When we are about to select this tab (which will only be visible on the _next frame_), flag it with a non-zero HiddenFramesCannotSkipItems. - // This will have the important effect of actually returning true in Begin() and not setting SkipItems, allowing an earlier submission of the window contents. - // This is analogous to regular windows being hidden from one frame. It is especially important as nested TabBars would otherwise generate flicker in the form - // of one empty frame. - // Note that we set HiddenFramesCannotSkipItems=2 because BeginDocked() is called just before Begin() has a chance to decrement the value. Effectively it'll be a 1 frame thing. - if (!window->DockTabIsVisible && node->TabBar && node->TabBar->NextSelectedTabId == window->ID) - window->HiddenFramesCannotSkipItems = 2; - // Update window flag IM_ASSERT((window->Flags & ImGuiWindowFlags_ChildWindow) == 0); window->Flags |= ImGuiWindowFlags_ChildWindow | ImGuiWindowFlags_AlwaysUseWindowPadding | ImGuiWindowFlags_NoResize;