diff --git a/src/config/ConfigManager.cpp b/src/config/ConfigManager.cpp index 75c0bdef..f01f9b40 100644 --- a/src/config/ConfigManager.cpp +++ b/src/config/ConfigManager.cpp @@ -70,6 +70,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 c739fa1d..3b1e4f4c 100644 --- a/src/layout/DwindleLayout.cpp +++ b/src/layout/DwindleLayout.cpp @@ -23,19 +23,21 @@ 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; 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); @@ -246,16 +248,19 @@ void CHyprDwindleLayout::onWindowCreatedTiling(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; @@ -284,14 +289,16 @@ void CHyprDwindleLayout::onWindowCreatedTiling(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); @@ -854,4 +861,4 @@ void CHyprDwindleLayout::toggleSplit(CWindow* pWindow) { std::string CHyprDwindleLayout::getLayoutName() { return "dwindle"; -} \ No newline at end of file +}