99#include " ../managers/EventManager.hpp"
1010#include " xwayland/XWayland.hpp"
1111
12- SWorkspaceGaps CHyprDwindleLayout::getWorkspaceGaps (const PHLWORKSPACE& pWorkspace) {
13- const auto WORKSPACERULE = g_pConfigManager->getWorkspaceRuleFor (pWorkspace);
14- static auto PGAPSINDATA = CConfigValue<Hyprlang::CUSTOMTYPE>(" general:gaps_in" );
15- static auto PGAPSOUTDATA = CConfigValue<Hyprlang::CUSTOMTYPE>(" general:gaps_out" );
16- auto * const PGAPSIN = sc<CCssGapData*>((PGAPSINDATA.ptr ())->getData ());
17- auto * const PGAPSOUT = sc<CCssGapData*>((PGAPSOUTDATA.ptr ())->getData ());
18-
19- SWorkspaceGaps gaps;
20- gaps.in = WORKSPACERULE.gapsIn .value_or (*PGAPSIN);
21- gaps.out = WORKSPACERULE.gapsOut .value_or (*PGAPSOUT);
22- return gaps;
23- }
24-
25- SNodeDisplayEdgeFlags CHyprDwindleLayout::getNodeDisplayEdgeFlags (const CBox& box, const PHLMONITOR& monitor) {
26- return {
27- .top = STICKS (box.y , monitor->m_position .y + monitor->m_reservedTopLeft .y ),
28- .bottom = STICKS (box.y + box.h , monitor->m_position .y + monitor->m_size .y - monitor->m_reservedBottomRight .y ),
29- .left = STICKS (box.x , monitor->m_position .x + monitor->m_reservedTopLeft .x ),
30- .right = STICKS (box.x + box.w , monitor->m_position .x + monitor->m_size .x - monitor->m_reservedBottomRight .x ),
31- };
32- }
33-
3412void SDwindleNodeData::recalcSizePosRecursive (bool force, bool horizontalOverride, bool verticalOverride) {
3513 if (children[0 ]) {
3614 static auto PSMARTSPLIT = CConfigValue<Hyprlang::INT>(" dwindle:smart_split" );
3715 static auto PPRESERVESPLIT = CConfigValue<Hyprlang::INT>(" dwindle:preserve_split" );
3816 static auto PFLMULT = CConfigValue<Hyprlang::FLOAT>(" dwindle:split_width_multiplier" );
3917
40- const auto PWORKSPACE = g_pCompositor->getWorkspaceByID (workspaceID);
41- if (!PWORKSPACE)
42- return ;
43-
44- const auto PMONITOR = PWORKSPACE->m_monitor .lock ();
45- if (!PMONITOR)
46- return ;
47-
48- const auto edges = layout->getNodeDisplayEdgeFlags (box, PMONITOR);
49- auto [gapsIn, gapsOut] = layout->getWorkspaceGaps (PWORKSPACE);
50-
51- const Vector2D availableSize = box.size () -
52- Vector2D{(edges.left ? gapsOut.m_left : gapsIn.m_left / 2 .f ) + (edges.right ? gapsOut.m_right : gapsIn.m_right / 2 .f ),
53- (edges.top ? gapsOut.m_top : gapsIn.m_top / 2 .f ) + (edges.bottom ? gapsOut.m_bottom : gapsIn.m_bottom / 2 .f )};
54-
5518 if (*PPRESERVESPLIT == 0 && *PSMARTSPLIT == 0 )
56- splitTop = availableSize. y * *PFLMULT > availableSize. x ;
19+ splitTop = box. h * *PFLMULT > box. w ;
5720
5821 if (verticalOverride)
5922 splitTop = true ;
@@ -64,28 +27,14 @@ void SDwindleNodeData::recalcSizePosRecursive(bool force, bool horizontalOverrid
6427
6528 if (SPLITSIDE) {
6629 // split left/right
67- const float gapsAppliedToChild1 = (edges.left ? gapsOut.m_left : gapsIn.m_left / 2 .f ) + gapsIn.m_right / 2 .f ;
68- const float gapsAppliedToChild2 = gapsIn.m_left / 2 .f + (edges.right ? gapsOut.m_right : gapsIn.m_right / 2 .f );
69- const float totalGaps = gapsAppliedToChild1 + gapsAppliedToChild2;
70- const float totalAvailable = box.w - totalGaps;
71-
72- const float child1Available = totalAvailable * (splitRatio / 2 .f );
73- const float FIRSTSIZE = child1Available + gapsAppliedToChild1;
74-
75- children[0 ]->box = CBox{box.x , box.y , FIRSTSIZE, box.h }.noNegativeSize ();
76- children[1 ]->box = CBox{box.x + FIRSTSIZE, box.y , box.w - FIRSTSIZE, box.h }.noNegativeSize ();
30+ const float FIRSTSIZE = box.w / 2.0 * splitRatio;
31+ children[0 ]->box = CBox{box.x , box.y , FIRSTSIZE, box.h }.noNegativeSize ();
32+ children[1 ]->box = CBox{box.x + FIRSTSIZE, box.y , box.w - FIRSTSIZE, box.h }.noNegativeSize ();
7733 } else {
7834 // split top/bottom
79- const float gapsAppliedToChild1 = (edges.top ? gapsOut.m_top : gapsIn.m_top / 2 .f ) + gapsIn.m_bottom / 2 .f ;
80- const float gapsAppliedToChild2 = gapsIn.m_top / 2 .f + (edges.bottom ? gapsOut.m_bottom : gapsIn.m_bottom / 2 .f );
81- const float totalGaps = gapsAppliedToChild1 + gapsAppliedToChild2;
82- const float totalAvailable = box.h - totalGaps;
83-
84- const float child1Available = totalAvailable * (splitRatio / 2 .f );
85- const float FIRSTSIZE = child1Available + gapsAppliedToChild1;
86-
87- children[0 ]->box = CBox{box.x , box.y , box.w , FIRSTSIZE}.noNegativeSize ();
88- children[1 ]->box = CBox{box.x , box.y + FIRSTSIZE, box.w , box.h - FIRSTSIZE}.noNegativeSize ();
35+ const float FIRSTSIZE = box.h / 2.0 * splitRatio;
36+ children[0 ]->box = CBox{box.x , box.y , box.w , FIRSTSIZE}.noNegativeSize ();
37+ children[1 ]->box = CBox{box.x , box.y + FIRSTSIZE, box.w , box.h - FIRSTSIZE}.noNegativeSize ();
8938 }
9039
9140 children[0 ]->recalcSizePosRecursive (force);
@@ -167,7 +116,10 @@ void CHyprDwindleLayout::applyNodeDataToWindow(SDwindleNodeData* pNode, bool for
167116 }
168117
169118 // for gaps outer
170- const auto edges = getNodeDisplayEdgeFlags (pNode->box , PMONITOR);
119+ const bool DISPLAYLEFT = STICKS (pNode->box .x , PMONITOR->m_position .x + PMONITOR->m_reservedTopLeft .x );
120+ const bool DISPLAYRIGHT = STICKS (pNode->box .x + pNode->box .w , PMONITOR->m_position .x + PMONITOR->m_size .x - PMONITOR->m_reservedBottomRight .x );
121+ const bool DISPLAYTOP = STICKS (pNode->box .y , PMONITOR->m_position .y + PMONITOR->m_reservedTopLeft .y );
122+ const bool DISPLAYBOTTOM = STICKS (pNode->box .y + pNode->box .h , PMONITOR->m_position .y + PMONITOR->m_size .y - PMONITOR->m_reservedBottomRight .y );
171123
172124 const auto PWINDOW = pNode->pWindow .lock ();
173125 // get specific gaps and rules for this workspace,
@@ -228,9 +180,9 @@ void CHyprDwindleLayout::applyNodeDataToWindow(SDwindleNodeData* pNode, bool for
228180 }
229181 }
230182
231- const auto GAPOFFSETTOPLEFT = Vector2D (sc<double >(edges. left ? gapsOut.m_left : gapsIn.m_left ), sc<double >(edges. top ? gapsOut.m_top : gapsIn.m_top ));
183+ const auto GAPOFFSETTOPLEFT = Vector2D (sc<double >(DISPLAYLEFT ? gapsOut.m_left : gapsIn.m_left ), sc<double >(DISPLAYTOP ? gapsOut.m_top : gapsIn.m_top ));
232184
233- const auto GAPOFFSETBOTTOMRIGHT = Vector2D (sc<double >(edges. right ? gapsOut.m_right : gapsIn.m_right ), sc<double >(edges. bottom ? gapsOut.m_bottom : gapsIn.m_bottom ));
185+ const auto GAPOFFSETBOTTOMRIGHT = Vector2D (sc<double >(DISPLAYRIGHT ? gapsOut.m_right : gapsIn.m_right ), sc<double >(DISPLAYBOTTOM ? gapsOut.m_bottom : gapsIn.m_bottom ));
234186
235187 calcPos = calcPos + GAPOFFSETTOPLEFT + ratioPadding / 2 ;
236188 calcSize = calcSize - GAPOFFSETTOPLEFT - GAPOFFSETBOTTOMRIGHT - ratioPadding;
@@ -398,6 +350,7 @@ void CHyprDwindleLayout::onWindowCreatedTiling(PHLWINDOW pWindow, eDirection dir
398350 }
399351
400352 // get the node under our cursor
353+
401354 m_dwindleNodesData.emplace_back ();
402355 const auto NEWPARENT = &m_dwindleNodesData.back ();
403356
@@ -410,17 +363,8 @@ void CHyprDwindleLayout::onWindowCreatedTiling(PHLWINDOW pWindow, eDirection dir
410363
411364 static auto PWIDTHMULTIPLIER = CConfigValue<Hyprlang::FLOAT>(" dwindle:split_width_multiplier" );
412365
413- const auto edges = getNodeDisplayEdgeFlags (NEWPARENT->box , PMONITOR);
414-
415- const auto WORKSPACE = g_pCompositor->getWorkspaceByID (PNODE->workspaceID );
416- auto [gapsIn, gapsOut] = getWorkspaceGaps (WORKSPACE);
417-
418366 // if cursor over first child, make it first, etc
419- const Vector2D availableSize = NEWPARENT->box .size () -
420- Vector2D{(edges.left ? gapsOut.m_left : gapsIn.m_left / 2 .f ) + (edges.right ? gapsOut.m_right : gapsIn.m_right / 2 .f ),
421- (edges.top ? gapsOut.m_top : gapsIn.m_top / 2 .f ) + (edges.bottom ? gapsOut.m_bottom : gapsIn.m_bottom / 2 .f )};
422-
423- const auto SIDEBYSIDE = availableSize.x > availableSize.y * *PWIDTHMULTIPLIER;
367+ const auto SIDEBYSIDE = NEWPARENT->box .w > NEWPARENT->box .h * *PWIDTHMULTIPLIER;
424368 NEWPARENT->splitTop = !SIDEBYSIDE;
425369
426370 static auto PFORCESPLIT = CConfigValue<Hyprlang::INT>(" dwindle:force_split" );
@@ -675,8 +619,11 @@ void CHyprDwindleLayout::resizeActiveWindow(const Vector2D& pixResize, eRectCorn
675619 static auto PSMARTRESIZING = CConfigValue<Hyprlang::INT>(" dwindle:smart_resizing" );
676620
677621 // get some data about our window
678- const auto PMONITOR = PWINDOW->m_monitor .lock ();
679- const auto edges = getNodeDisplayEdgeFlags (CBox{PWINDOW->m_position , PWINDOW->m_size }, PMONITOR);
622+ const auto PMONITOR = PWINDOW->m_monitor .lock ();
623+ const bool DISPLAYLEFT = STICKS (PWINDOW->m_position .x , PMONITOR->m_position .x + PMONITOR->m_reservedTopLeft .x );
624+ const bool DISPLAYRIGHT = STICKS (PWINDOW->m_position .x + PWINDOW->m_size .x , PMONITOR->m_position .x + PMONITOR->m_size .x - PMONITOR->m_reservedBottomRight .x );
625+ const bool DISPLAYTOP = STICKS (PWINDOW->m_position .y , PMONITOR->m_position .y + PMONITOR->m_reservedTopLeft .y );
626+ const bool DISPLAYBOTTOM = STICKS (PWINDOW->m_position .y + PWINDOW->m_size .y , PMONITOR->m_position .y + PMONITOR->m_size .y - PMONITOR->m_reservedBottomRight .y );
680627
681628 if (PWINDOW->m_isPseudotiled ) {
682629 if (!m_pseudoDragFlags.started ) {
@@ -724,10 +671,10 @@ void CHyprDwindleLayout::resizeActiveWindow(const Vector2D& pixResize, eRectCorn
724671
725672 // construct allowed movement
726673 Vector2D allowedMovement = pixResize;
727- if (edges. left && edges. right )
674+ if (DISPLAYLEFT && DISPLAYRIGHT )
728675 allowedMovement.x = 0 ;
729676
730- if (edges. bottom && edges. top )
677+ if (DISPLAYBOTTOM && DISPLAYTOP )
731678 allowedMovement.y = 0 ;
732679
733680 if (*PSMARTRESIZING == 1 ) {
@@ -737,10 +684,10 @@ void CHyprDwindleLayout::resizeActiveWindow(const Vector2D& pixResize, eRectCorn
737684 SDwindleNodeData* PHOUTER = nullptr ;
738685 SDwindleNodeData* PHINNER = nullptr ;
739686
740- const auto LEFT = corner == CORNER_TOPLEFT || corner == CORNER_BOTTOMLEFT || edges. right ;
741- const auto TOP = corner == CORNER_TOPLEFT || corner == CORNER_TOPRIGHT || edges. bottom ;
742- const auto RIGHT = corner == CORNER_TOPRIGHT || corner == CORNER_BOTTOMRIGHT || edges. left ;
743- const auto BOTTOM = corner == CORNER_BOTTOMLEFT || corner == CORNER_BOTTOMRIGHT || edges. top ;
687+ const auto LEFT = corner == CORNER_TOPLEFT || corner == CORNER_BOTTOMLEFT || DISPLAYRIGHT ;
688+ const auto TOP = corner == CORNER_TOPLEFT || corner == CORNER_TOPRIGHT || DISPLAYBOTTOM ;
689+ const auto RIGHT = corner == CORNER_TOPRIGHT || corner == CORNER_BOTTOMRIGHT || DISPLAYLEFT ;
690+ const auto BOTTOM = corner == CORNER_BOTTOMLEFT || corner == CORNER_BOTTOMRIGHT || DISPLAYTOP ;
744691 const auto NONE = corner == CORNER_NONE;
745692
746693 for (auto PCURRENT = PNODE; PCURRENT && PCURRENT->pParent ; PCURRENT = PCURRENT->pParent ) {
0 commit comments