From 3d46c739815b178fa77787083d02fabee8e79a21 Mon Sep 17 00:00:00 2001 From: Caleb Owens Date: Mon, 20 Jun 2022 14:37:27 +0100 Subject: [PATCH 1/2] Added a multiplier for the width to height ratio --- src/config/ConfigManager.cpp | 1 + src/layout/DwindleLayout.cpp | 8 +++++--- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/config/ConfigManager.cpp b/src/config/ConfigManager.cpp index d511c05a..60e72f76 100644 --- a/src/config/ConfigManager.cpp +++ b/src/config/ConfigManager.cpp @@ -53,6 +53,7 @@ void CConfigManager::setDefaultVars() { configValues["dwindle:force_split"].intValue = 0; configValues["dwindle:preserve_split"].intValue = 0; configValues["dwindle:special_scale_factor"].floatValue = 0.8f; + configValues["dwindle:split_width_multiplier"].floatValue = 1.0f; configValues["animations:enabled"].intValue = 1; configValues["animations:speed"].floatValue = 7.f; diff --git a/src/layout/DwindleLayout.cpp b/src/layout/DwindleLayout.cpp index ce63ace6..1a22bec0 100644 --- a/src/layout/DwindleLayout.cpp +++ b/src/layout/DwindleLayout.cpp @@ -23,8 +23,10 @@ void SDwindleNodeData::recalcSizePosRecursive() { const auto REVERSESPLITRATIO = 2.f - splitRatio; - if (g_pConfigManager->getInt("dwindle:preserve_split") == 0) - splitTop = size.y > size.x; + if (g_pConfigManager->getInt("dwindle:preserve_split") == 0) { + const auto WIDTHMULTIPLIER = g_pConfigManager->getFloat("dwindle:split_width_multiplier"); + splitTop = size.y * WIDTHMULTIPLIER > size.x; + } const auto SPLITSIDE = !splitTop; @@ -992,4 +994,4 @@ void CHyprDwindleLayout::toggleSplit(CWindow* pWindow) { std::string CHyprDwindleLayout::getLayoutName() { return "dwindle"; -} \ No newline at end of file +} From 7d80327e7dc241599695cbb92b0cd7b80c8ebf0d Mon Sep 17 00:00:00 2001 From: Caleb Owens Date: Mon, 20 Jun 2022 17:11:59 +0100 Subject: [PATCH 2/2] fixed vertical swapping issue --- src/layout/DwindleLayout.cpp | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/src/layout/DwindleLayout.cpp b/src/layout/DwindleLayout.cpp index 1a22bec0..84bc9450 100644 --- a/src/layout/DwindleLayout.cpp +++ b/src/layout/DwindleLayout.cpp @@ -31,13 +31,13 @@ void SDwindleNodeData::recalcSizePosRecursive() { const auto SPLITSIDE = !splitTop; if (SPLITSIDE) { - // split sidey + // split left/right children[0]->position = position; children[0]->size = Vector2D(size.x / 2.f * splitRatio, size.y); children[1]->position = Vector2D(position.x + size.x / 2.f * splitRatio, position.y); children[1]->size = Vector2D(size.x / 2.f * REVERSESPLITRATIO, size.y); } else { - // split toppy bottomy + // split top/bottom children[0]->position = position; children[0]->size = Vector2D(size.x, size.y / 2.f * splitRatio); children[1]->position = Vector2D(position.x, position.y + size.y / 2.f * splitRatio); @@ -237,16 +237,19 @@ void CHyprDwindleLayout::onWindowCreated(CWindow* pWindow) { NEWPARENT->pParent = OPENINGON->pParent; NEWPARENT->isNode = true; // it is a node + const auto WIDTHMULTIPLIER = g_pConfigManager->getFloat("dwindle:split_width_multiplier"); + // if cursor over first child, make it first, etc - const auto SIDEBYSIDE = NEWPARENT->size.x / NEWPARENT->size.y > 1.f; + const auto SIDEBYSIDE = NEWPARENT->size.x > NEWPARENT->size.y * WIDTHMULTIPLIER; NEWPARENT->splitTop = !SIDEBYSIDE; + const auto MOUSECOORDS = g_pInputManager->getMouseCoordsInternal(); const auto FORCESPLIT = g_pConfigManager->getInt("dwindle:force_split"); if (FORCESPLIT == 0) { - if ((SIDEBYSIDE && VECINRECT(MOUSECOORDS, NEWPARENT->position.x, NEWPARENT->position.y, NEWPARENT->position.x + NEWPARENT->size.x / 2.f, NEWPARENT->position.y + NEWPARENT->size.y)) - || (!SIDEBYSIDE && VECINRECT(MOUSECOORDS, NEWPARENT->position.x, NEWPARENT->position.y, NEWPARENT->position.x + NEWPARENT->size.x, NEWPARENT->position.y + NEWPARENT->size.y / 2.f))) { + if ((SIDEBYSIDE && VECINRECT(MOUSECOORDS, NEWPARENT->position.x, NEWPARENT->position.y / WIDTHMULTIPLIER, NEWPARENT->position.x + NEWPARENT->size.x / 2.f, NEWPARENT->position.y + NEWPARENT->size.y)) + || (!SIDEBYSIDE && VECINRECT(MOUSECOORDS, NEWPARENT->position.x, NEWPARENT->position.y / WIDTHMULTIPLIER, NEWPARENT->position.x + NEWPARENT->size.x, NEWPARENT->position.y + NEWPARENT->size.y / 2.f))) { // we are hovering over the first node, make PNODE first. NEWPARENT->children[1] = OPENINGON; NEWPARENT->children[0] = PNODE; @@ -275,14 +278,16 @@ void CHyprDwindleLayout::onWindowCreated(CWindow* pWindow) { } // Update the children - if (NEWPARENT->size.x > NEWPARENT->size.y) { - // split sidey + + + if (NEWPARENT->size.x * WIDTHMULTIPLIER > NEWPARENT->size.y) { + // split left/right OPENINGON->position = NEWPARENT->position; OPENINGON->size = Vector2D(NEWPARENT->size.x / 2.f, NEWPARENT->size.y); PNODE->position = Vector2D(NEWPARENT->position.x + NEWPARENT->size.x / 2.f, NEWPARENT->position.y); PNODE->size = Vector2D(NEWPARENT->size.x / 2.f, NEWPARENT->size.y); } else { - // split toppy bottomy + // split top/bottom OPENINGON->position = NEWPARENT->position; OPENINGON->size = Vector2D(NEWPARENT->size.x, NEWPARENT->size.y / 2.f); PNODE->position = Vector2D(NEWPARENT->position.x, NEWPARENT->position.y + NEWPARENT->size.y / 2.f);