diff --git a/src/layout/IHyprLayout.cpp b/src/layout/IHyprLayout.cpp index c05582bdb..80b2d0d4d 100644 --- a/src/layout/IHyprLayout.cpp +++ b/src/layout/IHyprLayout.cpp @@ -31,24 +31,19 @@ void IHyprLayout::onWindowRemoved(CWindow* pWindow) { pWindow->m_sGroupData.pNextWindow = nullptr; else { // find last window and update - CWindow* curr = pWindow; - const auto CURRWASVISIBLE = curr->getGroupCurrent() == curr; + CWindow* PWINDOWPREV = pWindow->getGroupPrevious(); + const auto WINDOWISVISIBLE = pWindow->getGroupCurrent() == pWindow; - while (curr->m_sGroupData.pNextWindow != pWindow) - curr = curr->m_sGroupData.pNextWindow; + if (WINDOWISVISIBLE) + PWINDOWPREV->setGroupCurrent(PWINDOWPREV); - if (CURRWASVISIBLE) - curr->setGroupCurrent(curr); - - curr->m_sGroupData.pNextWindow = pWindow->m_sGroupData.pNextWindow; + PWINDOWPREV->m_sGroupData.pNextWindow = pWindow->m_sGroupData.pNextWindow; pWindow->m_sGroupData.pNextWindow = nullptr; if (pWindow->m_sGroupData.head) { - pWindow->m_sGroupData.head = false; - curr->m_sGroupData.head = true; - curr->m_sGroupData.locked = pWindow->m_sGroupData.locked; - pWindow->m_sGroupData.locked = false; + std::swap(PWINDOWPREV->m_sGroupData.head, pWindow->m_sGroupData.head); + std::swap(PWINDOWPREV->m_sGroupData.locked, pWindow->m_sGroupData.locked); } if (pWindow == m_pLastTiledWindow) @@ -57,7 +52,7 @@ void IHyprLayout::onWindowRemoved(CWindow* pWindow) { pWindow->setHidden(false); pWindow->updateWindowDecos(); - curr->getGroupCurrent()->updateWindowDecos(); + PWINDOWPREV->getGroupCurrent()->updateWindowDecos(); g_pCompositor->updateWindowAnimatedDecorationValues(pWindow); return; diff --git a/src/managers/KeybindManager.cpp b/src/managers/KeybindManager.cpp index 333f01d19..b550fb6ea 100644 --- a/src/managers/KeybindManager.cpp +++ b/src/managers/KeybindManager.cpp @@ -1243,10 +1243,7 @@ void CKeybindManager::changeGroupActive(std::string args) { if (args != "b" && args != "prev") { PWINDOW->setGroupCurrent(PWINDOW->m_sGroupData.pNextWindow); } else { - CWindow* curr = PWINDOW->m_sGroupData.pNextWindow; - while (curr->m_sGroupData.pNextWindow != PWINDOW) - curr = curr->m_sGroupData.pNextWindow; - PWINDOW->setGroupCurrent(curr); + PWINDOW->setGroupCurrent(PWINDOW->getGroupPrevious()); } } diff --git a/src/render/decorations/CHyprGroupBarDecoration.cpp b/src/render/decorations/CHyprGroupBarDecoration.cpp index 89e047caf..70d4ed931 100644 --- a/src/render/decorations/CHyprGroupBarDecoration.cpp +++ b/src/render/decorations/CHyprGroupBarDecoration.cpp @@ -57,15 +57,10 @@ void CHyprGroupBarDecoration::updateWindow(CWindow* pWindow) { } m_dwGroupMembers.clear(); - CWindow* curr = pWindow; - CWindow* head = nullptr; - while (!curr->m_sGroupData.head) { - curr = curr->m_sGroupData.pNextWindow; - } + CWindow* head = pWindow->getGroupHead(); + m_dwGroupMembers.push_back(head); - head = curr; - m_dwGroupMembers.push_back(curr); - curr = curr->m_sGroupData.pNextWindow; + CWindow* curr = head->m_sGroupData.pNextWindow; while (curr != head) { m_dwGroupMembers.push_back(curr); curr = curr->m_sGroupData.pNextWindow;