Moving window to front of display and set focus (which happens to be back of our sorted list)
| 7161 | |
| 7162 | // Moving window to front of display and set focus (which happens to be back of our sorted list) |
| 7163 | void ImGui::FocusWindow(ImGuiWindow* window, ImGuiFocusRequestFlags flags) |
| 7164 | { |
| 7165 | ImGuiContext& g = *GImGui; |
| 7166 | |
| 7167 | // Modal check? |
| 7168 | if ((flags & ImGuiFocusRequestFlags_UnlessBelowModal) && (g.NavWindow != window)) // Early out in common case. |
| 7169 | if (ImGuiWindow* blocking_modal = FindBlockingModal(window)) |
| 7170 | { |
| 7171 | IMGUI_DEBUG_LOG_FOCUS("[focus] FocusWindow(\"%s\", UnlessBelowModal): prevented by \"%s\".\n", window ? window->Name : "<NULL>", blocking_modal->Name); |
| 7172 | if (window && window == window->RootWindow && (window->Flags & ImGuiWindowFlags_NoBringToFrontOnFocus) == 0) |
| 7173 | BringWindowToDisplayBehind(window, blocking_modal); // Still bring to right below modal. |
| 7174 | return; |
| 7175 | } |
| 7176 | |
| 7177 | // Find last focused child (if any) and focus it instead. |
| 7178 | if ((flags & ImGuiFocusRequestFlags_RestoreFocusedChild) && window != NULL) |
| 7179 | window = NavRestoreLastChildNavWindow(window); |
| 7180 | |
| 7181 | // Apply focus |
| 7182 | if (g.NavWindow != window) |
| 7183 | { |
| 7184 | SetNavWindow(window); |
| 7185 | if (window && g.NavDisableMouseHover) |
| 7186 | g.NavMousePosDirty = true; |
| 7187 | g.NavId = window ? window->NavLastIds[0] : 0; // Restore NavId |
| 7188 | g.NavLayer = ImGuiNavLayer_Main; |
| 7189 | g.NavFocusScopeId = window ? window->NavRootFocusScopeId : 0; |
| 7190 | g.NavIdIsAlive = false; |
| 7191 | g.NavLastValidSelectionUserData = ImGuiSelectionUserData_Invalid; |
| 7192 | |
| 7193 | // Close popups if any |
| 7194 | ClosePopupsOverWindow(window, false); |
| 7195 | } |
| 7196 | |
| 7197 | // Move the root window to the top of the pile |
| 7198 | IM_ASSERT(window == NULL || window->RootWindow != NULL); |
| 7199 | ImGuiWindow* focus_front_window = window ? window->RootWindow : NULL; // NB: In docking branch this is window->RootWindowDockStop |
| 7200 | ImGuiWindow* display_front_window = window ? window->RootWindow : NULL; |
| 7201 | |
| 7202 | // Steal active widgets. Some of the cases it triggers includes: |
| 7203 | // - Focus a window while an InputText in another window is active, if focus happens before the old InputText can run. |
| 7204 | // - When using Nav to activate menu items (due to timing of activating on press->new window appears->losing ActiveId) |
| 7205 | if (g.ActiveId != 0 && g.ActiveIdWindow && g.ActiveIdWindow->RootWindow != focus_front_window) |
| 7206 | if (!g.ActiveIdNoClearOnFocusLoss) |
| 7207 | ClearActiveID(); |
| 7208 | |
| 7209 | // Passing NULL allow to disable keyboard focus |
| 7210 | if (!window) |
| 7211 | return; |
| 7212 | |
| 7213 | // Bring to front |
| 7214 | BringWindowToFocusFront(focus_front_window); |
| 7215 | if (((window->Flags | display_front_window->Flags) & ImGuiWindowFlags_NoBringToFrontOnFocus) == 0) |
| 7216 | BringWindowToDisplayFront(display_front_window); |
| 7217 | } |
| 7218 | |
| 7219 | void ImGui::FocusTopMostWindowUnderOne(ImGuiWindow* under_this_window, ImGuiWindow* ignore_window, ImGuiViewport* filter_viewport, ImGuiFocusRequestFlags flags) |
| 7220 | { |
nothing calls this directly
no outgoing calls
no test coverage detected