MCPcopy Create free account
hub / github.com/IppClub/Dora-SSR / UpdateMouseMovingWindowNewFrame

Method UpdateMouseMovingWindowNewFrame

Source/3rdParty/imgui/imgui.cpp:5286–5318  ·  view source on GitHub ↗

Handle mouse moving window Note: moving window with the navigation keys (Square + d-pad / Ctrl+Tab + Arrows) are processed in NavUpdateWindowing() FIXME: We don't have strong guarantee that g.MovingWindow stay synced with g.ActiveId == g.MovingWindow->MoveId. This is currently enforced by the fact that BeginDragDropSource() is setting all g.ActiveIdUsingXXXX flags to inhibit navigation inputs, but

Source from the content-addressed store, hash-verified

5284// This is currently enforced by the fact that BeginDragDropSource() is setting all g.ActiveIdUsingXXXX flags to inhibit navigation inputs,
5285// but if we should more thoroughly test cases where g.ActiveId or g.MovingWindow gets changed and not the other.
5286void ImGui::UpdateMouseMovingWindowNewFrame()
5287{
5288 ImGuiContext& g = *GImGui;
5289 if (g.MovingWindow != NULL)
5290 {
5291 // We actually want to move the root window. g.MovingWindow == window we clicked on (could be a child window).
5292 // We track it to preserve Focus and so that generally ActiveIdWindow == MovingWindow and ActiveId == MovingWindow->MoveId for consistency.
5293 KeepAliveID(g.ActiveId);
5294 IM_ASSERT(g.MovingWindow && g.MovingWindow->RootWindow);
5295 ImGuiWindow* moving_window = g.MovingWindow->RootWindow;
5296 if (g.IO.MouseDown[0] && IsMousePosValid(&g.IO.MousePos))
5297 {
5298 ImVec2 pos = g.IO.MousePos - g.ActiveIdClickOffset;
5299 SetWindowPos(moving_window, pos, ImGuiCond_Always);
5300 FocusWindow(g.MovingWindow);
5301 }
5302 else
5303 {
5304 StopMouseMovingWindow();
5305 ClearActiveID();
5306 }
5307 }
5308 else
5309 {
5310 // When clicking/dragging from a window that has the _NoMove flag, we still set the ActiveId in order to prevent hovering others.
5311 if (g.ActiveIdWindow && g.ActiveIdWindow->MoveId == g.ActiveId)
5312 {
5313 KeepAliveID(g.ActiveId);
5314 if (!g.IO.MouseDown[0])
5315 ClearActiveID();
5316 }
5317 }
5318}
5319
5320// Initiate focusing and moving window when clicking on empty space or title bar.
5321// Initiate focusing window when clicking on a disabled item.

Callers

nothing calls this directly

Calls 1

SetWindowPosFunction · 0.85

Tested by

no test coverage detected