aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/layout/DwindleLayout.cpp
diff options
context:
space:
mode:
authorNiklas Haas <[email protected]>2024-02-14 18:58:28 +0100
committerGitHub <[email protected]>2024-02-14 17:58:28 +0000
commitd5950f7719d3c9ec5305208265366df5ce81b6c3 (patch)
tree266ce4c88f113b3b77601ce16cbf16f615411a25 /src/layout/DwindleLayout.cpp
parent06087914807f88d2a9fc76c8108985f6327598de (diff)
downloadHyprland-d5950f7719d3c9ec5305208265366df5ce81b6c3.tar.gz
Hyprland-d5950f7719d3c9ec5305208265366df5ce81b6c3.zip
dwindle: add swapsplit dispatcher (#4702)
This is distinct from `swapwindow` in that it allows swapping the entire tree node with its neighbour. Fixes: https://github.com/hyprwm/Hyprland/issues/4701
Diffstat (limited to 'src/layout/DwindleLayout.cpp')
-rw-r--r--src/layout/DwindleLayout.cpp16
1 files changed, 16 insertions, 0 deletions
diff --git a/src/layout/DwindleLayout.cpp b/src/layout/DwindleLayout.cpp
index 11be13ae..9db011d1 100644
--- a/src/layout/DwindleLayout.cpp
+++ b/src/layout/DwindleLayout.cpp
@@ -996,6 +996,8 @@ std::any CHyprDwindleLayout::layoutMessage(SLayoutMessageHeader header, std::str
const auto ARGS = CVarList(message, 0, ' ');
if (ARGS[0] == "togglesplit") {
toggleSplit(header.pWindow);
+ } else if (ARGS[0] == "swapsplit") {
+ swapSplit(header.pWindow);
} else if (ARGS[0] == "preselect") {
std::string direction = ARGS[1];
@@ -1049,6 +1051,20 @@ void CHyprDwindleLayout::toggleSplit(CWindow* pWindow) {
PNODE->pParent->recalcSizePosRecursive();
}
+void CHyprDwindleLayout::swapSplit(CWindow* pWindow) {
+ const auto PNODE = getNodeFromWindow(pWindow);
+
+ if (!PNODE || !PNODE->pParent)
+ return;
+
+ if (pWindow->m_bIsFullscreen)
+ return;
+
+ std::swap(PNODE->pParent->children[0], PNODE->pParent->children[1]);
+
+ PNODE->pParent->recalcSizePosRecursive();
+}
+
void CHyprDwindleLayout::replaceWindowDataWith(CWindow* from, CWindow* to) {
const auto PNODE = getNodeFromWindow(from);