mirror of
https://github.com/hyprwm/Hyprland
synced 2024-12-22 19:09:48 +01:00
refactor: replace manual iteration of CWindow with existing methods (#3147)
This commit is contained in:
parent
6a0e2bbff3
commit
69439871e6
3 changed files with 12 additions and 25 deletions
|
@ -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;
|
||||
|
|
|
@ -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());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Reference in a new issue