From 4088a4f40c25f143bddac3393a1f922426b379f5 Mon Sep 17 00:00:00 2001 From: ocornut Date: Fri, 15 May 2026 13:33:51 +0200 Subject: [PATCH] Windows: clicking on a window's empty-space to move/focus a window checks for lack of mouse button ownership. (#9382) --- docs/CHANGELOG.txt | 5 +++++ imgui.cpp | 4 ++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/docs/CHANGELOG.txt b/docs/CHANGELOG.txt index e13e2c319..c69f33f3c 100644 --- a/docs/CHANGELOG.txt +++ b/docs/CHANGELOG.txt @@ -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) diff --git a/imgui.cpp b/imgui.cpp index 01067abe7..a9677390f 100644 --- a/imgui.cpp +++ b/imgui.cpp @@ -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.