Viewports: fixed an issue where the implicit "Debug" window would erroneously be targeted for mouse inputs while hidden. (#9254)
diff --git a/docs/CHANGELOG.txt b/docs/CHANGELOG.txt
index 5bbb533..3d982d2 100644
--- a/docs/CHANGELOG.txt
+++ b/docs/CHANGELOG.txt
@@ -36,6 +36,19 @@
 - 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)
 -----------------------------------------------------------------------
 
diff --git a/imgui.cpp b/imgui.cpp
index 5567f1d..f183b37 100644
--- a/imgui.cpp
+++ b/imgui.cpp
@@ -16648,7 +16648,7 @@
     }
 }
 
-// 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 @@
     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 @@
         // 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)