Переглянути джерело

Viewport: Fixed minimization of main viewport leading to it being omitted from platform_io.Viewport list where the users assume it is at index 0. Fix d8ab2c1ac. It wasn't a problem when other viewports were child of the main viewport because they would all be minimized together. (#1542)

omar 6 роки тому
батько
коміт
05bc323be0
1 змінених файлів з 2 додано та 5 видалено
  1. 2 5
      imgui.cpp

+ 2 - 5
imgui.cpp

@@ -7419,7 +7419,6 @@ static void ImGui::UpdateViewportsNewFrame()
     ImGuiContext& g = *GImGui;
     IM_ASSERT(g.PlatformIO.Viewports.Size <= g.Viewports.Size);
 
-    // Update main viewport with current platform position and size
     ImGuiViewportP* main_viewport = g.Viewports[0];
     IM_ASSERT(main_viewport->ID == IMGUI_VIEWPORT_DEFAULT_ID);
     IM_ASSERT(main_viewport->Window == NULL);
@@ -7461,9 +7460,6 @@ static void ImGui::UpdateViewportsNewFrame()
         const bool platform_funcs_available = (n == 0 || viewport->PlatformWindowCreated);
         if ((g.ConfigFlagsForFrame & ImGuiConfigFlags_ViewportsEnable))
         {
-            if (g.PlatformIO.Platform_GetWindowMinimized && platform_funcs_available)
-                viewport->PlatformWindowMinimized = g.PlatformIO.Platform_GetWindowMinimized(viewport);
-
             // Update Position and Size (from Platform Window to ImGui) if requested. 
             // We do it early in the frame instead of waiting for UpdatePlatformWindows() to avoid a frame of lag when moving/resizing using OS facilities.
             if (!viewport->PlatformWindowMinimized && platform_funcs_available)
@@ -7577,7 +7573,8 @@ static void ImGui::UpdateViewportsEndFrame()
         ImGuiViewportP* viewport = g.Viewports[i];
         viewport->LastPos = viewport->Pos;
         if (viewport->LastFrameActive < g.FrameCount || viewport->Size.x <= 0.0f || viewport->Size.y <= 0.0f)
-            continue;
+            if (i > 0) // Always include main viewport in the list
+                continue;
         if (viewport->Window && !IsWindowActiveAndVisible(viewport->Window))
             continue;
         if (i > 0)