desktop/window: go back to the previously focused window in a group (#12763)

This commit is contained in:
Vaxry 2025-12-30 18:02:34 +01:00 committed by GitHub
parent 293d3e5de9
commit 529559712b
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 55 additions and 1 deletions

View file

@ -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;