mirror of
https://github.com/ocornut/imgui.git
synced 2024-12-05 06:57:13 +08:00
Viewport, Platform: Fixed a crash if the back-end set the PlatformRequestMove/PlatformRequestSize flags while viewports were disabled (it happened in the SDL back-end, and generally we want to tolerate it to make back-end implementation simpler). (#1542)
This commit is contained in:
parent
1176460e44
commit
ed84b2aaeb
31
imgui.cpp
31
imgui.cpp
@ -3555,22 +3555,25 @@ static void ImGui::UpdateViewports()
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Apply Position and Size (from Platform Window to ImGui) if requested.
|
if ((g.IO.ConfigFlags & ImGuiConfigFlags_ViewportsEnable))
|
||||||
// We do it early in the frame instead of waiting for UpdatePlatformWindows() to avoid a frame of lag when moving/resizing using OS facilities.
|
{
|
||||||
if (viewport->PlatformRequestMove)
|
// Apply Position and Size (from Platform Window to ImGui) if requested.
|
||||||
viewport->Pos = g.PlatformIO.Platform_GetWindowPos(viewport);
|
// We do it early in the frame instead of waiting for UpdatePlatformWindows() to avoid a frame of lag when moving/resizing using OS facilities.
|
||||||
if (viewport->PlatformRequestResize)
|
if (viewport->PlatformRequestMove)
|
||||||
viewport->Size = g.PlatformIO.Platform_GetWindowSize(viewport);
|
viewport->Pos = g.PlatformIO.Platform_GetWindowPos(viewport);
|
||||||
|
if (viewport->PlatformRequestResize)
|
||||||
|
viewport->Size = g.PlatformIO.Platform_GetWindowSize(viewport);
|
||||||
|
|
||||||
// Translate imgui windows when a Host Viewport has been moved
|
// Translate imgui windows when a Host Viewport has been moved
|
||||||
ImVec2 delta = viewport->Pos - viewport->LastPos;
|
ImVec2 delta = viewport->Pos - viewport->LastPos;
|
||||||
if ((viewport->Flags & ImGuiViewportFlags_CanHostOtherWindows) && (delta.x != 0.0f || delta.y != 0.0f))
|
if ((viewport->Flags & ImGuiViewportFlags_CanHostOtherWindows) && (delta.x != 0.0f || delta.y != 0.0f))
|
||||||
for (int window_n = 0; window_n < g.Windows.Size; window_n++)
|
for (int window_n = 0; window_n < g.Windows.Size; window_n++)
|
||||||
if (g.Windows[window_n]->Viewport == viewport)
|
if (g.Windows[window_n]->Viewport == viewport)
|
||||||
TranslateWindow(g.Windows[window_n], delta);
|
TranslateWindow(g.Windows[window_n], delta);
|
||||||
|
|
||||||
// Update monitor (we'll use this info to clamp windows and save windows lost in a removed monitor)
|
// Update monitor (we'll use this info to clamp windows and save windows lost in a removed monitor)
|
||||||
viewport->PlatformMonitor = FindPlatformMonitorForRect(viewport->GetRect());
|
viewport->PlatformMonitor = FindPlatformMonitorForRect(viewport->GetRect());
|
||||||
|
}
|
||||||
|
|
||||||
// Update DPI scale
|
// Update DPI scale
|
||||||
float new_dpi_scale;
|
float new_dpi_scale;
|
||||||
|
Loading…
Reference in New Issue
Block a user