From e7dca4fec2c4b55731103b7a7a3b2dcb7617a444 Mon Sep 17 00:00:00 2001 From: David Maas Date: Wed, 13 Mar 2019 00:57:15 -0500 Subject: [PATCH] Fixed main viewport not being marked as created, which broke updating the IME input position for the main viewport. This change also removes the logic scattered about that compensated for PlatformWindowCreated being wrong for the main viewport. --- imgui.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/imgui.cpp b/imgui.cpp index 53316f2c..4b1b9f77 100644 --- a/imgui.cpp +++ b/imgui.cpp @@ -3790,6 +3790,7 @@ void ImGui::Initialize(ImGuiContext* context) ImGuiViewportP* viewport = IM_NEW(ImGuiViewportP)(); viewport->ID = IMGUI_VIEWPORT_DEFAULT_ID; viewport->Idx = 0; + viewport->PlatformWindowCreated = true; g.Viewports.push_back(viewport); g.PlatformIO.MainViewport = g.Viewports[0]; // Make it accessible in public-facing GetPlatformIO() immediately (before the first call to EndFrame) g.PlatformIO.Viewports.push_back(g.Viewports[0]); @@ -10078,7 +10079,7 @@ static void ImGui::UpdateViewportsNewFrame() for (int n = 0; n < g.Viewports.Size; n++) { ImGuiViewportP* viewport = g.Viewports[n]; - const bool platform_funcs_available = (n == 0 || viewport->PlatformWindowCreated); + const bool platform_funcs_available = viewport->PlatformWindowCreated; if ((g.ConfigFlagsForFrame & ImGuiConfigFlags_ViewportsEnable)) if (g.PlatformIO.Platform_GetWindowMinimized && platform_funcs_available) viewport->PlatformWindowMinimized = g.PlatformIO.Platform_GetWindowMinimized(viewport); @@ -10124,7 +10125,7 @@ static void ImGui::UpdateViewportsNewFrame() continue; } - const bool platform_funcs_available = (n == 0 || viewport->PlatformWindowCreated); + const bool platform_funcs_available = viewport->PlatformWindowCreated; if ((g.ConfigFlagsForFrame & ImGuiConfigFlags_ViewportsEnable)) { // Update Position and Size (from Platform Window to ImGui) if requested. @@ -10535,7 +10536,7 @@ void ImGui::UpdatePlatformWindows() for (int n = 0; n < g.Viewports.Size && focused_viewport == NULL; n++) { ImGuiViewportP* viewport = g.Viewports[n]; - if (n == 0 || viewport->PlatformWindowCreated) + if (viewport->PlatformWindowCreated) if (g.PlatformIO.Platform_GetWindowFocus(viewport)) focused_viewport = viewport; }