Internals: Moving window: test mouse validity while translating window + using SetWindowPos().

This commit is contained in:
omar 2018-02-27 22:56:22 +01:00
parent b32bb4e6e3
commit 184a6f1198

View File

@ -3234,13 +3234,13 @@ static void ImGui::UpdateMovingWindow()
KeepAliveID(g.ActiveId); KeepAliveID(g.ActiveId);
IM_ASSERT(g.MovingWindow && g.MovingWindow->RootWindow); IM_ASSERT(g.MovingWindow && g.MovingWindow->RootWindow);
ImGuiWindow* moving_window = g.MovingWindow->RootWindow; ImGuiWindow* moving_window = g.MovingWindow->RootWindow;
if (g.IO.MouseDown[0]) if (g.IO.MouseDown[0] && IsMousePosValid(&g.IO.MousePos))
{ {
ImVec2 pos = g.IO.MousePos - g.ActiveIdClickOffset; ImVec2 pos = g.IO.MousePos - g.ActiveIdClickOffset;
if (moving_window->PosFloat.x != pos.x || moving_window->PosFloat.y != pos.y) if (moving_window->PosFloat.x != pos.x || moving_window->PosFloat.y != pos.y)
{ {
MarkIniSettingsDirty(moving_window); MarkIniSettingsDirty(moving_window);
moving_window->PosFloat = pos; SetWindowPos(moving_window, pos, ImGuiCond_Always);
} }
FocusWindow(g.MovingWindow); FocusWindow(g.MovingWindow);
} }