diff options
author | vaxerski <[email protected]> | 2022-05-16 17:37:46 +0200 |
---|---|---|
committer | vaxerski <[email protected]> | 2022-05-16 17:37:46 +0200 |
commit | 50f978e518c83872a25a47b5ddde310ec24ac203 (patch) | |
tree | e7632acf6ea22eae66fd1262e834212ff197fdf4 | |
parent | e90c1f7022ffd82e463c48260a97850c834f347d (diff) | |
download | Hyprland-50f978e518c83872a25a47b5ddde310ec24ac203.tar.gz Hyprland-50f978e518c83872a25a47b5ddde310ec24ac203.zip |
Added togglesplit dispatcher
-rw-r--r-- | src/layout/DwindleLayout.cpp | 20 | ||||
-rw-r--r-- | src/layout/DwindleLayout.hpp | 7 | ||||
-rw-r--r-- | src/layout/IHyprLayout.hpp | 16 | ||||
-rw-r--r-- | src/managers/KeybindManager.cpp | 15 | ||||
-rw-r--r-- | src/managers/KeybindManager.hpp | 1 |
5 files changed, 46 insertions, 13 deletions
diff --git a/src/layout/DwindleLayout.cpp b/src/layout/DwindleLayout.cpp index c7e3aa12..d224e775 100644 --- a/src/layout/DwindleLayout.cpp +++ b/src/layout/DwindleLayout.cpp @@ -833,4 +833,24 @@ void CHyprDwindleLayout::alterSplitRatioBy(CWindow* pWindow, float ratio) { PNODE->pParent->splitRatio = std::clamp(PNODE->pParent->splitRatio + ratio, 0.1f, 1.9f); PNODE->pParent->recalcSizePosRecursive(); +} + +void CHyprDwindleLayout::layoutMessage(SLayoutMessageHeader header, std::string message) { + if (message == "togglegroup") + toggleWindowGroup(header.pWindow); + else if (message == "changegroupactive") + switchGroupWindow(header.pWindow); + else if (message == "togglesplit") + toggleSplit(header.pWindow); +} + +void CHyprDwindleLayout::toggleSplit(CWindow* pWindow) { + const auto PNODE = getNodeFromWindow(pWindow); + + if (!PNODE || !PNODE->pParent) + return; + + PNODE->pParent->splitTop = !PNODE->pParent->splitTop; + + PNODE->pParent->recalcSizePosRecursive(); }
\ No newline at end of file diff --git a/src/layout/DwindleLayout.hpp b/src/layout/DwindleLayout.hpp index c1fd7a7b..5513e0f8 100644 --- a/src/layout/DwindleLayout.hpp +++ b/src/layout/DwindleLayout.hpp @@ -50,8 +50,7 @@ public: virtual void onMouseMove(const Vector2D&); virtual void onWindowCreatedFloating(CWindow*); virtual void fullscreenRequestForWindow(CWindow*); - virtual void toggleWindowGroup(CWindow*); - virtual void switchGroupWindow(CWindow*); + virtual void layoutMessage(SLayoutMessageHeader, std::string); virtual SWindowRenderLayoutHints requestRenderHints(CWindow*); virtual void switchWindows(CWindow*, CWindow*); virtual void alterSplitRatioBy(CWindow*, float); @@ -71,5 +70,9 @@ public: SDwindleNodeData* getFirstNodeOnWorkspace(const int&); SDwindleNodeData* getMasterNodeOnWorkspace(const int&); + void toggleWindowGroup(CWindow*); + void switchGroupWindow(CWindow*); + void toggleSplit(CWindow*); + friend struct SDwindleNodeData; };
\ No newline at end of file diff --git a/src/layout/IHyprLayout.hpp b/src/layout/IHyprLayout.hpp index 2f569b6e..71f30e3d 100644 --- a/src/layout/IHyprLayout.hpp +++ b/src/layout/IHyprLayout.hpp @@ -8,6 +8,10 @@ struct SWindowRenderLayoutHints { CColor borderColor; }; +struct SLayoutMessageHeader { + CWindow* pWindow = nullptr; +}; + interface IHyprLayout { public: @@ -69,16 +73,10 @@ public: virtual void fullscreenRequestForWindow(CWindow*) = 0; /* - Called when the user requests a window to be made into a group, - or when they want the group to be released. - Everything else is free to interpret by the layout. - */ - virtual void toggleWindowGroup(CWindow*) = 0; - - /* - Called when the user requests a group window switch + Called when a dispatcher requests a custom message + The layout is free to ignore. */ - virtual void switchGroupWindow(CWindow*) = 0; + virtual void layoutMessage(SLayoutMessageHeader, std::string) = 0; /* Required to be handled, but may return just SWindowRenderLayoutHints() diff --git a/src/managers/KeybindManager.cpp b/src/managers/KeybindManager.cpp index c41f552a..e58819d8 100644 --- a/src/managers/KeybindManager.cpp +++ b/src/managers/KeybindManager.cpp @@ -14,6 +14,7 @@ CKeybindManager::CKeybindManager() { m_mDispatchers["movewindow"] = moveActiveTo; m_mDispatchers["togglegroup"] = toggleGroup; m_mDispatchers["changegroupactive"] = changeGroupActive; + m_mDispatchers["togglesplit"] = toggleSplit; m_mDispatchers["splitratio"] = alterSplitRatio; m_mDispatchers["focusmonitor"] = focusMonitor; } @@ -432,11 +433,21 @@ void CKeybindManager::moveActiveTo(std::string args) { } void CKeybindManager::toggleGroup(std::string args) { - g_pLayoutManager->getCurrentLayout()->toggleWindowGroup(g_pCompositor->m_pLastWindow); + SLayoutMessageHeader header; + header.pWindow = g_pCompositor->m_pLastWindow; + g_pLayoutManager->getCurrentLayout()->layoutMessage(header, "togglegroup"); } void CKeybindManager::changeGroupActive(std::string args) { - g_pLayoutManager->getCurrentLayout()->switchGroupWindow(g_pCompositor->m_pLastWindow); + SLayoutMessageHeader header; + header.pWindow = g_pCompositor->m_pLastWindow; + g_pLayoutManager->getCurrentLayout()->layoutMessage(header, "changegroupactive"); +} + +void CKeybindManager::toggleSplit(std::string args) { + SLayoutMessageHeader header; + header.pWindow = g_pCompositor->m_pLastWindow; + g_pLayoutManager->getCurrentLayout()->layoutMessage(header, "togglesplit"); } void CKeybindManager::alterSplitRatio(std::string args) { diff --git a/src/managers/KeybindManager.hpp b/src/managers/KeybindManager.hpp index 9737d092..7f01859a 100644 --- a/src/managers/KeybindManager.hpp +++ b/src/managers/KeybindManager.hpp @@ -44,6 +44,7 @@ private: static void changeGroupActive(std::string); static void alterSplitRatio(std::string); static void focusMonitor(std::string); + static void toggleSplit(std::string); }; inline std::unique_ptr<CKeybindManager> g_pKeybindManager;
\ No newline at end of file |