refactor: replace manual iteration of CWindow with existing methods (#3147)

This commit is contained in:
memchr 2023-09-04 13:13:39 +00:00 committed by GitHub
parent 6a0e2bbff3
commit 69439871e6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 12 additions and 25 deletions

View File

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

View File

@ -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());
}
}

View File

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