1
0
Fork 0
mirror of https://github.com/ocornut/imgui.git synced 2026-01-26 02:34:23 +00:00

Docking+Viewports: Fixed extraneous viewport+platform-window recreation. Part 1.

Part 1: Add counters. Amend logs.
Refer to "viewport_owner_change_1" and "viewport_owner_change_2" in ImGuiTestSuite.
This commit is contained in:
ocornut 2023-06-23 15:40:54 +02:00
parent 7d81a166f9
commit 66c09fc05b
3 changed files with 12 additions and 0 deletions

View file

@ -3631,6 +3631,7 @@ void ImGui::Initialize()
viewport->Flags = ImGuiViewportFlags_OwnedByApp;
g.Viewports.push_back(viewport);
g.TempBuffer.resize(1024 * 3 + 1, 0);
g.ViewportCreatedCount++;
g.PlatformIO.Viewports.push_back(g.Viewports[0]);
#ifdef IMGUI_HAS_DOCK
@ -14373,6 +14374,7 @@ ImGuiViewportP* ImGui::AddUpdateViewport(ImGuiWindow* window, ImGuiID id, const
viewport->Flags = flags;
UpdateViewportPlatformMonitor(viewport);
g.Viewports.push_back(viewport);
g.ViewportCreatedCount++;
IMGUI_DEBUG_LOG_VIEWPORT("[viewport] Add Viewport %08X '%s'\n", id, window ? window->Name : "<NULL>");
// We normally setup for all viewports in NewFrame() but here need to handle the mid-frame creation of a new viewport.
@ -14685,6 +14687,7 @@ void ImGui::UpdatePlatformWindows()
g.PlatformIO.Platform_CreateWindow(viewport);
if (g.PlatformIO.Renderer_CreateWindow != NULL)
g.PlatformIO.Renderer_CreateWindow(viewport);
g.PlatformWindowsCreatedCount++;
viewport->LastNameHash = 0;
viewport->LastPlatformPos = viewport->LastPlatformSize = ImVec2(FLT_MAX, FLT_MAX); // By clearing those we'll enforce a call to Platform_SetWindowPos/Size below, before Platform_ShowWindow (FIXME: Is that necessary?)
viewport->LastRendererSize = viewport->Size; // We don't need to call Renderer_SetWindowSize() as it is expected Renderer_CreateWindow() already did it.
@ -16254,6 +16257,7 @@ static void ImGui::DockNodeUpdate(ImGuiDockNode* node)
FocusWindow(single_window);
if (node->HostWindow)
{
IMGUI_DEBUG_LOG_VIEWPORT("[viewport] Node %08X transfer Viewport %08X->%08X to Window '%s'\n", node->ID, node->HostWindow->Viewport->ID, single_window->ID, single_window->Name);
single_window->Viewport = node->HostWindow->Viewport;
single_window->ViewportId = node->HostWindow->ViewportId;
if (node->HostWindow->ViewportOwned)