From e031fe484c9d1aa827cf0566693a2e224ed279c8 Mon Sep 17 00:00:00 2001 From: ocornut Date: Fri, 2 Oct 2015 19:07:04 +0200 Subject: [PATCH] Added ImGuiWindowFlags_NoBringToFrontOnFocus behavior. --- imgui.cpp | 4 ++-- imgui.h | 1 + 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/imgui.cpp b/imgui.cpp index 72b34c39..c7047960 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 e4296aa4..b83fd9fe 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()