Viewports: fixed an issue where the implicit "Debug" window would erroneously be targeted for mouse inputs while hidden. (#9254)

This commit is contained in:
ocornut
2026-02-19 11:34:39 +01:00
parent 2a1b69f057
commit ad769352ea
2 changed files with 17 additions and 3 deletions

View File

@@ -35,6 +35,19 @@ HOW TO UPDATE?
and API updates have been a little more frequent lately. They are documented below and in imgui.cpp and should not affect all users.
- Please report any issue!
-----------------------------------------------------------------------
VERSION 1.92.7 WIP (In Progress)
-----------------------------------------------------------------------
Docking+Viewports Branch:
- Viewports:
- Fixed an issue where the implicit "Debug" window would erroneously be targetted for
mouse inputs while hidden if (1) the implicit "Debug" window was used in a previous
session and moved to a secondary viewport and (2) the Platform Backend does not
support the ImGuiBackendFlags_HasMouseHoveredViewport feature. (#9254)
-----------------------------------------------------------------------
VERSION 1.92.6 (2026-02-17)
-----------------------------------------------------------------------

View File

@@ -16648,7 +16648,7 @@ void ImGui::ScaleWindowsInViewport(ImGuiViewportP* viewport, float scale)
}
}
// If the backend doesn't set MouseLastHoveredViewport or doesn't honor ImGuiViewportFlags_NoInputs, we do a search ourselves.
// If the backend doesn't support ImGuiBackendFlags_HasMouseHoveredViewport or doesn't honor ImGuiViewportFlags_NoInputs for it, we do a search ourselves.
// A) It won't take account of the possibility that non-imgui windows may be in-between our dragged window and our target window.
// B) It requires Platform_GetWindowFocus to be implemented by backend.
ImGuiViewportP* ImGui::FindHoveredViewportFromPlatformWindowStack(const ImVec2& mouse_platform_pos)
@@ -16658,7 +16658,8 @@ ImGuiViewportP* ImGui::FindHoveredViewportFromPlatformWindowStack(const ImVec2&
for (ImGuiViewportP* viewport : g.Viewports)
if (!(viewport->Flags & (ImGuiViewportFlags_NoInputs | ImGuiViewportFlags_IsMinimized)) && viewport->GetMainRect().Contains(mouse_platform_pos))
if (best_candidate == NULL || best_candidate->LastFocusedStampCount < viewport->LastFocusedStampCount)
best_candidate = viewport;
if (viewport->PlatformWindowCreated)
best_candidate = viewport;
return best_candidate;
}
@@ -16880,7 +16881,7 @@ static void ImGui::UpdateViewportsNewFrame()
// 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) 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)
// C) uses LastFocusedStampCount 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)