Jelajahi Sumber

Viewports: fixed an issue where window repositioning leading to a monitor change could have the window incorrectly get clamped within the boundaries of its previous monitor. (#8484)

ocornut 4 bulan lalu
induk
melakukan
2d403a1614
2 mengubah file dengan 7 tambahan dan 0 penghapusan
  1. 3 0
      docs/CHANGELOG.txt
  2. 4 0
      imgui.cpp

+ 3 - 0
docs/CHANGELOG.txt

@@ -166,6 +166,9 @@ Docking+Viewports Branch:
 
 - Docking: Removed legacy assert preventing to call DockBuilderSplitNode() on an existing
   split node. This makes using DockBuilder a little more flexible and bearable! (#8472) [@MegaMech]
+- Viewports: fixed an issue where in certain cases, a window repositioning leading 
+  to a monitor change could have the window incorrectly get clamped within the boundaries 
+  of its previous monitor. Would happen e.g. when loading .ini data during runtime. (#8484) 
 - Viewports: fixed an assert when a window load settings with a position outside
   monitor bounds, when there are multiple monitors. (#8393, #8385) [@gaborodriguez]
 - Viewports + Backends: Win32: Fixed setting title bar text when application

+ 4 - 0
imgui.cpp

@@ -16144,11 +16144,15 @@ ImGuiViewportP* ImGui::AddUpdateViewport(ImGuiWindow* window, ImGuiID id, const
     if (viewport)
     {
         // Always update for main viewport as we are already pulling correct platform pos/size (see #4900)
+        ImVec2 prev_pos = viewport->Pos;
+        ImVec2 prev_size = viewport->Size;
         if (!viewport->PlatformRequestMove || viewport->ID == IMGUI_VIEWPORT_DEFAULT_ID)
             viewport->Pos = pos;
         if (!viewport->PlatformRequestResize || viewport->ID == IMGUI_VIEWPORT_DEFAULT_ID)
             viewport->Size = size;
         viewport->Flags = flags | (viewport->Flags & (ImGuiViewportFlags_IsMinimized | ImGuiViewportFlags_IsFocused)); // Preserve existing flags
+        if (prev_pos != viewport->Pos || prev_size != viewport->Size)
+            UpdateViewportPlatformMonitor(viewport);
     }
     else
     {