From 56203b175752b49c46eb9303c37b80cd4c2dfcf8 Mon Sep 17 00:00:00 2001 From: vaxerski <43317083+vaxerski@users.noreply.github.com> Date: Thu, 1 Sep 2022 19:46:35 +0200 Subject: [PATCH] fix no_gaps_when_only with a group --- src/layout/DwindleLayout.cpp | 20 +++++++++++++++++++- src/layout/DwindleLayout.hpp | 1 + 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/src/layout/DwindleLayout.cpp b/src/layout/DwindleLayout.cpp index c937f645..8caa1b88 100644 --- a/src/layout/DwindleLayout.cpp +++ b/src/layout/DwindleLayout.cpp @@ -90,6 +90,19 @@ void SDwindleNodeData::setGroupFocusedNode(SDwindleNodeData* pMember) { this->pWindow->m_bHidden = pMember != this; } +int SDwindleNodeData::getGroupMemberCount() { + SDwindleNodeData* current = this->pNextGroupMember; + + int no = 1; + + while (current != this) { + current = current->pNextGroupMember; + no++; + } + + return no; +} + int CHyprDwindleLayout::getNodesOnWorkspace(const int& id) { int no = 0; for (auto& n : m_lDwindleNodesData) { @@ -173,7 +186,9 @@ void CHyprDwindleLayout::applyNodeDataToWindow(SDwindleNodeData* pNode, bool for auto calcPos = PWINDOW->m_vPosition + Vector2D(BORDERSIZE, BORDERSIZE); auto calcSize = PWINDOW->m_vSize - Vector2D(2 * BORDERSIZE, 2 * BORDERSIZE); - if (*PNOGAPSWHENONLY && PWINDOW->m_iWorkspaceID != SPECIAL_WORKSPACE_ID && getNodesOnWorkspace(PWINDOW->m_iWorkspaceID) == 1) { + const auto NODESONWORKSPACE = getNodesOnWorkspace(PWINDOW->m_iWorkspaceID); + + if (*PNOGAPSWHENONLY && PWINDOW->m_iWorkspaceID != SPECIAL_WORKSPACE_ID && (NODESONWORKSPACE == 1 || (pNode->isGroupMember() && pNode->getGroupMemberCount() == NODESONWORKSPACE))) { PWINDOW->m_vRealPosition = calcPos - Vector2D(BORDERSIZE, BORDERSIZE); PWINDOW->m_vRealSize = calcSize + Vector2D(2 * BORDERSIZE, 2 * BORDERSIZE); @@ -871,6 +886,9 @@ void CHyprDwindleLayout::toggleWindowGroup(CWindow* pWindow) { // focus PNODE->setGroupFocusedNode(PNODE); + + // required for no_gaps_when_only to work + applyNodeDataToWindow(PNODE); } g_pCompositor->updateAllWindowsAnimatedDecorationValues(); diff --git a/src/layout/DwindleLayout.hpp b/src/layout/DwindleLayout.hpp index 64c6a29d..d86dd992 100644 --- a/src/layout/DwindleLayout.hpp +++ b/src/layout/DwindleLayout.hpp @@ -41,6 +41,7 @@ struct SDwindleNodeData { bool isGroupMember(); SDwindleNodeData* getGroupHead(); SDwindleNodeData* getGroupVisible(); + int getGroupMemberCount(); void setGroupFocusedNode(SDwindleNodeData*); CHyprDwindleLayout* layout = nullptr; };