Viewport: Fix viewport regression with protruding child window creating their own viewport. (fixes cae4d02, 760c1d95) (#1542)

This commit is contained in:
omar 2018-11-26 14:53:04 +01:00
parent d8ab2c1ac9
commit 379733aba1

View File

@ -7498,6 +7498,10 @@ static void ImGui::UpdateSelectWindowViewport(ImGuiWindow* window)
window->Viewport = AddUpdateViewport(window, window->ID, window->Pos, window->Size, ImGuiViewportFlags_None);
}
// Fallback to default viewport
if (window->Viewport == NULL)
window->Viewport = main_viewport;
// Mark window as allowed to protrude outside of its viewport and into the current monitor
// We need to take account of the possibility that mouse may become invalid.
if (flags & (ImGuiWindowFlags_Tooltip | ImGuiWindowFlags_Popup))
@ -7507,15 +7511,8 @@ static void ImGui::UpdateSelectWindowViewport(ImGuiWindow* window)
bool mouse_valid = IsMousePosValid(&mouse_ref);
if ((window->Appearing || (flags & ImGuiWindowFlags_Tooltip)) && (!use_mouse_ref || mouse_valid))
window->ViewportAllowPlatformMonitorExtend = FindPlatformMonitorForPos((use_mouse_ref && mouse_valid) ? mouse_ref : NavCalcPreferredRefPos());
else
window->ViewportAllowPlatformMonitorExtend = window->Viewport->PlatformMonitor;
}
// Fallback to default viewport
if (window->Viewport == NULL)
window->Viewport = main_viewport;
if (window->ViewportAllowPlatformMonitorExtend < 0)
if (window->ViewportAllowPlatformMonitorExtend < 0 && (flags & ImGuiWindowFlags_ChildWindow) == 0)
window->ViewportAllowPlatformMonitorExtend = window->Viewport->PlatformMonitor;
// Update flags