Viewports: Fixed loss of imgui-side focus when dragging a secondary viewport back in main viewport. (#6299)

Amend d2291df55, 63370be0e, dcb6335bfe
This commit is contained in:
ocornut 2023-05-20 14:21:17 +02:00
parent 530134d125
commit e590b5114e
2 changed files with 3 additions and 0 deletions

View File

@ -153,6 +153,8 @@ Docking+Viewports Branch:
- Viewports: Fixed platform-side focus (e.g. Alt+Tab) from leading to accidental - Viewports: Fixed platform-side focus (e.g. Alt+Tab) from leading to accidental
closure of Modal windows. Regression from 1.89.5. (#6357, #6299) 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), - Viewports: Added void* ImGuiPlatformMonitor::PlatformHandle field (backend-dependant),
for usage by user code. for usage by user code.
- Backends: SDL2: Update monitor list when receiving a display event. (#6348) - Backends: SDL2: Update monitor list when receiving a display event. (#6348)

View File

@ -14000,6 +14000,7 @@ static void ImGui::UpdateViewportsNewFrame()
// FIXME: perhaps 'FocusTopMostWindowUnderOne()' can handle the 'focused_window->Window != NULL' case as well. // FIXME: perhaps 'FocusTopMostWindowUnderOne()' can handle the 'focused_window->Window != NULL' case as well.
if (!IsAnyMouseDown()) 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; ImGuiFocusRequestFlags focus_request_flags = ImGuiFocusRequestFlags_UnlessBelowModal | ImGuiFocusRequestFlags_RestoreFocusedChild;
if (focused_viewport->Window != NULL) if (focused_viewport->Window != NULL)
FocusWindow(focused_viewport->Window, focus_request_flags); FocusWindow(focused_viewport->Window, focus_request_flags);