MCPcopy Create free account
hub / github.com/KebsCS/KBotExt / UpdateMouseMovingWindowEndFrame

Method UpdateMouseMovingWindowEndFrame

KBotExt/imgui/imgui.cpp:4366–4416  ·  view source on GitHub ↗

Initiate moving window when clicking on empty space or title bar. Handle left-click and right-click focus.

Source from the content-addressed store, hash-verified

4364// Initiate moving window when clicking on empty space or title bar.
4365// Handle left-click and right-click focus.
4366void ImGui::UpdateMouseMovingWindowEndFrame()
4367{
4368 ImGuiContext& g = *GImGui;
4369 if (g.ActiveId != 0 || g.HoveredId != 0)
4370 return;
4371
4372 // Unless we just made a window/popup appear
4373 if (g.NavWindow && g.NavWindow->Appearing)
4374 return;
4375
4376 // Click on empty space to focus window and start moving
4377 // (after we're done with all our widgets)
4378 if (g.IO.MouseClicked[0])
4379 {
4380 // Handle the edge case of a popup being closed while clicking in its empty space.
4381 // If we try to focus it, FocusWindow() > ClosePopupsOverWindow() will accidentally close any parent popups because they are not linked together any more.
4382 ImGuiWindow* root_window = g.HoveredWindow ? g.HoveredWindow->RootWindow : NULL;
4383 const bool is_closed_popup = root_window && (root_window->Flags & ImGuiWindowFlags_Popup) && !IsPopupOpen(root_window->PopupId, ImGuiPopupFlags_AnyPopupLevel);
4384
4385 if (root_window != NULL && !is_closed_popup)
4386 {
4387 StartMouseMovingWindow(g.HoveredWindow); //-V595
4388
4389 // Cancel moving if clicked outside of title bar
4390 if (g.IO.ConfigWindowsMoveFromTitleBarOnly && !(root_window->Flags & ImGuiWindowFlags_NoTitleBar))
4391 if (!root_window->TitleBarRect().Contains(g.IO.MouseClickedPos[0]))
4392 g.MovingWindow = NULL;
4393
4394 // Cancel moving if clicked over an item which was disabled or inhibited by popups (note that we know HoveredId == 0 already)
4395 if (g.HoveredIdDisabled)
4396 g.MovingWindow = NULL;
4397 }
4398 else if (root_window == NULL && g.NavWindow != NULL)
4399 {
4400 // Clicking on void disable focus
4401 FocusWindow(NULL, ImGuiFocusRequestFlags_UnlessBelowModal);
4402 }
4403 }
4404
4405 // With right mouse button we close popups without changing focus based on where the mouse is aimed
4406 // Instead, focus will be restored to the window under the bottom-most closed popup.
4407 // (The left mouse button path calls FocusWindow on the hovered window, which will lead NewFrame->ClosePopupsOverWindow to trigger)
4408 if (g.IO.MouseClicked[1])
4409 {
4410 // Find the top-most window between HoveredWindow and the top-most Modal Window.
4411 // This is where we can trim the popup stack.
4412 ImGuiWindow* modal = GetTopMostPopupModal();
4413 bool hovered_window_above_modal = g.HoveredWindow && (modal == NULL || IsWindowAbove(g.HoveredWindow, modal));
4414 ClosePopupsOverWindow(hovered_window_above_modal ? g.HoveredWindow : modal, true);
4415 }
4416}
4417
4418static bool IsWindowActiveAndVisible(ImGuiWindow* window)
4419{

Callers

nothing calls this directly

Calls 1

ContainsMethod · 0.80

Tested by

no test coverage detected