summaryrefslogtreecommitdiff
path: root/src/layout/DwindleLayout.cpp
diff options
context:
space:
mode:
authorDaniel Adolfsson <daniel@ashen.se>2023-07-11 13:37:25 +0200
committerGitHub <noreply@github.com>2023-07-11 13:37:25 +0200
commit64e7d5345dddd755e361a6fce5a7f58b06a8b546 (patch)
tree4bdc0effcc9c6de0322ffbf39c587e3ed5854dab /src/layout/DwindleLayout.cpp
parent29d017f54bc4b41ec402e6ac91d4857b8305483a (diff)
Add support for smart splitting (#2676)
* Add support for smart splitting * clang-format * smart_split default to 0, and make smart_split behave like preserve_split
Diffstat (limited to 'src/layout/DwindleLayout.cpp')
-rw-r--r--src/layout/DwindleLayout.cpp29
1 files changed, 27 insertions, 2 deletions
diff --git a/src/layout/DwindleLayout.cpp b/src/layout/DwindleLayout.cpp
index dda9a53f..adf597ff 100644
--- a/src/layout/DwindleLayout.cpp
+++ b/src/layout/DwindleLayout.cpp
@@ -6,10 +6,11 @@ void SDwindleNodeData::recalcSizePosRecursive(bool force, bool horizontalOverrid
const auto REVERSESPLITRATIO = 2.f - splitRatio;
+ static auto* const PSMARTSPLIT = &g_pConfigManager->getConfigValuePtr("dwindle:smart_split")->intValue;
static auto* const PPRESERVESPLIT = &g_pConfigManager->getConfigValuePtr("dwindle:preserve_split")->intValue;
static auto* const PFLMULT = &g_pConfigManager->getConfigValuePtr("dwindle:split_width_multiplier")->floatValue;
- if (*PPRESERVESPLIT == 0) {
+ if (*PPRESERVESPLIT == 0 && *PSMARTSPLIT == 0) {
splitTop = size.y * *PFLMULT > size.x;
}
@@ -363,6 +364,7 @@ void CHyprDwindleLayout::onWindowCreatedTiling(CWindow* pWindow) {
static auto* const PFORCESPLIT = &g_pConfigManager->getConfigValuePtr("dwindle:force_split")->intValue;
static auto* const PERMANENTDIRECTIONOVERRIDE = &g_pConfigManager->getConfigValuePtr("dwindle:permanent_direction_override")->intValue;
+ static auto* const PSMARTSPLIT = &g_pConfigManager->getConfigValuePtr("dwindle:smart_split")->intValue;
bool horizontalOverride = false;
bool verticalOverride = false;
@@ -388,7 +390,30 @@ void CHyprDwindleLayout::onWindowCreatedTiling(CWindow* pWindow) {
// whether or not the override persists after opening one window
if (*PERMANENTDIRECTIONOVERRIDE == 0)
overrideDirection = OneTimeFocus::NOFOCUS;
-
+ } else if (*PSMARTSPLIT == 1) {
+ const auto tl = NEWPARENT->position;
+ const auto tr = NEWPARENT->position + Vector2D(NEWPARENT->size.x, 0);
+ const auto bl = NEWPARENT->position + Vector2D(0, NEWPARENT->size.y);
+ const auto br = NEWPARENT->position + NEWPARENT->size;
+ const auto cc = NEWPARENT->position + NEWPARENT->size / 2;
+
+ if (MOUSECOORDS.inTriangle(tl, tr, cc)) {
+ NEWPARENT->splitTop = true;
+ NEWPARENT->children[0] = PNODE;
+ NEWPARENT->children[1] = OPENINGON;
+ } else if (MOUSECOORDS.inTriangle(tr, cc, br)) {
+ NEWPARENT->splitTop = false;
+ NEWPARENT->children[0] = OPENINGON;
+ NEWPARENT->children[1] = PNODE;
+ } else if (MOUSECOORDS.inTriangle(br, bl, cc)) {
+ NEWPARENT->splitTop = true;
+ NEWPARENT->children[0] = OPENINGON;
+ NEWPARENT->children[1] = PNODE;
+ } else {
+ NEWPARENT->splitTop = false;
+ NEWPARENT->children[0] = PNODE;
+ NEWPARENT->children[1] = OPENINGON;
+ }
} else if (*PFORCESPLIT == 0 || !pWindow->m_bFirstMap) {
if ((SIDEBYSIDE &&
VECINRECT(MOUSECOORDS, NEWPARENT->position.x, NEWPARENT->position.y / *PWIDTHMULTIPLIER, NEWPARENT->position.x + NEWPARENT->size.x / 2.f,