From 0978f00911df253196b0a013b77adc4c8202fdcb Mon Sep 17 00:00:00 2001 From: omar Date: Fri, 19 Jan 2018 15:06:39 +0100 Subject: [PATCH] MovingWindow: Track click offset based on root window (undo 514d30d8cdd659b6af3c93512583a00ee18ecbaf). This should not affect the patch used for #1345 as the RootWindow for Child+Tooltip window points to itself now. --- imgui.cpp | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/imgui.cpp b/imgui.cpp index 7dbc92c1..41ce93da 100644 --- a/imgui.cpp +++ b/imgui.cpp @@ -2393,11 +2393,8 @@ void ImGui::NewFrame() if (g.IO.MouseDown[0]) { // MovingWindow = window we clicked on, could be a child window. We track it to preserve Focus and so that ActiveIdWindow == MovingWindow and ActiveId == MovingWindow->MoveId for consistency. - // actually_moving_window = MovingWindow->RootWindow. ImGuiWindow* actually_moving_window = g.MovingWindow->RootWindow; ImVec2 pos = g.IO.MousePos - g.ActiveIdClickOffset; - if (actually_moving_window != g.MovingWindow) - pos += actually_moving_window->PosFloat - g.MovingWindow->PosFloat; if (actually_moving_window->PosFloat.x != pos.x || actually_moving_window->PosFloat.y != pos.y) { MarkIniSettingsDirty(actually_moving_window); @@ -2979,7 +2976,7 @@ void ImGui::EndFrame() // Set ActiveId even if the _NoMove flag is set, without it dragging away from a window with _NoMove would activate hover on other windows. FocusWindow(g.HoveredWindow); SetActiveID(g.HoveredWindow->MoveId, g.HoveredWindow); - g.ActiveIdClickOffset = g.IO.MousePos - g.HoveredWindow->Pos; + g.ActiveIdClickOffset = g.IO.MousePos - g.HoveredRootWindow->Pos; if (!(g.HoveredWindow->Flags & ImGuiWindowFlags_NoMove) && !(g.HoveredRootWindow->Flags & ImGuiWindowFlags_NoMove)) { g.MovingWindow = g.HoveredWindow;