Skip to content

Commit

Permalink
fix bug with floating groups and clarify comments
Browse files Browse the repository at this point in the history
  • Loading branch information
Aqa-Ib committed Sep 24, 2024
1 parent 430d9c8 commit 3c24673
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 11 deletions.
13 changes: 9 additions & 4 deletions src/layout/DwindleLayout.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<Hyprlang::INT>("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);
Expand All @@ -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<Hyprlang::INT>("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();
Expand Down
4 changes: 2 additions & 2 deletions src/layout/IHyprLayout.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<Hyprlang::INT>("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<Hyprlang::INT>("group:insert_after_current");
Expand Down
14 changes: 9 additions & 5 deletions src/layout/MasterLayout.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<Hyprlang::INT>("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())) {

Expand All @@ -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<Hyprlang::INT>("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();
Expand Down

0 comments on commit 3c24673

Please sign in to comment.