From 9852649e972a9d741586e8050fa46cac949b3330 Mon Sep 17 00:00:00 2001 From: omar Date: Tue, 14 Aug 2018 19:17:33 -0700 Subject: [PATCH] Viewport: Initial viewport DpiScale only queried on viewport creation. Because AddUpdateViewport() is called repeatedly on MovingWindow or with ImGuiConfigFlags_ViewportsNoMerge, the DpiScale update would break ImGuiConfigFlags_DpiEnableScaleViewports. (#1542) --- imgui.cpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/imgui.cpp b/imgui.cpp index 33cd67f3..bcb90656 100644 --- a/imgui.cpp +++ b/imgui.cpp @@ -5241,6 +5241,11 @@ ImGuiViewportP* ImGui::AddUpdateViewport(ImGuiWindow* window, ImGuiID id, const // We need to extend the fullscreen clip rect so the OverlayDrawList clip is correct for that the first frame g.DrawListSharedData.ClipRectFullscreen.z = ImMax(g.DrawListSharedData.ClipRectFullscreen.z, viewport->Pos.x + viewport->Size.x); g.DrawListSharedData.ClipRectFullscreen.w = ImMax(g.DrawListSharedData.ClipRectFullscreen.w, viewport->Pos.y + viewport->Size.y); + + // Request an initial DpiScale before the OS platform window creation + // This is so we can select an appropriate font size on the first frame of our window lifetime + if (g.PlatformIO.Platform_GetWindowDpiScale) + viewport->DpiScale = g.PlatformIO.Platform_GetWindowDpiScale(viewport); } viewport->Window = window; @@ -5251,10 +5256,6 @@ ImGuiViewportP* ImGui::AddUpdateViewport(ImGuiWindow* window, ImGuiID id, const if (window != NULL) window->ViewportOwned = true; - // Request an initial DpiScale before the OS platform window creation - // This is so we can select an appropriate font size on the first frame of our window lifetime - if (g.PlatformIO.Platform_GetWindowDpiScale) - viewport->DpiScale = g.PlatformIO.Platform_GetWindowDpiScale(viewport); return viewport; }