mirror of
https://github.com/hyprwm/Hyprland
synced 2024-11-02 19:05:58 +01:00
refactor: flatten nesting if
s in layout window creation method (#3294)
This commit is contained in:
parent
0e64dd2ea5
commit
e6651334f2
2 changed files with 59 additions and 60 deletions
|
@ -318,34 +318,33 @@ 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
|
||||||
|
!g_pKeybindManager->m_bGroupsLocked && !m_vOverrideFocalPoint) {
|
||||||
|
if (!pWindow->m_sGroupData.pNextWindow)
|
||||||
|
pWindow->m_dWindowDecorations.emplace_back(std::make_unique<CHyprGroupBarDecoration>(pWindow));
|
||||||
|
|
||||||
if (!pWindow->m_sGroupData.pNextWindow || !pWindow->getGroupHead()->m_sGroupData.locked) { // source is not a group or an unlocked group
|
m_lDwindleNodesData.remove(*PNODE);
|
||||||
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 wlr_box box = OPENINGON->pWindow->getDecorationByType(DECORATION_GROUPBAR)->getWindowDecorationRegion().getExtents();
|
const int SIZE = OPENINGON->pWindow->getGroupSize();
|
||||||
if (wlr_box_contains_point(&box, MOUSECOORDS.x, MOUSECOORDS.y)) { // TODO: Deny when not using mouse
|
const int INDEX = (int)((MOUSECOORDS.x - box.x) * 2 * SIZE / box.width + 1) / 2 - 1;
|
||||||
const int SIZE = OPENINGON->pWindow->getGroupSize();
|
CWindow* pWindowInsertAfter = OPENINGON->pWindow->getGroupWindowByIndex(INDEX);
|
||||||
const int INDEX = (int)((MOUSECOORDS.x - box.x) * 2 * SIZE / box.width + 1) / 2 - 1;
|
pWindowInsertAfter->insertWindowToGroup(pWindow);
|
||||||
CWindow* pWindowInsertAfter = OPENINGON->pWindow->getGroupWindowByIndex(INDEX);
|
if (INDEX == -1)
|
||||||
pWindowInsertAfter->insertWindowToGroup(pWindow);
|
std::swap(pWindow->m_sGroupData.pNextWindow->m_sGroupData.head, pWindow->m_sGroupData.head);
|
||||||
if (INDEX == -1)
|
} else {
|
||||||
std::swap(pWindow->m_sGroupData.pNextWindow->m_sGroupData.head, pWindow->m_sGroupData.head);
|
static const auto* USECURRPOS = &g_pConfigManager->getConfigValuePtr("misc:group_insert_after_current")->intValue;
|
||||||
} else {
|
(*USECURRPOS ? OPENINGON->pWindow : OPENINGON->pWindow->getGroupTail())->insertWindowToGroup(pWindow);
|
||||||
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;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
OPENINGON->pWindow->setGroupCurrent(pWindow);
|
||||||
|
pWindow->updateWindowDecos();
|
||||||
|
recalculateWindow(pWindow);
|
||||||
|
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// If it's not, get the node under our cursor
|
// If it's not, get the node under our cursor
|
||||||
|
|
|
@ -94,34 +94,34 @@ 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
|
||||||
|
!g_pKeybindManager->m_bGroupsLocked // global group lock disengaged
|
||||||
|
) {
|
||||||
|
if (!pWindow->m_sGroupData.pNextWindow)
|
||||||
|
pWindow->m_dWindowDecorations.emplace_back(std::make_unique<CHyprGroupBarDecoration>(pWindow));
|
||||||
|
|
||||||
if (!pWindow->m_sGroupData.pNextWindow || !pWindow->getGroupHead()->m_sGroupData.locked) { // source is not a group or an unlocked group
|
m_lMasterNodesData.remove(*PNODE);
|
||||||
if (!pWindow->m_sGroupData.pNextWindow)
|
|
||||||
pWindow->m_dWindowDecorations.emplace_back(std::make_unique<CHyprGroupBarDecoration>(pWindow));
|
|
||||||
|
|
||||||
m_lMasterNodesData.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 wlr_box box = OPENINGON->pWindow->getDecorationByType(DECORATION_GROUPBAR)->getWindowDecorationRegion().getExtents();
|
const int SIZE = OPENINGON->pWindow->getGroupSize();
|
||||||
if (wlr_box_contains_point(&box, MOUSECOORDS.x, MOUSECOORDS.y)) { // TODO: Deny when not using mouse
|
const int INDEX = (int)((MOUSECOORDS.x - box.x) * 2 * SIZE / box.width + 1) / 2 - 1;
|
||||||
const int SIZE = OPENINGON->pWindow->getGroupSize();
|
CWindow* pWindowInsertAfter = OPENINGON->pWindow->getGroupWindowByIndex(INDEX);
|
||||||
const int INDEX = (int)((MOUSECOORDS.x - box.x) * 2 * SIZE / box.width + 1) / 2 - 1;
|
pWindowInsertAfter->insertWindowToGroup(pWindow);
|
||||||
CWindow* pWindowInsertAfter = OPENINGON->pWindow->getGroupWindowByIndex(INDEX);
|
if (INDEX == -1)
|
||||||
pWindowInsertAfter->insertWindowToGroup(pWindow);
|
std::swap(pWindow->m_sGroupData.pNextWindow->m_sGroupData.head, pWindow->m_sGroupData.head);
|
||||||
if (INDEX == -1)
|
} else {
|
||||||
std::swap(pWindow->m_sGroupData.pNextWindow->m_sGroupData.head, pWindow->m_sGroupData.head);
|
static const auto* USECURRPOS = &g_pConfigManager->getConfigValuePtr("misc:group_insert_after_current")->intValue;
|
||||||
} else {
|
(*USECURRPOS ? OPENINGON->pWindow : OPENINGON->pWindow->getGroupTail())->insertWindowToGroup(pWindow);
|
||||||
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;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
OPENINGON->pWindow->setGroupCurrent(pWindow);
|
||||||
|
pWindow->updateWindowDecos();
|
||||||
|
recalculateWindow(pWindow);
|
||||||
|
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (*PNEWISMASTER || WINDOWSONWORKSPACE == 1 || (!pWindow->m_bFirstMap && OPENINGON->isMaster)) {
|
if (*PNEWISMASTER || WINDOWSONWORKSPACE == 1 || (!pWindow->m_bFirstMap && OPENINGON->isMaster)) {
|
||||||
|
@ -680,13 +680,13 @@ void CHyprMasterLayout::resizeActiveWindow(const Vector2D& pixResize, eRectCorne
|
||||||
const bool DISPLAYTOP = STICKS(PWINDOW->m_vPosition.y, PMONITOR->vecPosition.y + PMONITOR->vecReservedTopLeft.y);
|
const bool DISPLAYTOP = STICKS(PWINDOW->m_vPosition.y, PMONITOR->vecPosition.y + PMONITOR->vecReservedTopLeft.y);
|
||||||
const bool DISPLAYLEFT = STICKS(PWINDOW->m_vPosition.x, PMONITOR->vecPosition.x + PMONITOR->vecReservedTopLeft.x);
|
const bool DISPLAYLEFT = STICKS(PWINDOW->m_vPosition.x, PMONITOR->vecPosition.x + PMONITOR->vecReservedTopLeft.x);
|
||||||
|
|
||||||
const bool LEFT = corner == CORNER_TOPLEFT || corner == CORNER_BOTTOMLEFT;
|
const bool LEFT = corner == CORNER_TOPLEFT || corner == CORNER_BOTTOMLEFT;
|
||||||
const bool TOP = corner == CORNER_TOPLEFT || corner == CORNER_TOPRIGHT;
|
const bool TOP = corner == CORNER_TOPLEFT || corner == CORNER_TOPRIGHT;
|
||||||
const bool NONE = corner == CORNER_NONE;
|
const bool NONE = corner == CORNER_NONE;
|
||||||
|
|
||||||
const auto MASTERS = getMastersOnWorkspace(PNODE->workspaceID);
|
const auto MASTERS = getMastersOnWorkspace(PNODE->workspaceID);
|
||||||
const auto WINDOWS = getNodesOnWorkspace(PNODE->workspaceID);
|
const auto WINDOWS = getNodesOnWorkspace(PNODE->workspaceID);
|
||||||
const auto STACKWINDOWS = WINDOWS - MASTERS;
|
const auto STACKWINDOWS = WINDOWS - MASTERS;
|
||||||
|
|
||||||
if (getNodesOnWorkspace(PWINDOW->m_iWorkspaceID) == 1 && !centered)
|
if (getNodesOnWorkspace(PWINDOW->m_iWorkspaceID) == 1 && !centered)
|
||||||
return;
|
return;
|
||||||
|
@ -716,8 +716,8 @@ void CHyprMasterLayout::resizeActiveWindow(const Vector2D& pixResize, eRectCorne
|
||||||
// check the up/down resize
|
// check the up/down resize
|
||||||
const bool isStackVertical = orientation == ORIENTATION_LEFT || orientation == ORIENTATION_RIGHT || orientation == ORIENTATION_CENTER;
|
const bool isStackVertical = orientation == ORIENTATION_LEFT || orientation == ORIENTATION_RIGHT || orientation == ORIENTATION_CENTER;
|
||||||
|
|
||||||
const auto RESIZEDELTA = isStackVertical ? pixResize.y : pixResize.x;
|
const auto RESIZEDELTA = isStackVertical ? pixResize.y : pixResize.x;
|
||||||
const auto WSSIZE = PMONITOR->vecSize - PMONITOR->vecReservedTopLeft - PMONITOR->vecReservedBottomRight;
|
const auto WSSIZE = PMONITOR->vecSize - PMONITOR->vecReservedTopLeft - PMONITOR->vecReservedBottomRight;
|
||||||
|
|
||||||
auto nodesInSameColumn = PNODE->isMaster ? MASTERS : STACKWINDOWS;
|
auto nodesInSameColumn = PNODE->isMaster ? MASTERS : STACKWINDOWS;
|
||||||
if (orientation == ORIENTATION_CENTER && !PNODE->isMaster)
|
if (orientation == ORIENTATION_CENTER && !PNODE->isMaster)
|
||||||
|
@ -729,8 +729,8 @@ void CHyprMasterLayout::resizeActiveWindow(const Vector2D& pixResize, eRectCorne
|
||||||
if (!*PSMARTRESIZING) {
|
if (!*PSMARTRESIZING) {
|
||||||
PNODE->percSize = std::clamp(PNODE->percSize + RESIZEDELTA / SIZE, 0.05, 1.95);
|
PNODE->percSize = std::clamp(PNODE->percSize + RESIZEDELTA / SIZE, 0.05, 1.95);
|
||||||
} else {
|
} else {
|
||||||
const auto NODEIT = std::find(m_lMasterNodesData.begin(), m_lMasterNodesData.end(), *PNODE);
|
const auto NODEIT = std::find(m_lMasterNodesData.begin(), m_lMasterNodesData.end(), *PNODE);
|
||||||
const auto REVNODEIT = std::find(m_lMasterNodesData.rbegin(), m_lMasterNodesData.rend(), *PNODE);
|
const auto REVNODEIT = std::find(m_lMasterNodesData.rbegin(), m_lMasterNodesData.rend(), *PNODE);
|
||||||
|
|
||||||
const float totalSize = isStackVertical ? WSSIZE.y : WSSIZE.x;
|
const float totalSize = isStackVertical ? WSSIZE.y : WSSIZE.x;
|
||||||
const float minSize = totalSize / nodesInSameColumn * 0.2;
|
const float minSize = totalSize / nodesInSameColumn * 0.2;
|
||||||
|
|
Loading…
Reference in a new issue