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; pWindow->m_sGroupData.pNextWindow = nullptr;
else { else {
// find last window and update // find last window and update
CWindow* curr = pWindow; CWindow* PWINDOWPREV = pWindow->getGroupPrevious();
const auto CURRWASVISIBLE = curr->getGroupCurrent() == curr; const auto WINDOWISVISIBLE = pWindow->getGroupCurrent() == pWindow;
while (curr->m_sGroupData.pNextWindow != pWindow) if (WINDOWISVISIBLE)
curr = curr->m_sGroupData.pNextWindow; PWINDOWPREV->setGroupCurrent(PWINDOWPREV);
if (CURRWASVISIBLE) PWINDOWPREV->m_sGroupData.pNextWindow = pWindow->m_sGroupData.pNextWindow;
curr->setGroupCurrent(curr);
curr->m_sGroupData.pNextWindow = pWindow->m_sGroupData.pNextWindow;
pWindow->m_sGroupData.pNextWindow = nullptr; pWindow->m_sGroupData.pNextWindow = nullptr;
if (pWindow->m_sGroupData.head) { if (pWindow->m_sGroupData.head) {
pWindow->m_sGroupData.head = false; std::swap(PWINDOWPREV->m_sGroupData.head, pWindow->m_sGroupData.head);
curr->m_sGroupData.head = true; std::swap(PWINDOWPREV->m_sGroupData.locked, pWindow->m_sGroupData.locked);
curr->m_sGroupData.locked = pWindow->m_sGroupData.locked;
pWindow->m_sGroupData.locked = false;
} }
if (pWindow == m_pLastTiledWindow) if (pWindow == m_pLastTiledWindow)
@ -57,7 +52,7 @@ void IHyprLayout::onWindowRemoved(CWindow* pWindow) {
pWindow->setHidden(false); pWindow->setHidden(false);
pWindow->updateWindowDecos(); pWindow->updateWindowDecos();
curr->getGroupCurrent()->updateWindowDecos(); PWINDOWPREV->getGroupCurrent()->updateWindowDecos();
g_pCompositor->updateWindowAnimatedDecorationValues(pWindow); g_pCompositor->updateWindowAnimatedDecorationValues(pWindow);
return; return;

View file

@ -1243,10 +1243,7 @@ void CKeybindManager::changeGroupActive(std::string args) {
if (args != "b" && args != "prev") { if (args != "b" && args != "prev") {
PWINDOW->setGroupCurrent(PWINDOW->m_sGroupData.pNextWindow); PWINDOW->setGroupCurrent(PWINDOW->m_sGroupData.pNextWindow);
} else { } else {
CWindow* curr = PWINDOW->m_sGroupData.pNextWindow; PWINDOW->setGroupCurrent(PWINDOW->getGroupPrevious());
while (curr->m_sGroupData.pNextWindow != PWINDOW)
curr = curr->m_sGroupData.pNextWindow;
PWINDOW->setGroupCurrent(curr);
} }
} }

View file

@ -57,15 +57,10 @@ void CHyprGroupBarDecoration::updateWindow(CWindow* pWindow) {
} }
m_dwGroupMembers.clear(); m_dwGroupMembers.clear();
CWindow* curr = pWindow; CWindow* head = pWindow->getGroupHead();
CWindow* head = nullptr; m_dwGroupMembers.push_back(head);
while (!curr->m_sGroupData.head) {
curr = curr->m_sGroupData.pNextWindow;
}
head = curr; CWindow* curr = head->m_sGroupData.pNextWindow;
m_dwGroupMembers.push_back(curr);
curr = curr->m_sGroupData.pNextWindow;
while (curr != head) { while (curr != head) {
m_dwGroupMembers.push_back(curr); m_dwGroupMembers.push_back(curr);
curr = curr->m_sGroupData.pNextWindow; curr = curr->m_sGroupData.pNextWindow;