refactor: flatten nesting ifs in layout window creation method (#3294)

This commit is contained in:
memchr 2023-09-14 11:27:16 +00:00 committed by GitHub
parent 0e64dd2ea5
commit e6651334f2
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 59 additions and 60 deletions

View file

@ -318,10 +318,10 @@ void CHyprDwindleLayout::onWindowCreatedTiling(CWindow* pWindow, eDirection dire
} }
// if it's a group, add the window // if it's a group, add the window
if (OPENINGON->pWindow->m_sGroupData.pNextWindow && !OPENINGON->pWindow->getGroupHead()->m_sGroupData.locked && !g_pKeybindManager->m_bGroupsLocked && if (OPENINGON->pWindow->m_sGroupData.pNextWindow && // target is group
!m_vOverrideFocalPoint) { // target is an unlocked group !OPENINGON->pWindow->getGroupHead()->m_sGroupData.locked && // target unlocked
!(pWindow->m_sGroupData.pNextWindow && pWindow->getGroupHead()->m_sGroupData.locked) && // source unlocked or isn't group
if (!pWindow->m_sGroupData.pNextWindow || !pWindow->getGroupHead()->m_sGroupData.locked) { // source is not a group or an unlocked group !g_pKeybindManager->m_bGroupsLocked && !m_vOverrideFocalPoint) {
if (!pWindow->m_sGroupData.pNextWindow) if (!pWindow->m_sGroupData.pNextWindow)
pWindow->m_dWindowDecorations.emplace_back(std::make_unique<CHyprGroupBarDecoration>(pWindow)); pWindow->m_dWindowDecorations.emplace_back(std::make_unique<CHyprGroupBarDecoration>(pWindow));
@ -346,7 +346,6 @@ void CHyprDwindleLayout::onWindowCreatedTiling(CWindow* pWindow, eDirection dire
return; return;
} }
}
// If it's not, get the node under our cursor // If it's not, get the node under our cursor

View file

@ -94,10 +94,11 @@ void CHyprMasterLayout::onWindowCreatedTiling(CWindow* pWindow, eDirection direc
const auto MOUSECOORDS = g_pInputManager->getMouseCoordsInternal(); const auto MOUSECOORDS = g_pInputManager->getMouseCoordsInternal();
// if it's a group, add the window // if it's a group, add the window
if (OPENINGON && OPENINGON->pWindow->m_sGroupData.pNextWindow && !OPENINGON->pWindow->getGroupHead()->m_sGroupData.locked && !g_pKeybindManager->m_bGroupsLocked && if (OPENINGON && OPENINGON != PNODE && OPENINGON->pWindow->m_sGroupData.pNextWindow && // target is group
OPENINGON != PNODE) { // target is an unlocked group !OPENINGON->pWindow->getGroupHead()->m_sGroupData.locked && // target unlocked
!(pWindow->m_sGroupData.pNextWindow && pWindow->getGroupHead()->m_sGroupData.locked) && // source unlocked or isn't group
if (!pWindow->m_sGroupData.pNextWindow || !pWindow->getGroupHead()->m_sGroupData.locked) { // source is not a group or an unlocked group !g_pKeybindManager->m_bGroupsLocked // global group lock disengaged
) {
if (!pWindow->m_sGroupData.pNextWindow) if (!pWindow->m_sGroupData.pNextWindow)
pWindow->m_dWindowDecorations.emplace_back(std::make_unique<CHyprGroupBarDecoration>(pWindow)); pWindow->m_dWindowDecorations.emplace_back(std::make_unique<CHyprGroupBarDecoration>(pWindow));
@ -122,7 +123,6 @@ void CHyprMasterLayout::onWindowCreatedTiling(CWindow* pWindow, eDirection direc
return; return;
} }
}
if (*PNEWISMASTER || WINDOWSONWORKSPACE == 1 || (!pWindow->m_bFirstMap && OPENINGON->isMaster)) { if (*PNEWISMASTER || WINDOWSONWORKSPACE == 1 || (!pWindow->m_bFirstMap && OPENINGON->isMaster)) {
for (auto& nd : m_lMasterNodesData) { for (auto& nd : m_lMasterNodesData) {