summaryrefslogtreecommitdiff
path: root/src/layout/DwindleLayout.cpp
diff options
context:
space:
mode:
authorVaxry <vaxry@vaxry.net>2025-11-17 22:37:53 +0000
committerVaxry <vaxry@vaxry.net>2025-11-18 00:59:21 +0000
commitedc311544a54a06ce4acb759b4d9a30853695452 (patch)
tree511cdfc2e97dcb224de24f92a86139ef1782b79f /src/layout/DwindleLayout.cpp
parent37fe7b2efde3f572080de33a1fef1b8306ee8bda (diff)
dwindle: Revert rework split logic to be fully gap-aware (#12047)
This reverts commit 151b5f69783b111831e8c5dc062904a221799d7b. Fixes #12380
Diffstat (limited to 'src/layout/DwindleLayout.cpp')
-rw-r--r--src/layout/DwindleLayout.cpp105
1 files changed, 26 insertions, 79 deletions
diff --git a/src/layout/DwindleLayout.cpp b/src/layout/DwindleLayout.cpp
index c653a47e..4925a50e 100644
--- a/src/layout/DwindleLayout.cpp
+++ b/src/layout/DwindleLayout.cpp
@@ -9,51 +9,14 @@
#include "../managers/EventManager.hpp"
#include "xwayland/XWayland.hpp"
-SWorkspaceGaps CHyprDwindleLayout::getWorkspaceGaps(const PHLWORKSPACE& pWorkspace) {
- const auto WORKSPACERULE = g_pConfigManager->getWorkspaceRuleFor(pWorkspace);
- static auto PGAPSINDATA = CConfigValue<Hyprlang::CUSTOMTYPE>("general:gaps_in");
- static auto PGAPSOUTDATA = CConfigValue<Hyprlang::CUSTOMTYPE>("general:gaps_out");
- auto* const PGAPSIN = sc<CCssGapData*>((PGAPSINDATA.ptr())->getData());
- auto* const PGAPSOUT = sc<CCssGapData*>((PGAPSOUTDATA.ptr())->getData());
-
- SWorkspaceGaps gaps;
- gaps.in = WORKSPACERULE.gapsIn.value_or(*PGAPSIN);
- gaps.out = WORKSPACERULE.gapsOut.value_or(*PGAPSOUT);
- return gaps;
-}
-
-SNodeDisplayEdgeFlags CHyprDwindleLayout::getNodeDisplayEdgeFlags(const CBox& box, const PHLMONITOR& monitor) {
- return {
- .top = STICKS(box.y, monitor->m_position.y + monitor->m_reservedTopLeft.y),
- .bottom = STICKS(box.y + box.h, monitor->m_position.y + monitor->m_size.y - monitor->m_reservedBottomRight.y),
- .left = STICKS(box.x, monitor->m_position.x + monitor->m_reservedTopLeft.x),
- .right = STICKS(box.x + box.w, monitor->m_position.x + monitor->m_size.x - monitor->m_reservedBottomRight.x),
- };
-}
-
void SDwindleNodeData::recalcSizePosRecursive(bool force, bool horizontalOverride, bool verticalOverride) {
if (children[0]) {
static auto PSMARTSPLIT = CConfigValue<Hyprlang::INT>("dwindle:smart_split");
static auto PPRESERVESPLIT = CConfigValue<Hyprlang::INT>("dwindle:preserve_split");
static auto PFLMULT = CConfigValue<Hyprlang::FLOAT>("dwindle:split_width_multiplier");
- const auto PWORKSPACE = g_pCompositor->getWorkspaceByID(workspaceID);
- if (!PWORKSPACE)
- return;
-
- const auto PMONITOR = PWORKSPACE->m_monitor.lock();
- if (!PMONITOR)
- return;
-
- const auto edges = layout->getNodeDisplayEdgeFlags(box, PMONITOR);
- auto [gapsIn, gapsOut] = layout->getWorkspaceGaps(PWORKSPACE);
-
- const Vector2D availableSize = box.size() -
- Vector2D{(edges.left ? gapsOut.m_left : gapsIn.m_left / 2.f) + (edges.right ? gapsOut.m_right : gapsIn.m_right / 2.f),
- (edges.top ? gapsOut.m_top : gapsIn.m_top / 2.f) + (edges.bottom ? gapsOut.m_bottom : gapsIn.m_bottom / 2.f)};
-
if (*PPRESERVESPLIT == 0 && *PSMARTSPLIT == 0)
- splitTop = availableSize.y * *PFLMULT > availableSize.x;
+ splitTop = box.h * *PFLMULT > box.w;
if (verticalOverride)
splitTop = true;
@@ -64,28 +27,14 @@ void SDwindleNodeData::recalcSizePosRecursive(bool force, bool horizontalOverrid
if (SPLITSIDE) {
// split left/right
- const float gapsAppliedToChild1 = (edges.left ? gapsOut.m_left : gapsIn.m_left / 2.f) + gapsIn.m_right / 2.f;
- const float gapsAppliedToChild2 = gapsIn.m_left / 2.f + (edges.right ? gapsOut.m_right : gapsIn.m_right / 2.f);
- const float totalGaps = gapsAppliedToChild1 + gapsAppliedToChild2;
- const float totalAvailable = box.w - totalGaps;
-
- const float child1Available = totalAvailable * (splitRatio / 2.f);
- const float FIRSTSIZE = child1Available + gapsAppliedToChild1;
-
- children[0]->box = CBox{box.x, box.y, FIRSTSIZE, box.h}.noNegativeSize();
- children[1]->box = CBox{box.x + FIRSTSIZE, box.y, box.w - FIRSTSIZE, box.h}.noNegativeSize();
+ const float FIRSTSIZE = box.w / 2.0 * splitRatio;
+ children[0]->box = CBox{box.x, box.y, FIRSTSIZE, box.h}.noNegativeSize();
+ children[1]->box = CBox{box.x + FIRSTSIZE, box.y, box.w - FIRSTSIZE, box.h}.noNegativeSize();
} else {
// split top/bottom
- const float gapsAppliedToChild1 = (edges.top ? gapsOut.m_top : gapsIn.m_top / 2.f) + gapsIn.m_bottom / 2.f;
- const float gapsAppliedToChild2 = gapsIn.m_top / 2.f + (edges.bottom ? gapsOut.m_bottom : gapsIn.m_bottom / 2.f);
- const float totalGaps = gapsAppliedToChild1 + gapsAppliedToChild2;
- const float totalAvailable = box.h - totalGaps;
-
- const float child1Available = totalAvailable * (splitRatio / 2.f);
- const float FIRSTSIZE = child1Available + gapsAppliedToChild1;
-
- children[0]->box = CBox{box.x, box.y, box.w, FIRSTSIZE}.noNegativeSize();
- children[1]->box = CBox{box.x, box.y + FIRSTSIZE, box.w, box.h - FIRSTSIZE}.noNegativeSize();
+ const float FIRSTSIZE = box.h / 2.0 * splitRatio;
+ children[0]->box = CBox{box.x, box.y, box.w, FIRSTSIZE}.noNegativeSize();
+ children[1]->box = CBox{box.x, box.y + FIRSTSIZE, box.w, box.h - FIRSTSIZE}.noNegativeSize();
}
children[0]->recalcSizePosRecursive(force);
@@ -167,7 +116,10 @@ void CHyprDwindleLayout::applyNodeDataToWindow(SDwindleNodeData* pNode, bool for
}
// for gaps outer
- const auto edges = getNodeDisplayEdgeFlags(pNode->box, PMONITOR);
+ const bool DISPLAYLEFT = STICKS(pNode->box.x, PMONITOR->m_position.x + PMONITOR->m_reservedTopLeft.x);
+ const bool DISPLAYRIGHT = STICKS(pNode->box.x + pNode->box.w, PMONITOR->m_position.x + PMONITOR->m_size.x - PMONITOR->m_reservedBottomRight.x);
+ const bool DISPLAYTOP = STICKS(pNode->box.y, PMONITOR->m_position.y + PMONITOR->m_reservedTopLeft.y);
+ const bool DISPLAYBOTTOM = STICKS(pNode->box.y + pNode->box.h, PMONITOR->m_position.y + PMONITOR->m_size.y - PMONITOR->m_reservedBottomRight.y);
const auto PWINDOW = pNode->pWindow.lock();
// get specific gaps and rules for this workspace,
@@ -228,9 +180,9 @@ void CHyprDwindleLayout::applyNodeDataToWindow(SDwindleNodeData* pNode, bool for
}
}
- const auto GAPOFFSETTOPLEFT = Vector2D(sc<double>(edges.left ? gapsOut.m_left : gapsIn.m_left), sc<double>(edges.top ? gapsOut.m_top : gapsIn.m_top));
+ const auto GAPOFFSETTOPLEFT = Vector2D(sc<double>(DISPLAYLEFT ? gapsOut.m_left : gapsIn.m_left), sc<double>(DISPLAYTOP ? gapsOut.m_top : gapsIn.m_top));
- const auto GAPOFFSETBOTTOMRIGHT = Vector2D(sc<double>(edges.right ? gapsOut.m_right : gapsIn.m_right), sc<double>(edges.bottom ? gapsOut.m_bottom : gapsIn.m_bottom));
+ const auto GAPOFFSETBOTTOMRIGHT = Vector2D(sc<double>(DISPLAYRIGHT ? gapsOut.m_right : gapsIn.m_right), sc<double>(DISPLAYBOTTOM ? gapsOut.m_bottom : gapsIn.m_bottom));
calcPos = calcPos + GAPOFFSETTOPLEFT + ratioPadding / 2;
calcSize = calcSize - GAPOFFSETTOPLEFT - GAPOFFSETBOTTOMRIGHT - ratioPadding;
@@ -398,6 +350,7 @@ void CHyprDwindleLayout::onWindowCreatedTiling(PHLWINDOW pWindow, eDirection dir
}
// get the node under our cursor
+
m_dwindleNodesData.emplace_back();
const auto NEWPARENT = &m_dwindleNodesData.back();
@@ -410,17 +363,8 @@ void CHyprDwindleLayout::onWindowCreatedTiling(PHLWINDOW pWindow, eDirection dir
static auto PWIDTHMULTIPLIER = CConfigValue<Hyprlang::FLOAT>("dwindle:split_width_multiplier");
- const auto edges = getNodeDisplayEdgeFlags(NEWPARENT->box, PMONITOR);
-
- const auto WORKSPACE = g_pCompositor->getWorkspaceByID(PNODE->workspaceID);
- auto [gapsIn, gapsOut] = getWorkspaceGaps(WORKSPACE);
-
// if cursor over first child, make it first, etc
- const Vector2D availableSize = NEWPARENT->box.size() -
- Vector2D{(edges.left ? gapsOut.m_left : gapsIn.m_left / 2.f) + (edges.right ? gapsOut.m_right : gapsIn.m_right / 2.f),
- (edges.top ? gapsOut.m_top : gapsIn.m_top / 2.f) + (edges.bottom ? gapsOut.m_bottom : gapsIn.m_bottom / 2.f)};
-
- const auto SIDEBYSIDE = availableSize.x > availableSize.y * *PWIDTHMULTIPLIER;
+ const auto SIDEBYSIDE = NEWPARENT->box.w > NEWPARENT->box.h * *PWIDTHMULTIPLIER;
NEWPARENT->splitTop = !SIDEBYSIDE;
static auto PFORCESPLIT = CConfigValue<Hyprlang::INT>("dwindle:force_split");
@@ -675,8 +619,11 @@ void CHyprDwindleLayout::resizeActiveWindow(const Vector2D& pixResize, eRectCorn
static auto PSMARTRESIZING = CConfigValue<Hyprlang::INT>("dwindle:smart_resizing");
// get some data about our window
- const auto PMONITOR = PWINDOW->m_monitor.lock();
- const auto edges = getNodeDisplayEdgeFlags(CBox{PWINDOW->m_position, PWINDOW->m_size}, PMONITOR);
+ const auto PMONITOR = PWINDOW->m_monitor.lock();
+ const bool DISPLAYLEFT = STICKS(PWINDOW->m_position.x, PMONITOR->m_position.x + PMONITOR->m_reservedTopLeft.x);
+ const bool DISPLAYRIGHT = STICKS(PWINDOW->m_position.x + PWINDOW->m_size.x, PMONITOR->m_position.x + PMONITOR->m_size.x - PMONITOR->m_reservedBottomRight.x);
+ const bool DISPLAYTOP = STICKS(PWINDOW->m_position.y, PMONITOR->m_position.y + PMONITOR->m_reservedTopLeft.y);
+ const bool DISPLAYBOTTOM = STICKS(PWINDOW->m_position.y + PWINDOW->m_size.y, PMONITOR->m_position.y + PMONITOR->m_size.y - PMONITOR->m_reservedBottomRight.y);
if (PWINDOW->m_isPseudotiled) {
if (!m_pseudoDragFlags.started) {
@@ -724,10 +671,10 @@ void CHyprDwindleLayout::resizeActiveWindow(const Vector2D& pixResize, eRectCorn
// construct allowed movement
Vector2D allowedMovement = pixResize;
- if (edges.left && edges.right)
+ if (DISPLAYLEFT && DISPLAYRIGHT)
allowedMovement.x = 0;
- if (edges.bottom && edges.top)
+ if (DISPLAYBOTTOM && DISPLAYTOP)
allowedMovement.y = 0;
if (*PSMARTRESIZING == 1) {
@@ -737,10 +684,10 @@ void CHyprDwindleLayout::resizeActiveWindow(const Vector2D& pixResize, eRectCorn
SDwindleNodeData* PHOUTER = nullptr;
SDwindleNodeData* PHINNER = nullptr;
- const auto LEFT = corner == CORNER_TOPLEFT || corner == CORNER_BOTTOMLEFT || edges.right;
- const auto TOP = corner == CORNER_TOPLEFT || corner == CORNER_TOPRIGHT || edges.bottom;
- const auto RIGHT = corner == CORNER_TOPRIGHT || corner == CORNER_BOTTOMRIGHT || edges.left;
- const auto BOTTOM = corner == CORNER_BOTTOMLEFT || corner == CORNER_BOTTOMRIGHT || edges.top;
+ const auto LEFT = corner == CORNER_TOPLEFT || corner == CORNER_BOTTOMLEFT || DISPLAYRIGHT;
+ const auto TOP = corner == CORNER_TOPLEFT || corner == CORNER_TOPRIGHT || DISPLAYBOTTOM;
+ const auto RIGHT = corner == CORNER_TOPRIGHT || corner == CORNER_BOTTOMRIGHT || DISPLAYLEFT;
+ const auto BOTTOM = corner == CORNER_BOTTOMLEFT || corner == CORNER_BOTTOMRIGHT || DISPLAYTOP;
const auto NONE = corner == CORNER_NONE;
for (auto PCURRENT = PNODE; PCURRENT && PCURRENT->pParent; PCURRENT = PCURRENT->pParent) {