Viewport: Always be lenient with invalid mouse position during dragging, since they are provided by back-end and technically acceptable inputs + comments. (#1542)

This commit is contained in:
omar 2018-03-01 20:14:55 +01:00
parent d98a5d54aa
commit 00b9e70ba2

View File

@ -5891,7 +5891,7 @@ static void ImGui::UpdateWindowViewport(ImGuiWindow* window, bool window_pos_set
} }
const bool window_is_mouse_tooltip = (flags & ImGuiWindowFlags_Tooltip) && g.NavDisableHighlight && !g.NavDisableMouseHover; const bool window_is_mouse_tooltip = (flags & ImGuiWindowFlags_Tooltip) && g.NavDisableHighlight && !g.NavDisableMouseHover;
const bool window_follow_mouse_viewport = window_is_mouse_tooltip || (g.MovingWindow && g.MovingWindow->RootWindow == window); const bool window_follow_mouse_viewport = (window_is_mouse_tooltip || (g.MovingWindow && g.MovingWindow->RootWindow == window));
bool created_viewport = false; bool created_viewport = false;
@ -5899,17 +5899,15 @@ static void ImGui::UpdateWindowViewport(ImGuiWindow* window, bool window_pos_set
if (g.NextWindowData.ViewportCond) if (g.NextWindowData.ViewportCond)
{ {
window->Viewport = prev_viewport = FindViewportByID(g.NextWindowData.ViewportId); window->Viewport = prev_viewport = FindViewportByID(g.NextWindowData.ViewportId);
window->ViewportId = g.NextWindowData.ViewportId; window->ViewportId = g.NextWindowData.ViewportId; // Store ID even if Viewport isn't resolved.
} }
else if (flags & ImGuiWindowFlags_ChildWindow)// || (flags & ImGuiWindowFlags_Popup)) else if (flags & ImGuiWindowFlags_ChildWindow)// || (flags & ImGuiWindowFlags_Popup))
{ {
IM_ASSERT(window->ParentWindow); IM_ASSERT(window->ParentWindow);
window->Viewport = prev_viewport = window->ParentWindow->Viewport; window->Viewport = prev_viewport = window->ParentWindow->Viewport;
} }
else if (window_follow_mouse_viewport) else if (window_follow_mouse_viewport && IsMousePosValid())
{ {
IM_ASSERT(IsMousePosValid());
// Calculate mouse position in OS/platform coordinates // Calculate mouse position in OS/platform coordinates
if (!window_is_mouse_tooltip && !GetViewportRect(window).Contains(window->Rect())) if (!window_is_mouse_tooltip && !GetViewportRect(window).Contains(window->Rect()))
{ {