Viewports: Fix to avoid SetNextWindowViewport being overrided by creation of a standalone viewport. (#2544, #1542)

This commit is contained in:
omar 2019-05-08 18:20:13 +02:00
parent e6c982509d
commit 9bf3f910c8

View File

@ -10552,11 +10552,13 @@ static void ImGui::UpdateSelectWindowViewport(ImGuiWindow* window)
} }
} }
bool lock_viewport = false;
if (g.NextWindowData.ViewportCond) if (g.NextWindowData.ViewportCond)
{ {
// Code explicitly request a viewport // Code explicitly request a viewport
window->Viewport = (ImGuiViewportP*)FindViewportByID(g.NextWindowData.ViewportId); window->Viewport = (ImGuiViewportP*)FindViewportByID(g.NextWindowData.ViewportId);
window->ViewportId = g.NextWindowData.ViewportId; // Store ID even if Viewport isn't resolved yet. window->ViewportId = g.NextWindowData.ViewportId; // Store ID even if Viewport isn't resolved yet.
lock_viewport = true;
} }
else if ((flags & ImGuiWindowFlags_ChildWindow) || (flags & ImGuiWindowFlags_ChildMenu)) else if ((flags & ImGuiWindowFlags_ChildWindow) || (flags & ImGuiWindowFlags_ChildMenu))
{ {
@ -10590,6 +10592,8 @@ static void ImGui::UpdateSelectWindowViewport(ImGuiWindow* window)
window->Viewport = main_viewport; window->Viewport = main_viewport;
// Mark window as allowed to protrude outside of its viewport and into the current monitor // Mark window as allowed to protrude outside of its viewport and into the current monitor
if (!lock_viewport)
{
if (flags & (ImGuiWindowFlags_Tooltip | ImGuiWindowFlags_Popup)) if (flags & (ImGuiWindowFlags_Tooltip | ImGuiWindowFlags_Popup))
{ {
// We need to take account of the possibility that mouse may become invalid. // We need to take account of the possibility that mouse may become invalid.
@ -10620,10 +10624,13 @@ static void ImGui::UpdateSelectWindowViewport(ImGuiWindow* window)
window->Viewport = AddUpdateViewport(window, window->ID, window->Pos, window->Size, ImGuiViewportFlags_NoFocusOnAppearing); window->Viewport = AddUpdateViewport(window, window->ID, window->Pos, window->Size, ImGuiViewportFlags_NoFocusOnAppearing);
} }
} }
else if (window->ViewportAllowPlatformMonitorExtend < 0 && (flags & ImGuiWindowFlags_ChildWindow) == 0)
{
// Regular (non-child, non-popup) windows by default are also allowed to protrude // Regular (non-child, non-popup) windows by default are also allowed to protrude
// Child windows are kept contained within their parent. // Child windows are kept contained within their parent.
else if (window->ViewportAllowPlatformMonitorExtend < 0 && (flags & ImGuiWindowFlags_ChildWindow) == 0)
window->ViewportAllowPlatformMonitorExtend = window->Viewport->PlatformMonitor; window->ViewportAllowPlatformMonitorExtend = window->Viewport->PlatformMonitor;
}
}
// Update flags // Update flags
window->ViewportOwned = (window == window->Viewport->Window); window->ViewportOwned = (window == window->Viewport->Window);