diff --git a/imgui.cpp b/imgui.cpp index 72b34c396..c70479601 100644 --- a/imgui.cpp +++ b/imgui.cpp @@ -4149,9 +4149,9 @@ void ImGui::FocusWindow(ImGuiWindow* window) if (g.ActiveId != 0 && g.ActiveIdWindow && g.ActiveIdWindow->RootWindow != window) ImGui::SetActiveID(0); - if (g.Windows.back() == window) + // Bring to front + if ((window->Flags & ImGuiWindowFlags_NoBringToFrontOnFocus) || g.Windows.back() == window) return; - for (int i = 0; i < g.Windows.Size; i++) if (g.Windows[i] == window) { diff --git a/imgui.h b/imgui.h index e4296aa42..b83fd9fef 100644 --- a/imgui.h +++ b/imgui.h @@ -458,6 +458,7 @@ enum ImGuiWindowFlags_ ImGuiWindowFlags_MenuBar = 1 << 10, // Has a menu-bar ImGuiWindowFlags_HorizontalScrollbar = 1 << 11, // Enable horizontal scrollbar (off by default). You need to use SetNextWindowContentSize(ImVec2(width,0.0f)); prior to calling Begin() to specify width. Read code in imgui_demo in the "Horizontal Scrolling" section. ImGuiWindowFlags_NoFocusOnAppearing = 1 << 12, // Disable taking focus when transitioning from hidden to visible state + ImGuiWindowFlags_NoBringToFrontOnFocus = 1 << 13, // Disable bringing window to front when taking focus (e.g. clicking on it or programatically giving it focus) // [Internal] ImGuiWindowFlags_ChildWindow = 1 << 20, // Don't use! For internal use by BeginChild() ImGuiWindowFlags_ChildWindowAutoFitX = 1 << 21, // Don't use! For internal use by BeginChild()