From 5af385ea78d13a8390d95590dd557c8e3385278b Mon Sep 17 00:00:00 2001 From: omar Date: Thu, 28 Mar 2019 18:02:03 +0100 Subject: [PATCH] Viewport: Renamed member + added note about a Docking issue with restoring focus. --- imgui.cpp | 12 ++++++++---- imgui_internal.h | 4 ++-- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/imgui.cpp b/imgui.cpp index 9bad7a0a..e54f8e3c 100644 --- a/imgui.cpp +++ b/imgui.cpp @@ -6260,6 +6260,10 @@ void ImGui::FocusPreviousWindowIgnoringOne(ImGuiWindow* ignore_window) if (window != ignore_window && window->WasActive && !(window->Flags & ImGuiWindowFlags_ChildWindow)) if ((window->Flags & (ImGuiWindowFlags_NoMouseInputs | ImGuiWindowFlags_NoNavInputs)) != (ImGuiWindowFlags_NoMouseInputs | ImGuiWindowFlags_NoNavInputs)) { + // FIXME-DOCKING: This is failing (lagging by one frame) for docked windows. + // If A and B are docked into window and B disappear, at the NewFrame() call site window->NavLastChildNavWindow will still point to B. + // We might leverage the tab order implicitly stored in window->DockNodeAsHost->TabBar (essentially the 'most_recently_selected_tab' code in tab bar will do that but on next update) + // to tell which is the "previous" window. Or we may leverage 'LastFrameFocused/LastFrameJustFocused' and have this function handle child window itself? ImGuiWindow* focus_window = NavRestoreLastChildNavWindow(window); FocusWindow(focus_window); return; @@ -10554,8 +10558,8 @@ void ImGui::UpdatePlatformWindows() // Even without focus, we assume the window becomes front-most. // This is useful for our platform z-order heuristic when io.MouseHoveredViewport is not available. - if (viewport->LastFrontMostStampCount != g.WindowsFrontMostStampCount) - viewport->LastFrontMostStampCount = ++g.WindowsFrontMostStampCount; + if (viewport->LastFrontMostStampCount != g.ViewportFrontMostStampCount) + viewport->LastFrontMostStampCount = ++g.ViewportFrontMostStampCount; } // Clear request flags @@ -10576,8 +10580,8 @@ void ImGui::UpdatePlatformWindows() } if (focused_viewport && g.PlatformLastFocusedViewport != focused_viewport->ID) { - if (focused_viewport->LastFrontMostStampCount != g.WindowsFrontMostStampCount) - focused_viewport->LastFrontMostStampCount = ++g.WindowsFrontMostStampCount; + if (focused_viewport->LastFrontMostStampCount != g.ViewportFrontMostStampCount) + focused_viewport->LastFrontMostStampCount = ++g.ViewportFrontMostStampCount; g.PlatformLastFocusedViewport = focused_viewport->ID; } } diff --git a/imgui_internal.h b/imgui_internal.h index 9f735e6b..89d0df5b 100644 --- a/imgui_internal.h +++ b/imgui_internal.h @@ -951,7 +951,6 @@ struct ImGuiContext ImVector CurrentWindowStack; ImGuiStorage WindowsById; int WindowsActiveCount; - int WindowsFrontMostStampCount; // Every time the front-most window changes, we stamp its viewport with an incrementing counter ImGuiWindow* CurrentWindow; // Being drawn into ImGuiWindow* HoveredWindow; // Will catch mouse inputs ImGuiWindow* HoveredRootWindow; // Will catch mouse inputs (for focus/move only) @@ -996,6 +995,7 @@ struct ImGuiContext ImGuiViewportP* MouseViewport; ImGuiViewportP* MouseLastHoveredViewport; // Last known viewport that was hovered by mouse (even if we are not hovering any viewport any more) + honoring the _NoInputs flag. ImGuiID PlatformLastFocusedViewport; // Record of last focused platform window/viewport, when this changes we stamp the viewport as front-most + int ViewportFrontMostStampCount; // Every time the front-most window changes, we stamp its viewport with an incrementing counter // Navigation data (for gamepad/keyboard) ImGuiWindow* NavWindow; // Focused window for navigation. Could be called 'FocusWindow' @@ -1141,7 +1141,6 @@ struct ImGuiContext FrameCount = 0; FrameCountEnded = FrameCountPlatformEnded = FrameCountRendered = -1; WindowsActiveCount = 0; - WindowsFrontMostStampCount = 0; CurrentWindow = NULL; HoveredWindow = NULL; HoveredRootWindow = NULL; @@ -1175,6 +1174,7 @@ struct ImGuiContext CurrentViewport = NULL; MouseViewport = MouseLastHoveredViewport = NULL; PlatformLastFocusedViewport = 0; + ViewportFrontMostStampCount = 0; NavWindow = NULL; NavId = NavActivateId = NavActivateDownId = NavActivatePressedId = NavInputId = 0;