diff options
| author | vaxerski <43317083+vaxerski@users.noreply.github.com> | 2022-04-20 16:53:41 +0200 |
|---|---|---|
| committer | vaxerski <43317083+vaxerski@users.noreply.github.com> | 2022-04-20 16:53:41 +0200 |
| commit | 87b849129427ab664130aa1abc8ade0485328e33 (patch) | |
| tree | 7275db50df7f47389d1f91948cede19ded8c26a5 /src/layout | |
| parent | 418e2d96aef0b52d1f93eb3dfe7d08906c7c719c (diff) | |
Added the splitratio dispatcher
Diffstat (limited to 'src/layout')
| -rw-r--r-- | src/layout/DwindleLayout.cpp | 13 | ||||
| -rw-r--r-- | src/layout/DwindleLayout.hpp | 3 | ||||
| -rw-r--r-- | src/layout/IHyprLayout.hpp | 6 |
3 files changed, 21 insertions, 1 deletions
diff --git a/src/layout/DwindleLayout.cpp b/src/layout/DwindleLayout.cpp index 5b7ee165..e7f4b87a 100644 --- a/src/layout/DwindleLayout.cpp +++ b/src/layout/DwindleLayout.cpp @@ -778,4 +778,17 @@ void CHyprDwindleLayout::switchWindows(CWindow* pWindow, CWindow* pWindow2) { // recalc the workspace getMasterNodeOnWorkspace(PNODE->workspaceID)->recalcSizePosRecursive(); +} + +void CHyprDwindleLayout::alterSplitRatioBy(CWindow* pWindow, float ratio) { + // window should be valid, insallah + + const auto PNODE = getNodeFromWindow(pWindow); + + if (!PNODE || !PNODE->pParent) + return; + + PNODE->pParent->splitRatio = std::clamp(PNODE->pParent->splitRatio + ratio, 0.1f, 1.9f); + + PNODE->pParent->recalcSizePosRecursive(); }
\ No newline at end of file diff --git a/src/layout/DwindleLayout.hpp b/src/layout/DwindleLayout.hpp index 68496723..7eeb5793 100644 --- a/src/layout/DwindleLayout.hpp +++ b/src/layout/DwindleLayout.hpp @@ -51,7 +51,8 @@ public: virtual void toggleWindowGroup(CWindow*); virtual void switchGroupWindow(CWindow*); virtual SWindowRenderLayoutHints requestRenderHints(CWindow*); - virtual void switchWindows(CWindow*, CWindow*); + virtual void switchWindows(CWindow*, CWindow*); + virtual void alterSplitRatioBy(CWindow*, float); private: diff --git a/src/layout/IHyprLayout.hpp b/src/layout/IHyprLayout.hpp index 341d5fbb..6d40ef03 100644 --- a/src/layout/IHyprLayout.hpp +++ b/src/layout/IHyprLayout.hpp @@ -90,4 +90,10 @@ public: The layout is free to ignore. */ virtual void switchWindows(CWindow*, CWindow*) = 0; + + /* + Called when the user requests to change the splitratio by X + on a window + */ + virtual void alterSplitRatioBy(CWindow*, float) = 0; };
\ No newline at end of file |
