From 3c246736e79ee6cfecde2ec1c8c35df06363a7ac Mon Sep 17 00:00:00 2001 From: Aqa-Ib Date: Tue, 24 Sep 2024 10:51:05 +0200 Subject: [PATCH] fix bug with floating groups and clarify comments --- src/layout/DwindleLayout.cpp | 13 +++++++++---- src/layout/IHyprLayout.cpp | 4 ++-- src/layout/MasterLayout.cpp | 14 +++++++++----- 3 files changed, 20 insertions(+), 11 deletions(-) diff --git a/src/layout/DwindleLayout.cpp b/src/layout/DwindleLayout.cpp index c695783e065..64b0aba4026 100644 --- a/src/layout/DwindleLayout.cpp +++ b/src/layout/DwindleLayout.cpp @@ -340,8 +340,10 @@ void CHyprDwindleLayout::onWindowCreatedTiling(PHLWINDOW pWindow, eDirection dir return; } + // If the active window is a group and auto_group = true: static auto AUTOGROUP = CConfigValue("group:auto_group"); - // auto group the window if OPENINGON is a tiled group + + // auto group the new window if OPENINGON is a tiled group if (*AUTOGROUP && OPENINGON->pWindow->m_sGroupData.pNextWindow.lock() // target is a tiled group && pWindow->canBeGroupedInto(OPENINGON->pWindow.lock()) && !m_vOverrideFocalPoint) { // we are not moving window m_lDwindleNodesData.remove(*PNODE); @@ -359,13 +361,16 @@ void CHyprDwindleLayout::onWindowCreatedTiling(PHLWINDOW pWindow, eDirection dir return; } - // auto group the window if the last window is a floating group + + // auto group the new window if the focused window is a floating group const auto PLASTWINDOW = g_pCompositor->m_pLastWindow; if (*AUTOGROUP && PLASTWINDOW && PLASTWINDOW->m_bIsFloating && PLASTWINDOW->m_sGroupData.pNextWindow // target is the focused floating group && pWindow->canBeGroupedInto(PLASTWINDOW.lock())) { - static auto USECURRPOS = CConfigValue("group:insert_after_current"); - (*USECURRPOS ? PLASTWINDOW : PLASTWINDOW->getGroupTail())->insertWindowToGroup(pWindow); + // make the new window floating before merging into the focused floating group + pWindow->m_bIsFloating = true; + m_lDwindleNodesData.remove(*PNODE); + g_pLayoutManager->getCurrentLayout()->onWindowCreatedFloating(pWindow); PLASTWINDOW->setGroupCurrent(pWindow); pWindow->applyGroupRules(); diff --git a/src/layout/IHyprLayout.cpp b/src/layout/IHyprLayout.cpp index 9a0eed758d7..0036d2f4b77 100644 --- a/src/layout/IHyprLayout.cpp +++ b/src/layout/IHyprLayout.cpp @@ -81,10 +81,10 @@ void IHyprLayout::onWindowRemovedFloating(PHLWINDOW pWindow) { void IHyprLayout::onWindowCreatedFloating(PHLWINDOW pWindow) { - // auto group the window if the last window is a floating group + // auto group the new window if the focused window is a floating group static auto AUTOGROUP = CConfigValue("group:auto_group"); const auto PLASTWINDOW = g_pCompositor->m_pLastWindow; - if (*AUTOGROUP && PLASTWINDOW && PLASTWINDOW->m_bIsFloating && PLASTWINDOW->m_sGroupData.pNextWindow // target is a floating group + if (*AUTOGROUP && PLASTWINDOW && PLASTWINDOW->m_bIsFloating && PLASTWINDOW->m_sGroupData.pNextWindow // target is the focused floating group && pWindow->canBeGroupedInto(PLASTWINDOW.lock())) { static auto USECURRPOS = CConfigValue("group:insert_after_current"); diff --git a/src/layout/MasterLayout.cpp b/src/layout/MasterLayout.cpp index a2a8995d738..fb10e7dc962 100644 --- a/src/layout/MasterLayout.cpp +++ b/src/layout/MasterLayout.cpp @@ -116,8 +116,10 @@ void CHyprMasterLayout::onWindowCreatedTiling(PHLWINDOW pWindow, eDirection dire return; } + // If the active window is a group and auto_group = true: static auto AUTOGROUP = CConfigValue("group:auto_group"); - // auto group the window if OPENINGON is a tiled group + + // auto group the new window if OPENINGON is a tiled group if (*AUTOGROUP && OPENINGON && OPENINGON != PNODE && OPENINGON->pWindow->m_sGroupData.pNextWindow.lock() // target is a tiled group && pWindow->canBeGroupedInto(OPENINGON->pWindow.lock())) { @@ -136,14 +138,16 @@ void CHyprMasterLayout::onWindowCreatedTiling(PHLWINDOW pWindow, eDirection dire return; } - // auto group the window if the last window is a floating group + + // auto group the new window if the focused window is a floating group const auto PLASTWINDOW = g_pCompositor->m_pLastWindow; if (*AUTOGROUP && PLASTWINDOW && PLASTWINDOW->m_bIsFloating && PLASTWINDOW->m_sGroupData.pNextWindow // target is the focused floating group && pWindow->canBeGroupedInto(PLASTWINDOW.lock())) { - m_lMasterNodesData.remove(*PNODE); - static auto USECURRPOS = CConfigValue("group:insert_after_current"); - (*USECURRPOS ? PLASTWINDOW : PLASTWINDOW->getGroupTail())->insertWindowToGroup(pWindow); + // make the new window floating before merging into the focused floating group + pWindow->m_bIsFloating = true; + m_lMasterNodesData.remove(*PNODE); + g_pLayoutManager->getCurrentLayout()->onWindowCreatedFloating(pWindow); PLASTWINDOW->setGroupCurrent(pWindow); pWindow->applyGroupRules();