From 00b9e70ba2733ac126147f3585ae5488481b70e4 Mon Sep 17 00:00:00 2001 From: omar Date: Thu, 1 Mar 2018 20:14:55 +0100 Subject: [PATCH] Viewport: Always be lenient with invalid mouse position during dragging, since they are provided by back-end and technically acceptable inputs + comments. (#1542) --- imgui.cpp | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/imgui.cpp b/imgui.cpp index cee66bb3..e9f644b2 100644 --- a/imgui.cpp +++ b/imgui.cpp @@ -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_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; @@ -5899,17 +5899,15 @@ static void ImGui::UpdateWindowViewport(ImGuiWindow* window, bool window_pos_set if (g.NextWindowData.ViewportCond) { 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)) { IM_ASSERT(window->ParentWindow); 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 if (!window_is_mouse_tooltip && !GetViewportRect(window).Contains(window->Rect())) {