Internals: made MousePos an argument of UpdateHoveredWindowAndCaptureFlags(). (#8431, #1152)

This commit is contained in:
ocornut
2025-03-21 17:21:22 +01:00
parent f5003aff69
commit ca3ba28768
2 changed files with 4 additions and 4 deletions

View File

@@ -5058,7 +5058,7 @@ static bool IsWindowActiveAndVisible(ImGuiWindow* window)
}
// The reason this is exposed in imgui_internal.h is: on touch-based system that don't have hovering, we want to dispatch inputs to the right target (imgui vs imgui+app)
void ImGui::UpdateHoveredWindowAndCaptureFlags()
void ImGui::UpdateHoveredWindowAndCaptureFlags(const ImVec2& mouse_pos)
{
ImGuiContext& g = *GImGui;
ImGuiIO& io = g.IO;
@@ -5072,7 +5072,7 @@ void ImGui::UpdateHoveredWindowAndCaptureFlags()
// - When moving a window we can skip the search, which also conveniently bypasses the fact that window->WindowRectClipped is lagging as this point of the frame.
// - We also support the moved window toggling the NoInputs flag after moving has started in order to be able to detect windows below it, which is useful for e.g. docking mechanisms.
bool clear_hovered_windows = false;
FindHoveredWindowEx(g.IO.MousePos, false, &g.HoveredWindow, &g.HoveredWindowUnderMovingWindow);
FindHoveredWindowEx(mouse_pos, false, &g.HoveredWindow, &g.HoveredWindowUnderMovingWindow);
g.HoveredWindowBeforeClear = g.HoveredWindow;
// Modal windows prevents mouse from hovering behind them.
@@ -5343,7 +5343,7 @@ void ImGui::NewFrame()
// Find hovered window
// (needs to be before UpdateMouseMovingWindowNewFrame so we fill g.HoveredWindowUnderMovingWindow on the mouse release frame)
// (currently needs to be done after the WasActive=Active loop and FindHoveredWindowEx uses ->Active)
UpdateHoveredWindowAndCaptureFlags();
UpdateHoveredWindowAndCaptureFlags(g.IO.MousePos);
// Handle user moving window with mouse (at the beginning of the frame to avoid input lag or sheering)
UpdateMouseMovingWindowNewFrame();