From d9fda227637065f07f419ab5ec0669dfbd016e76 Mon Sep 17 00:00:00 2001 From: omar Date: Thu, 20 Dec 2018 22:33:51 +0100 Subject: [PATCH] Viewport: Fixed not clearing request flags in main viewport, which led some back-end (SDL) to break on resize as PlatformRequestResize would stay true forever and inhibit new sizes passed to AddUpdateViewport(). (#1542) --- imgui.cpp | 5 +++-- imgui_internal.h | 9 +++++---- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/imgui.cpp b/imgui.cpp index 6eeea325..a69763fa 100644 --- a/imgui.cpp +++ b/imgui.cpp @@ -3818,6 +3818,7 @@ void ImGui::EndFrame() IM_ASSERT(viewport->Window != NULL); g.PlatformIO.Viewports.push_back(viewport); } + g.Viewports[0]->ClearRequestFlags(); // Clear main viewport flags because UpdatePlatformWindows() won't do it and may not even be called // Sort the window list so that all child windows are after their parent // We cannot do that on FocusWindow() because childs may not exist yet @@ -7760,7 +7761,7 @@ void ImGui::UpdatePlatformWindows() } // Clear request flags - viewport->PlatformRequestClose = viewport->PlatformRequestMove = viewport->PlatformRequestResize = false; + viewport->ClearRequestFlags(); } // Update our implicit z-order knowledge of platform windows, which is used when the back-end cannot provide io.MouseHoveredViewport. @@ -7865,7 +7866,7 @@ void ImGui::DestroyPlatformWindow(ImGuiViewportP* viewport) viewport->PlatformHandle = NULL; viewport->RendererUserData = viewport->PlatformHandle = NULL; viewport->PlatformWindowCreated = false; - viewport->PlatformRequestClose = viewport->PlatformRequestMove = viewport->PlatformRequestResize = false; + viewport->ClearRequestFlags(); } void ImGui::DestroyPlatformWindows() diff --git a/imgui_internal.h b/imgui_internal.h index dc0e7815..56f4f352 100644 --- a/imgui_internal.h +++ b/imgui_internal.h @@ -672,10 +672,11 @@ struct ImGuiViewportP : public ImGuiViewport ImVec2 LastPlatformSize; ImVec2 LastRendererSize; - ImGuiViewportP() { Idx = -1; LastFrameActive = LastFrameOverlayDrawList = LastFrontMostStampCount = -1; LastNameHash = 0; Alpha = LastAlpha = 1.0f; PlatformMonitor = -1; PlatformWindowCreated = PlatformWindowMinimized = false; Window = NULL; OverlayDrawList = NULL; LastPlatformPos = LastPlatformSize = LastRendererSize = ImVec2(FLT_MAX, FLT_MAX); } - ~ImGuiViewportP() { if (OverlayDrawList) IM_DELETE(OverlayDrawList); } - ImRect GetRect() const { return ImRect(Pos.x, Pos.y, Pos.x + Size.x, Pos.y + Size.y); } - ImVec2 GetCenter() const{ return ImVec2(Pos.x + Size.x * 0.5f, Pos.y + Size.y * 0.5f); } + ImGuiViewportP() { Idx = -1; LastFrameActive = LastFrameOverlayDrawList = LastFrontMostStampCount = -1; LastNameHash = 0; Alpha = LastAlpha = 1.0f; PlatformMonitor = -1; PlatformWindowCreated = PlatformWindowMinimized = false; Window = NULL; OverlayDrawList = NULL; LastPlatformPos = LastPlatformSize = LastRendererSize = ImVec2(FLT_MAX, FLT_MAX); } + ~ImGuiViewportP() { if (OverlayDrawList) IM_DELETE(OverlayDrawList); } + ImRect GetRect() const { return ImRect(Pos.x, Pos.y, Pos.x + Size.x, Pos.y + Size.y); } + ImVec2 GetCenter() const { return ImVec2(Pos.x + Size.x * 0.5f, Pos.y + Size.y * 0.5f); } + void ClearRequestFlags() { PlatformRequestClose = PlatformRequestMove = PlatformRequestResize = false; } }; struct ImGuiNavMoveResult