Windows: clicking on a window's empty-space to move/focus a window checks for lack of mouse button ownership. (#9382)

This commit is contained in:
ocornut
2026-05-15 13:33:51 +02:00
parent 46a050fff2
commit 4088a4f40c
2 changed files with 7 additions and 2 deletions
+5
View File
@@ -43,6 +43,11 @@ Breaking Changes:
Other Changes:
- Windows:
- Clicking on a window's empty-space to move/focus a window checks
for lack of mouse button ownership. This gives an additional opportunity
for user code to bypass it without using a clickable item. (#9382)
-----------------------------------------------------------------------
VERSION 1.92.8 (Released 2026-05-12)
+2 -2
View File
@@ -5357,7 +5357,7 @@ void ImGui::UpdateMouseMovingWindowEndFrame()
// Click on empty space to focus window and start moving
// (after we're done with all our widgets)
if (g.IO.MouseClicked[0])
if (IsMouseClicked(0, ImGuiInputFlags_None, ImGuiKeyOwner_NoOwner))
{
// Handle the edge case of a popup being closed while clicking in its empty space.
// If we try to focus it, FocusWindow() > ClosePopupsOverWindow() will accidentally close any parent popups because they are not linked together any more.
@@ -5395,7 +5395,7 @@ void ImGui::UpdateMouseMovingWindowEndFrame()
// With right mouse button we close popups without changing focus based on where the mouse is aimed
// Instead, focus will be restored to the window under the bottom-most closed popup.
// (The left mouse button path calls FocusWindow on the hovered window, which will lead NewFrame->ClosePopupsOverWindow to trigger)
if (g.IO.MouseClicked[1] && g.HoveredId == 0)
if (g.HoveredId == 0 && IsMouseClicked(1, ImGuiInputFlags_None, ImGuiKeyOwner_NoOwner))
{
// Find the top-most window between HoveredWindow and the top-most Modal Window.
// This is where we can trim the popup stack.