summaryrefslogtreecommitdiff
path: root/src/layout/IHyprLayout.cpp
diff options
context:
space:
mode:
authormemchr <118117622+memchr@users.noreply.github.com>2023-09-04 13:13:39 +0000
committerGitHub <noreply@github.com>2023-09-04 15:13:39 +0200
commit69439871e60eeb16993fd6044843d14d2191c9fb (patch)
tree49d8c5d5faa482c9be9404840af3c65e23c8f7a9 /src/layout/IHyprLayout.cpp
parent6a0e2bbff36ad53b08289c150925f1037f856475 (diff)
refactor: replace manual iteration of CWindow with existing methods (#3147)
Diffstat (limited to 'src/layout/IHyprLayout.cpp')
-rw-r--r--src/layout/IHyprLayout.cpp21
1 files changed, 8 insertions, 13 deletions
diff --git a/src/layout/IHyprLayout.cpp b/src/layout/IHyprLayout.cpp
index c05582bd..80b2d0d4 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;