From bfacbac7c4bdf01e1d5661271e2566010f7945b5 Mon Sep 17 00:00:00 2001 From: omar Date: Wed, 23 Jan 2019 11:05:00 +0100 Subject: [PATCH] Docking: Fix a focusing issue where dock node wouldn't be moved to the front as expected. --- imgui.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/imgui.cpp b/imgui.cpp index 0b7dd3f5..5519019a 100644 --- a/imgui.cpp +++ b/imgui.cpp @@ -11156,6 +11156,15 @@ static void ImGui::DockNodeUpdate(ImGuiDockNode* node) host_window->DC.CursorPos = host_window->Pos; node->Pos = host_window->Pos; node->Size = host_window->Size; + + // We set ImGuiWindowFlags_NoFocusOnAppearing because we don't want the host window to take full focus (e.g. steal NavWindow) + // But we still it bring it to the front of display. There's no way to choose this precise behavior via window flags. + // One simple case to ponder if: window A has a toggle to create windows B/C/D. Dock B/C/D together, clear the toggle and enable it again. + // When reappearing B/C/D will request focus and be moved to the top of the display pile, but they are not linked to the dock host window + // during the frame they appear. The dock host window would keep its old display order, and the sorting in EndFrame would move B/C/D back + // after the dock host window, losing their top-most status. + if (node->HostWindow->Appearing) + BringWindowToDisplayFront(node->HostWindow); } else if (node->ParentNode) {