From e4aeef4b9f7688006bf1cf2bb340ecaf6013cd41 Mon Sep 17 00:00:00 2001 From: ocornut Date: Wed, 21 Jun 2023 15:34:51 +0200 Subject: [PATCH] Viewports: Closing a viewport via OS/platform means (e.g. OS close button or task-bar menu), mark all windows in this viewport as closed. --- docs/CHANGELOG.txt | 2 ++ imgui.cpp | 12 ++++-------- 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/docs/CHANGELOG.txt b/docs/CHANGELOG.txt index fef9b114a..cef298627 100644 --- a/docs/CHANGELOG.txt +++ b/docs/CHANGELOG.txt @@ -151,6 +151,8 @@ Other changes: Docking+Viewports Branch: +- Viewports: Closing a viewport via OS/platform means (e.g. OS close button or task-bar menu), + mark all windows in this viewport as closed. - Docking: Fixed dragging from title-bar empty space (regression from 1.88 related to keeping ID alive when calling low-level ButtonBehavior() directly). (#5181, #2645) - Docking: [Internal] DockBuilderDockWindow() API calls don't clear docking order diff --git a/imgui.cpp b/imgui.cpp index 7b2a45e4d..339f47229 100644 --- a/imgui.cpp +++ b/imgui.cpp @@ -7227,16 +7227,12 @@ bool ImGui::Begin(const char* name, bool* p_open, ImGuiWindowFlags flags) if (want_focus && window == g.NavWindow) NavInitWindow(window, false); // <-- this is in the way for us to be able to defer and sort reappearing FocusWindow() calls - // Close requested by platform window + // Close requested by platform window (apply to all windows in this viewport) if (p_open != NULL && window->Viewport->PlatformRequestClose && window->Viewport != GetMainViewport()) { - if (!window->DockIsActive || window->DockTabIsVisible) - { - window->Viewport->PlatformRequestClose = false; - g.NavWindowingToggleLayer = false; // Assume user mapped PlatformRequestClose on ALT-F4 so we disable ALT for menu toggle. False positive not an issue. - IMGUI_DEBUG_LOG_VIEWPORT("[viewport] Window '%s' PlatformRequestClose\n", window->Name); - *p_open = false; - } + IMGUI_DEBUG_LOG_VIEWPORT("[viewport] Window '%s' closed by PlatformRequestClose\n", window->Name); + *p_open = false; + g.NavWindowingToggleLayer = false; // Assume user mapped PlatformRequestClose on ALT-F4 so we disable ALT for menu toggle. False positive not an issue. // FIXME-NAV: Try removing. } // Title bar