From e590b5114e5cbe7f4e858548ddf9959827a366af Mon Sep 17 00:00:00 2001 From: ocornut Date: Sat, 20 May 2023 14:21:17 +0200 Subject: [PATCH] Viewports: Fixed loss of imgui-side focus when dragging a secondary viewport back in main viewport. (#6299) Amend d2291df55, 63370be0e, dcb6335bfe --- docs/CHANGELOG.txt | 2 ++ imgui.cpp | 1 + 2 files changed, 3 insertions(+) diff --git a/docs/CHANGELOG.txt b/docs/CHANGELOG.txt index bce96e334..cfc0a0534 100644 --- a/docs/CHANGELOG.txt +++ b/docs/CHANGELOG.txt @@ -153,6 +153,8 @@ Docking+Viewports Branch: - Viewports: Fixed platform-side focus (e.g. Alt+Tab) from leading to accidental closure of Modal windows. Regression from 1.89.5. (#6357, #6299) +- Viewports: Fixed loss of imgui-side focus when dragging a secondary viewport back in + main viewport, due to platform-side handling changes. Regression from 1.89.5 (#6299) - Viewports: Added void* ImGuiPlatformMonitor::PlatformHandle field (backend-dependant), for usage by user code. - Backends: SDL2: Update monitor list when receiving a display event. (#6348) diff --git a/imgui.cpp b/imgui.cpp index f101eafa2..d03d158fd 100644 --- a/imgui.cpp +++ b/imgui.cpp @@ -14000,6 +14000,7 @@ static void ImGui::UpdateViewportsNewFrame() // FIXME: perhaps 'FocusTopMostWindowUnderOne()' can handle the 'focused_window->Window != NULL' case as well. if (!IsAnyMouseDown()) { + focused_viewport->LastFocusedHadNavWindow |= (g.NavWindow != NULL) && (g.NavWindow->Viewport == focused_viewport); // Update so a window changing viewport won't lose focus. ImGuiFocusRequestFlags focus_request_flags = ImGuiFocusRequestFlags_UnlessBelowModal | ImGuiFocusRequestFlags_RestoreFocusedChild; if (focused_viewport->Window != NULL) FocusWindow(focused_viewport->Window, focus_request_flags);