From dbd9ae287a40e773a6fff364bdd8816ddae9b92b Mon Sep 17 00:00:00 2001 From: ocornut Date: Sun, 23 Mar 2025 12:55:59 +0100 Subject: [PATCH] Windows: fixed SetNextWindowCollapsed()/SetWindowCollapsed() breaking codepath that preserve last contents size when collapsed. (#7691) --- docs/CHANGELOG.txt | 4 ++++ imgui.cpp | 6 ++++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/docs/CHANGELOG.txt b/docs/CHANGELOG.txt index 4d35191a5..0574bfe36 100644 --- a/docs/CHANGELOG.txt +++ b/docs/CHANGELOG.txt @@ -48,6 +48,10 @@ Other changes: - IO: variations in analog-only components of gamepad events do not interfere with trickling of mouse position events (#4921, #8508) +- Windows: fixed SetNextWindowCollapsed()/SetWindowCollapsed() breaking + codepath that preserve last contents size when collapsed, resulting in + programmatically uncollapsing auto-sizing windows having them flicker size + for a frame. (#7691) [@achabense] - Error Handling: added better error report and recovery for extraneous EndPopup() call. (#1651, #8499) - Style, InputText: added ImGuiCol_InputTextCursor to configure color of diff --git a/imgui.cpp b/imgui.cpp index ea813cd92..ba3271c54 100644 --- a/imgui.cpp +++ b/imgui.cpp @@ -8228,8 +8228,10 @@ void ImGui::SetWindowCollapsed(ImGuiWindow* window, bool collapsed, ImGuiCond co return; window->SetWindowCollapsedAllowFlags &= ~(ImGuiCond_Once | ImGuiCond_FirstUseEver | ImGuiCond_Appearing); - // Set - window->Collapsed = collapsed; + // Queue applying in Begin() + if (window->WantCollapseToggle) + window->Collapsed ^= 1; + window->WantCollapseToggle = (window->Collapsed != collapsed); } void ImGui::SetWindowHitTestHole(ImGuiWindow* window, const ImVec2& pos, const ImVec2& size)