From 87c1ab79883b90b5c8fc9698a8bff0bfb7f1b5c8 Mon Sep 17 00:00:00 2001 From: ocornut Date: Tue, 26 Aug 2025 18:48:08 +0200 Subject: [PATCH] Windows: changed how g.CurrentItemFlags is modified before windows' CloseButton() submission to be less misleading. (#8903) I don't think anyone would have `ImGuiItemFlags_NoFocus` set globally but technically it might. --- imgui.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/imgui.cpp b/imgui.cpp index 18e67eab2..bc4da78ee 100644 --- a/imgui.cpp +++ b/imgui.cpp @@ -7113,10 +7113,11 @@ void ImGui::RenderWindowTitleBarContents(ImGuiWindow* window, const ImRect& titl // Close button if (has_close_button) { + ImGuiItemFlags backup_item_flags = g.CurrentItemFlags; g.CurrentItemFlags |= ImGuiItemFlags_NoFocus; if (CloseButton(window->GetID("#CLOSE"), close_button_pos)) *p_open = false; - g.CurrentItemFlags &= ~ImGuiItemFlags_NoFocus; + g.CurrentItemFlags = backup_item_flags; } window->DC.NavLayerCurrent = ImGuiNavLayer_Main;