diff options
Diffstat (limited to 'src/desktop/view/Window.cpp')
| -rw-r--r-- | src/desktop/view/Window.cpp | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/src/desktop/view/Window.cpp b/src/desktop/view/Window.cpp index 695ba81f..b0e6a365 100644 --- a/src/desktop/view/Window.cpp +++ b/src/desktop/view/Window.cpp @@ -2437,7 +2437,24 @@ void CWindow::unmapWindow() { } bool wasLastWindow = false; - PHLWINDOW nextInGroup = m_groupData.pNextWindow ? m_groupData.pNextWindow.lock() : nullptr; + PHLWINDOW nextInGroup = [this] -> PHLWINDOW { + if (!m_groupData.pNextWindow) + return nullptr; + + // walk the history to find a suitable window + const auto HISTORY = Desktop::History::windowTracker()->fullHistory(); + for (const auto& w : HISTORY | std::views::reverse) { + if (!w || !w->m_isMapped || w == m_self) + continue; + + if (!hasInGroup(w.lock())) + continue; + + return w.lock(); + } + + return nullptr; + }(); if (m_self.lock() == Desktop::focusState()->window()) { wasLastWindow = true; |
