Ver Fonte

Nav: Use Platform_SetWindowFocus when CTRL+Tabbing to another viewport.

omar há 7 anos atrás
pai
commit
5eabf44021
1 ficheiros alterados com 5 adições e 0 exclusões
  1. 5 0
      imgui.cpp

+ 5 - 0
imgui.cpp

@@ -8603,6 +8603,7 @@ static void ImGui::NavUpdateWindowing()
     // Apply final focus
     // Apply final focus
     if (apply_focus_window && (g.NavWindow == NULL || apply_focus_window != g.NavWindow->RootWindow))
     if (apply_focus_window && (g.NavWindow == NULL || apply_focus_window != g.NavWindow->RootWindow))
     {
     {
+        ImGuiViewport* previous_viewport = g.NavWindow ? g.NavWindow->Viewport : NULL;
         g.NavDisableHighlight = false;
         g.NavDisableHighlight = false;
         g.NavDisableMouseHover = true;
         g.NavDisableMouseHover = true;
         apply_focus_window = NavRestoreLastChildNavWindow(apply_focus_window);
         apply_focus_window = NavRestoreLastChildNavWindow(apply_focus_window);
@@ -8614,6 +8615,10 @@ static void ImGui::NavUpdateWindowing()
         // If the window only has a menu layer, select it directly
         // If the window only has a menu layer, select it directly
         if (apply_focus_window->DC.NavLayerActiveMask == (1 << 1))
         if (apply_focus_window->DC.NavLayerActiveMask == (1 << 1))
             g.NavLayer = 1;
             g.NavLayer = 1;
+
+        // Request OS level focus
+        if (apply_focus_window->Viewport != previous_viewport && g.PlatformIO.Platform_SetWindowFocus)
+            g.PlatformIO.Platform_SetWindowFocus(apply_focus_window->Viewport);
     }
     }
     if (apply_focus_window)
     if (apply_focus_window)
         g.NavWindowingTarget = NULL;
         g.NavWindowingTarget = NULL;