summaryrefslogtreecommitdiff
path: root/src/layout/DwindleLayout.cpp
diff options
context:
space:
mode:
authormemchr <118117622+memchr@users.noreply.github.com>2023-09-14 11:27:16 +0000
committerGitHub <noreply@github.com>2023-09-14 12:27:16 +0100
commite6651334f264591cffef96738a2355b1b207eaa6 (patch)
tree18eb84a106497a0f5c23b7ba5569fe4162a48933 /src/layout/DwindleLayout.cpp
parent0e64dd2ea58aa1b41418d78d5aa27f787de6a267 (diff)
refactor: flatten nesting `if`s in layout window creation method (#3294)
Diffstat (limited to 'src/layout/DwindleLayout.cpp')
-rw-r--r--src/layout/DwindleLayout.cpp49
1 files changed, 24 insertions, 25 deletions
diff --git a/src/layout/DwindleLayout.cpp b/src/layout/DwindleLayout.cpp
index a0da8771..43079f59 100644
--- a/src/layout/DwindleLayout.cpp
+++ b/src/layout/DwindleLayout.cpp
@@ -318,34 +318,33 @@ void CHyprDwindleLayout::onWindowCreatedTiling(CWindow* pWindow, eDirection dire
}
// if it's a group, add the window
- if (OPENINGON->pWindow->m_sGroupData.pNextWindow && !OPENINGON->pWindow->getGroupHead()->m_sGroupData.locked && !g_pKeybindManager->m_bGroupsLocked &&
- !m_vOverrideFocalPoint) { // target is an unlocked group
-
- if (!pWindow->m_sGroupData.pNextWindow || !pWindow->getGroupHead()->m_sGroupData.locked) { // source is not a group or an unlocked group
- if (!pWindow->m_sGroupData.pNextWindow)
- pWindow->m_dWindowDecorations.emplace_back(std::make_unique<CHyprGroupBarDecoration>(pWindow));
-
- m_lDwindleNodesData.remove(*PNODE);
-
- const wlr_box box = OPENINGON->pWindow->getDecorationByType(DECORATION_GROUPBAR)->getWindowDecorationRegion().getExtents();
- if (wlr_box_contains_point(&box, MOUSECOORDS.x, MOUSECOORDS.y)) { // TODO: Deny when not using mouse
- const int SIZE = OPENINGON->pWindow->getGroupSize();
- const int INDEX = (int)((MOUSECOORDS.x - box.x) * 2 * SIZE / box.width + 1) / 2 - 1;
- CWindow* pWindowInsertAfter = OPENINGON->pWindow->getGroupWindowByIndex(INDEX);
- pWindowInsertAfter->insertWindowToGroup(pWindow);
- if (INDEX == -1)
- std::swap(pWindow->m_sGroupData.pNextWindow->m_sGroupData.head, pWindow->m_sGroupData.head);
- } else {
- static const auto* USECURRPOS = &g_pConfigManager->getConfigValuePtr("misc:group_insert_after_current")->intValue;
- (*USECURRPOS ? OPENINGON->pWindow : OPENINGON->pWindow->getGroupTail())->insertWindowToGroup(pWindow);
- }
+ if (OPENINGON->pWindow->m_sGroupData.pNextWindow && // target is group
+ !OPENINGON->pWindow->getGroupHead()->m_sGroupData.locked && // target unlocked
+ !(pWindow->m_sGroupData.pNextWindow && pWindow->getGroupHead()->m_sGroupData.locked) && // source unlocked or isn't group
+ !g_pKeybindManager->m_bGroupsLocked && !m_vOverrideFocalPoint) {
+ if (!pWindow->m_sGroupData.pNextWindow)
+ pWindow->m_dWindowDecorations.emplace_back(std::make_unique<CHyprGroupBarDecoration>(pWindow));
- OPENINGON->pWindow->setGroupCurrent(pWindow);
- pWindow->updateWindowDecos();
- recalculateWindow(pWindow);
+ m_lDwindleNodesData.remove(*PNODE);
- return;
+ const wlr_box box = OPENINGON->pWindow->getDecorationByType(DECORATION_GROUPBAR)->getWindowDecorationRegion().getExtents();
+ if (wlr_box_contains_point(&box, MOUSECOORDS.x, MOUSECOORDS.y)) { // TODO: Deny when not using mouse
+ const int SIZE = OPENINGON->pWindow->getGroupSize();
+ const int INDEX = (int)((MOUSECOORDS.x - box.x) * 2 * SIZE / box.width + 1) / 2 - 1;
+ CWindow* pWindowInsertAfter = OPENINGON->pWindow->getGroupWindowByIndex(INDEX);
+ pWindowInsertAfter->insertWindowToGroup(pWindow);
+ if (INDEX == -1)
+ std::swap(pWindow->m_sGroupData.pNextWindow->m_sGroupData.head, pWindow->m_sGroupData.head);
+ } else {
+ static const auto* USECURRPOS = &g_pConfigManager->getConfigValuePtr("misc:group_insert_after_current")->intValue;
+ (*USECURRPOS ? OPENINGON->pWindow : OPENINGON->pWindow->getGroupTail())->insertWindowToGroup(pWindow);
}
+
+ OPENINGON->pWindow->setGroupCurrent(pWindow);
+ pWindow->updateWindowDecos();
+ recalculateWindow(pWindow);
+
+ return;
}
// If it's not, get the node under our cursor