MCPcopy Create free account
hub / github.com/Raais/ImStudio / UpdateMouseMovingWindowEndFrame

Method UpdateMouseMovingWindowEndFrame

src/third-party/imgui/imgui.cpp:3853–3903  ·  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

3851// Initiate moving window when clicking on empty space or title bar.
3852// Handle left-click and right-click focus.
3853void ImGui::UpdateMouseMovingWindowEndFrame()
3854{
3855 ImGuiContext& g = *GImGui;
3856 if (g.ActiveId != 0 || g.HoveredId != 0)
3857 return;
3858
3859 // Unless we just made a window/popup appear
3860 if (g.NavWindow && g.NavWindow->Appearing)
3861 return;
3862
3863 // Click on empty space to focus window and start moving
3864 // (after we're done with all our widgets)
3865 if (g.IO.MouseClicked[0])
3866 {
3867 // Handle the edge case of a popup being closed while clicking in its empty space.
3868 // If we try to focus it, FocusWindow() > ClosePopupsOverWindow() will accidentally close any parent popups because they are not linked together any more.
3869 ImGuiWindow* root_window = g.HoveredWindow ? g.HoveredWindow->RootWindow : NULL;
3870 const bool is_closed_popup = root_window && (root_window->Flags & ImGuiWindowFlags_Popup) && !IsPopupOpen(root_window->PopupId, ImGuiPopupFlags_AnyPopupLevel);
3871
3872 if (root_window != NULL && !is_closed_popup)
3873 {
3874 StartMouseMovingWindow(g.HoveredWindow); //-V595
3875
3876 // Cancel moving if clicked outside of title bar
3877 if (g.IO.ConfigWindowsMoveFromTitleBarOnly && !(root_window->Flags & ImGuiWindowFlags_NoTitleBar))
3878 if (!root_window->TitleBarRect().Contains(g.IO.MouseClickedPos[0]))
3879 g.MovingWindow = NULL;
3880
3881 // Cancel moving if clicked over an item which was disabled or inhibited by popups (note that we know HoveredId == 0 already)
3882 if (g.HoveredIdDisabled)
3883 g.MovingWindow = NULL;
3884 }
3885 else if (root_window == NULL && g.NavWindow != NULL && GetTopMostPopupModal() == NULL)
3886 {
3887 // Clicking on void disable focus
3888 FocusWindow(NULL);
3889 }
3890 }
3891
3892 // With right mouse button we close popups without changing focus based on where the mouse is aimed
3893 // Instead, focus will be restored to the window under the bottom-most closed popup.
3894 // (The left mouse button path calls FocusWindow on the hovered window, which will lead NewFrame->ClosePopupsOverWindow to trigger)
3895 if (g.IO.MouseClicked[1])
3896 {
3897 // Find the top-most window between HoveredWindow and the top-most Modal Window.
3898 // This is where we can trim the popup stack.
3899 ImGuiWindow* modal = GetTopMostPopupModal();
3900 bool hovered_window_above_modal = g.HoveredWindow && (modal == NULL || IsWindowAbove(g.HoveredWindow, modal));
3901 ClosePopupsOverWindow(hovered_window_above_modal ? g.HoveredWindow : modal, true);
3902 }
3903}
3904
3905static bool IsWindowActiveAndVisible(ImGuiWindow* window)
3906{

Callers

nothing calls this directly

Calls 1

ContainsMethod · 0.80

Tested by

no test coverage detected