mirror of
https://github.com/ocornut/imgui.git
synced 2025-09-11 05:48:24 +00:00
Viewports: Relaxed specs for backend supporting ImGuiBackendFlags_HasMouseHoveredViewport. Backends: SDL: Added support for simplified HasMouseHoveredViewport. (#1542, #4665)
This commit is contained in:
12
imgui.cpp
12
imgui.cpp
@@ -12701,17 +12701,14 @@ static void ImGui::UpdateViewportsNewFrame()
|
||||
{
|
||||
viewport_hovered = g.IO.MouseHoveredViewport ? (ImGuiViewportP*)FindViewportByID(g.IO.MouseHoveredViewport) : NULL;
|
||||
if (viewport_hovered && (viewport_hovered->Flags & ImGuiViewportFlags_NoInputs))
|
||||
{
|
||||
// Backend failed at honoring its contract if it returned a viewport with the _NoInputs flag.
|
||||
IM_ASSERT(0);
|
||||
viewport_hovered = FindHoveredViewportFromPlatformWindowStack(g.IO.MousePos);
|
||||
}
|
||||
viewport_hovered = FindHoveredViewportFromPlatformWindowStack(g.IO.MousePos); // Backend failed to handle _NoInputs viewport: revert to our fallback.
|
||||
}
|
||||
else
|
||||
{
|
||||
// If the backend doesn't know how to honor ImGuiViewportFlags_NoInputs, we do a search ourselves. Note that this search:
|
||||
// A) won't take account of the possibility that non-imgui windows may be in-between our dragged window and our target window.
|
||||
// B) uses LastFrameAsRefViewport as a flawed replacement for the last time a window was focused (we could/should fix that by introducing Focus functions in PlatformIO)
|
||||
// B) won't take account of how the backend apply parent<>child relationship to secondary viewports, which affects their Z order.
|
||||
// C) uses LastFrameAsRefViewport as a flawed replacement for the last time a window was focused (we could/should fix that by introducing Focus functions in PlatformIO)
|
||||
viewport_hovered = FindHoveredViewportFromPlatformWindowStack(g.IO.MousePos);
|
||||
}
|
||||
if (viewport_hovered != NULL)
|
||||
@@ -17663,7 +17660,8 @@ void ImGui::ShowMetricsWindow(bool* p_open)
|
||||
TreePop();
|
||||
}
|
||||
|
||||
if (TreeNode("Inferred order (front-to-back)"))
|
||||
BulletText("MouseViewport: 0x%08X (UserHovered 0x%08X, LastHovered 0x%08X)", g.MouseViewport ? g.MouseViewport->ID : 0, g.IO.MouseHoveredViewport, g.MouseLastHoveredViewport ? g.MouseLastHoveredViewport->ID : 0);
|
||||
if (TreeNode("Inferred Z order (front-to-back)"))
|
||||
{
|
||||
static ImVector<ImGuiViewportP*> viewports;
|
||||
viewports.resize(g.Viewports.Size);
|
||||
|
Reference in New Issue
Block a user