diff options
| author | vaxerski <43317083+vaxerski@users.noreply.github.com> | 2022-05-16 17:27:55 +0200 |
|---|---|---|
| committer | vaxerski <43317083+vaxerski@users.noreply.github.com> | 2022-05-16 17:27:55 +0200 |
| commit | e90c1f7022ffd82e463c48260a97850c834f347d (patch) | |
| tree | ec8593b84ec0d374efce6b55e941f877c7d34a6e /src/layout/DwindleLayout.cpp | |
| parent | e991550abe8f4b13af586d635cdfec3b5c18fcd9 (diff) | |
added dwindle:preserve_split
Diffstat (limited to 'src/layout/DwindleLayout.cpp')
| -rw-r--r-- | src/layout/DwindleLayout.cpp | 33 |
1 files changed, 29 insertions, 4 deletions
diff --git a/src/layout/DwindleLayout.cpp b/src/layout/DwindleLayout.cpp index 620143f6..c7e3aa12 100644 --- a/src/layout/DwindleLayout.cpp +++ b/src/layout/DwindleLayout.cpp @@ -23,7 +23,12 @@ void SDwindleNodeData::recalcSizePosRecursive() { const auto REVERSESPLITRATIO = 2.f - splitRatio; - if (size.x > size.y) { + if (g_pConfigManager->getInt("dwindle:preserve_split") == 0) + splitTop = size.y > size.x; + + const auto SPLITSIDE = !splitTop; + + if (SPLITSIDE) { // split sidey children[0]->position = position; children[0]->size = Vector2D(size.x / 2.f * splitRatio, size.y); @@ -213,6 +218,7 @@ void CHyprDwindleLayout::onWindowCreated(CWindow* pWindow) { // if cursor over first child, make it first, etc const auto SIDEBYSIDE = NEWPARENT->size.x / NEWPARENT->size.y > 1.f; + NEWPARENT->splitTop = !SIDEBYSIDE; const auto MOUSECOORDS = g_pInputManager->getMouseCoordsInternal(); const auto FORCESPLIT = g_pConfigManager->getInt("dwindle:force_split"); @@ -485,10 +491,10 @@ void CHyprDwindleLayout::onMouseMove(const Vector2D& mousePos) { if (!PPARENT) return; // the only window on a workspace, ignore - const bool PARENTSIDEBYSIDE = PPARENT->size.x / PPARENT->size.y > 1.f; + const bool PARENTSIDEBYSIDE = !PPARENT->splitTop; // Get the parent's parent - const auto PPARENT2 = PPARENT->pParent; + auto PPARENT2 = PPARENT->pParent; // No parent means we have only 2 windows, and thus one axis of freedom if (!PPARENT2) { @@ -505,7 +511,26 @@ void CHyprDwindleLayout::onMouseMove(const Vector2D& mousePos) { return; } - // If there is a parent 2, we have 2 axes of freedom + // Get first parent with other split + while(PPARENT2 && PPARENT2->splitTop == !PARENTSIDEBYSIDE) + PPARENT2 = PPARENT2->pParent; + + // no parent, one axis of freedom + if (!PPARENT2) { + if (PARENTSIDEBYSIDE) { + allowedMovement.x *= 2.f / PPARENT->size.x; + PPARENT->splitRatio = std::clamp(PPARENT->splitRatio + allowedMovement.x, (double)0.1f, (double)1.9f); + PPARENT->recalcSizePosRecursive(); + } else { + allowedMovement.y *= 2.f / PPARENT->size.y; + PPARENT->splitRatio = std::clamp(PPARENT->splitRatio + allowedMovement.y, (double)0.1f, (double)1.9f); + PPARENT->recalcSizePosRecursive(); + } + + return; + } + + // 2 axes of freedom const auto SIDECONTAINER = PARENTSIDEBYSIDE ? PPARENT : PPARENT2; const auto TOPCONTAINER = PARENTSIDEBYSIDE ? PPARENT2 : PPARENT; |
