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)
| 4422 | |
| 4423 | // 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) |
| 4424 | void ImGui::UpdateHoveredWindowAndCaptureFlags() |
| 4425 | { |
| 4426 | ImGuiContext& g = *GImGui; |
| 4427 | ImGuiIO& io = g.IO; |
| 4428 | g.WindowsHoverPadding = ImMax(g.Style.TouchExtraPadding, ImVec2(WINDOWS_HOVER_PADDING, WINDOWS_HOVER_PADDING)); |
| 4429 | |
| 4430 | // Find the window hovered by mouse: |
| 4431 | // - Child windows can extend beyond the limit of their parent so we need to derive HoveredRootWindow from HoveredWindow. |
| 4432 | // - 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. |
| 4433 | // - 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. |
| 4434 | bool clear_hovered_windows = false; |
| 4435 | FindHoveredWindow(); |
| 4436 | |
| 4437 | // Modal windows prevents mouse from hovering behind them. |
| 4438 | ImGuiWindow* modal_window = GetTopMostPopupModal(); |
| 4439 | if (modal_window && g.HoveredWindow && !IsWindowWithinBeginStackOf(g.HoveredWindow->RootWindow, modal_window)) |
| 4440 | clear_hovered_windows = true; |
| 4441 | |
| 4442 | // Disabled mouse? |
| 4443 | if (io.ConfigFlags & ImGuiConfigFlags_NoMouse) |
| 4444 | clear_hovered_windows = true; |
| 4445 | |
| 4446 | // We track click ownership. When clicked outside of a window the click is owned by the application and |
| 4447 | // won't report hovering nor request capture even while dragging over our windows afterward. |
| 4448 | const bool has_open_popup = (g.OpenPopupStack.Size > 0); |
| 4449 | const bool has_open_modal = (modal_window != NULL); |
| 4450 | int mouse_earliest_down = -1; |
| 4451 | bool mouse_any_down = false; |
| 4452 | for (int i = 0; i < IM_ARRAYSIZE(io.MouseDown); i++) |
| 4453 | { |
| 4454 | if (io.MouseClicked[i]) |
| 4455 | { |
| 4456 | io.MouseDownOwned[i] = (g.HoveredWindow != NULL) || has_open_popup; |
| 4457 | io.MouseDownOwnedUnlessPopupClose[i] = (g.HoveredWindow != NULL) || has_open_modal; |
| 4458 | } |
| 4459 | mouse_any_down |= io.MouseDown[i]; |
| 4460 | if (io.MouseDown[i]) |
| 4461 | if (mouse_earliest_down == -1 || io.MouseClickedTime[i] < io.MouseClickedTime[mouse_earliest_down]) |
| 4462 | mouse_earliest_down = i; |
| 4463 | } |
| 4464 | const bool mouse_avail = (mouse_earliest_down == -1) || io.MouseDownOwned[mouse_earliest_down]; |
| 4465 | const bool mouse_avail_unless_popup_close = (mouse_earliest_down == -1) || io.MouseDownOwnedUnlessPopupClose[mouse_earliest_down]; |
| 4466 | |
| 4467 | // If mouse was first clicked outside of ImGui bounds we also cancel out hovering. |
| 4468 | // FIXME: For patterns of drag and drop across OS windows, we may need to rework/remove this test (first committed 311c0ca9 on 2015/02) |
| 4469 | const bool mouse_dragging_extern_payload = g.DragDropActive && (g.DragDropSourceFlags & ImGuiDragDropFlags_SourceExtern) != 0; |
| 4470 | if (!mouse_avail && !mouse_dragging_extern_payload) |
| 4471 | clear_hovered_windows = true; |
| 4472 | |
| 4473 | if (clear_hovered_windows) |
| 4474 | g.HoveredWindow = g.HoveredWindowUnderMovingWindow = NULL; |
| 4475 | |
| 4476 | // Update io.WantCaptureMouse for the user application (true = dispatch mouse info to Dear ImGui only, false = dispatch mouse to Dear ImGui + underlying app) |
| 4477 | // Update io.WantCaptureMouseAllowPopupClose (experimental) to give a chance for app to react to popup closure with a drag |
| 4478 | if (g.WantCaptureMouseNextFrame != -1) |
| 4479 | { |
| 4480 | io.WantCaptureMouse = io.WantCaptureMouseUnlessPopupClose = (g.WantCaptureMouseNextFrame != 0); |
| 4481 | } |
nothing calls this directly
no test coverage detected