From c1743eef48432a08438de0926a6fc657e5ce2d11 Mon Sep 17 00:00:00 2001 From: ocornut Date: Mon, 15 Apr 2024 11:42:51 +0200 Subject: [PATCH] Docking: when io.ConfigDockingWithShift is enabled, fixed help tooltip erroneously reading SetNextWindowXXX() data. (#6709, #4643, #7491) --- docs/CHANGELOG.txt | 14 ++++++++++++++ imgui.cpp | 6 +++++- 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/docs/CHANGELOG.txt b/docs/CHANGELOG.txt index b014d039..8ef1744b 100644 --- a/docs/CHANGELOG.txt +++ b/docs/CHANGELOG.txt @@ -35,6 +35,20 @@ HOW TO UPDATE? and API updates have been a little more frequent lately. They are documented below and in imgui.cpp and should not affect all users. - Please report any issue! +----------------------------------------------------------------------- + VERSION 1.90.6 WIP (In Progress) +----------------------------------------------------------------------- + +Breaking changes: + +Other changes: + +Docking+Viewports Branch: + +- Docking: when io.ConfigDockingWithShift is enabled, fixed help tooltip erroneously + reading SetNextWindowXXX() data. (#6709, #4643, #7491) [@ocornut, @cfillion] + + ----------------------------------------------------------------------- VERSION 1.90.5 (Released 2024-04-11) ----------------------------------------------------------------------- diff --git a/imgui.cpp b/imgui.cpp index d74843d7..1e3cce9b 100644 --- a/imgui.cpp +++ b/imgui.cpp @@ -7445,6 +7445,9 @@ bool ImGui::Begin(const char* name, bool* p_open, ImGuiWindowFlags flags) if (window->AutoFitFramesY > 0) window->AutoFitFramesY--; + // Clear SetNextWindowXXX data (can aim to move this higher in the function) + g.NextWindowData.ClearFlags(); + // Apply focus (we need to call FocusWindow() AFTER setting DC.CursorStartPos so our initial navigation reference rectangle can start around there) // We ImGuiFocusRequestFlags_UnlessBelowModal to: // - Avoid focusing a window that is created outside of a modal. This will prevent active modal from being closed. @@ -7517,6 +7520,7 @@ bool ImGui::Begin(const char* name, bool* p_open, ImGuiWindowFlags flags) // Append SetCurrentViewport(window, window->Viewport); SetCurrentWindow(window); + g.NextWindowData.ClearFlags(); } if (!(flags & ImGuiWindowFlags_DockNodeHost)) @@ -7525,7 +7529,6 @@ bool ImGui::Begin(const char* name, bool* p_open, ImGuiWindowFlags flags) // Clear 'accessed' flag last thing (After PushClipRect which will set the flag. We want the flag to stay false when the default "Debug" window is unused) window->WriteAccessed = false; window->BeginCount++; - g.NextWindowData.ClearFlags(); // Update visibility if (first_begin_of_the_frame) @@ -19143,6 +19146,7 @@ void ImGui::BeginDockableDragDropSource(ImGuiWindow* window) // When ConfigDockingWithShift is set, display a tooltip to increase UI affordance. // We cannot set for HoveredWindowUnderMovingWindow != NULL here, as it is only valid/useful when drag and drop is already active // (because of the 'is_mouse_dragging_with_an_expected_destination' logic in UpdateViewportsNewFrame() function) + IM_ASSERT(g.NextWindowData.Flags == 0); if (g.IO.ConfigDockingWithShift && g.MouseStationaryTimer >= 1.0f && g.ActiveId >= 1.0f) SetTooltip("%s", LocalizeGetMsg(ImGuiLocKey_DockingHoldShiftToDock)); return;