Skip to content

Commit f0fe195

Browse files
committed
Focus: merge extra param for FocusTopMostWindowUnderOne() from docking branch to facilitate merge.
1 parent 00d3f92 commit f0fe195

File tree

3 files changed

+14
-12
lines changed

3 files changed

+14
-12
lines changed

imgui.cpp

+12-10
Original file line numberDiff line numberDiff line change
@@ -4624,7 +4624,7 @@ void ImGui::NewFrame()
46244624

46254625
// Closing the focused window restore focus to the first active root window in descending z-order
46264626
if (g.NavWindow && !g.NavWindow->WasActive)
4627-
FocusTopMostWindowUnderOne(NULL, NULL);
4627+
FocusTopMostWindowUnderOne(NULL, NULL, NULL);
46284628

46294629
// No window should be open at the beginning of the frame.
46304630
// But in order to allow the user to call NewFrame() multiple times without calling Render(), we are doing an explicit clear.
@@ -6968,9 +6968,10 @@ void ImGui::FocusWindow(ImGuiWindow* window)
69686968
BringWindowToDisplayFront(display_front_window);
69696969
}
69706970

6971-
void ImGui::FocusTopMostWindowUnderOne(ImGuiWindow* under_this_window, ImGuiWindow* ignore_window)
6971+
void ImGui::FocusTopMostWindowUnderOne(ImGuiWindow* under_this_window, ImGuiWindow* ignore_window, ImGuiViewport* filter_viewport)
69726972
{
69736973
ImGuiContext& g = *GImGui;
6974+
IM_UNUSED(filter_viewport); // Unused in master branch.
69746975
int start_idx = g.WindowsFocusOrder.Size - 1;
69756976
if (under_this_window != NULL)
69766977
{
@@ -6988,13 +6989,14 @@ void ImGui::FocusTopMostWindowUnderOne(ImGuiWindow* under_this_window, ImGuiWind
69886989
// We may later decide to test for different NoXXXInputs based on the active navigation input (mouse vs nav) but that may feel more confusing to the user.
69896990
ImGuiWindow* window = g.WindowsFocusOrder[i];
69906991
IM_ASSERT(window == window->RootWindow);
6991-
if (window != ignore_window && window->WasActive)
6992-
if ((window->Flags & (ImGuiWindowFlags_NoMouseInputs | ImGuiWindowFlags_NoNavInputs)) != (ImGuiWindowFlags_NoMouseInputs | ImGuiWindowFlags_NoNavInputs))
6993-
{
6994-
ImGuiWindow* focus_window = NavRestoreLastChildNavWindow(window);
6995-
FocusWindow(focus_window);
6996-
return;
6997-
}
6992+
if (window == ignore_window || !window->WasActive)
6993+
continue;
6994+
if ((window->Flags & (ImGuiWindowFlags_NoMouseInputs | ImGuiWindowFlags_NoNavInputs)) != (ImGuiWindowFlags_NoMouseInputs | ImGuiWindowFlags_NoNavInputs))
6995+
{
6996+
ImGuiWindow* focus_window = NavRestoreLastChildNavWindow(window);
6997+
FocusWindow(focus_window);
6998+
return;
6999+
}
69987000
}
69997001
FocusWindow(NULL);
70007002
}
@@ -10261,7 +10263,7 @@ void ImGui::ClosePopupToLevel(int remaining, bool restore_focus_to_window_under_
1026110263
if (focus_window && !focus_window->WasActive && popup_window)
1026210264
{
1026310265
// Fallback
10264-
FocusTopMostWindowUnderOne(popup_window, NULL);
10266+
FocusTopMostWindowUnderOne(popup_window, NULL, NULL);
1026510267
}
1026610268
else
1026710269
{

imgui_internal.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -2752,7 +2752,7 @@ namespace ImGui
27522752

27532753
// Windows: Display Order and Focus Order
27542754
IMGUI_API void FocusWindow(ImGuiWindow* window);
2755-
IMGUI_API void FocusTopMostWindowUnderOne(ImGuiWindow* under_this_window, ImGuiWindow* ignore_window);
2755+
IMGUI_API void FocusTopMostWindowUnderOne(ImGuiWindow* under_this_window, ImGuiWindow* ignore_window, ImGuiViewport* filter_viewport);
27562756
IMGUI_API void BringWindowToFocusFront(ImGuiWindow* window);
27572757
IMGUI_API void BringWindowToDisplayFront(ImGuiWindow* window);
27582758
IMGUI_API void BringWindowToDisplayBack(ImGuiWindow* window);

imgui_widgets.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -7084,7 +7084,7 @@ void ImGui::EndMainMenuBar()
70847084
// FIXME: With this strategy we won't be able to restore a NULL focus.
70857085
ImGuiContext& g = *GImGui;
70867086
if (g.CurrentWindow == g.NavWindow && g.NavLayer == ImGuiNavLayer_Main && !g.NavAnyRequest)
7087-
FocusTopMostWindowUnderOne(g.NavWindow, NULL);
7087+
FocusTopMostWindowUnderOne(g.NavWindow, NULL, NULL);
70887088

70897089
End();
70907090
}

0 commit comments

Comments
 (0)