From 0cc5af9e607c0abccc8e87c5a15991340f008a3a Mon Sep 17 00:00:00 2001 From: outfoxxed Date: Sun, 20 Aug 2023 03:13:08 -0700 Subject: [PATCH] Add `visible` option to movewindow Allows movement between only visible nodes, skipping all hidden tab groups --- README.md | 3 ++- src/Hy3Layout.cpp | 16 +++++++++++++--- src/Hy3Layout.hpp | 2 +- src/dispatchers.cpp | 17 +++++++++++++++-- 4 files changed, 31 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index 74004ad..e04bf79 100644 --- a/README.md +++ b/README.md @@ -222,8 +222,9 @@ plugin { - `hy3:setephemeral, ` - change the ephemerality of the group the node belongs to - `hy3:movefocus, , [visible]` - move the focus left, up, down, or right - `visible` - only move between visible nodes, not hidden tabs - - `hy3:movewindow, , [once]` - move a window left, up, down, or right + - `hy3:movewindow, , [once], [visible]` - move a window left, up, down, or right - `once` - only move directly to the neighboring group, without moving into any of its subgroups + - `visible` - only move between visible nodes, not hidden tabs - `hy3:killactive` - close all windows in the focused node - `hy3:changefocus, ` - `top` - focus all nodes in the workspace diff --git a/src/Hy3Layout.cpp b/src/Hy3Layout.cpp index 7564abe..12a67ab 100644 --- a/src/Hy3Layout.cpp +++ b/src/Hy3Layout.cpp @@ -874,7 +874,7 @@ void Hy3Layout::changeGroupEphemeralityOn(Hy3Node& node, bool ephemeral) { ); } -void Hy3Layout::shiftWindow(int workspace, ShiftDirection direction, bool once) { +void Hy3Layout::shiftWindow(int workspace, ShiftDirection direction, bool once, bool visible) { auto* node = this->getWorkspaceFocusedNode(workspace); Debug::log(LOG, "ShiftWindow %p %d", node, direction); if (node == nullptr) return; @@ -890,7 +890,7 @@ void Hy3Layout::shiftWindow(int workspace, ShiftDirection direction, bool once) node2->recalcSizePosRecursive(); } } else { - this->shiftOrGetFocus(*node, direction, true, once, false); + this->shiftOrGetFocus(*node, direction, true, once, visible); } } @@ -1584,7 +1584,17 @@ Hy3Node* Hy3Layout::shiftOrGetFocus( group_data.children.end(), group_data.focused_child ); - } else if (shiftMatchesLayout(group_data.layout, direction)) { + } else if (visible && group_data.layout == Hy3GroupLayout::Tabbed && group_data.focused_child != nullptr) + { + // if the group is tabbed and we're going by visible nodes, jump to the current entry + iter = std::find( + group_data.children.begin(), + group_data.children.end(), + group_data.focused_child + ); + shift_after = true; + } else if (shiftMatchesLayout(group_data.layout, direction) || (visible && group_data.layout == Hy3GroupLayout::Tabbed)) + { // if the group has the same orientation as movement pick the // last/first child based on movement direction if (shiftIsForward(direction)) iter = group_data.children.begin(); diff --git a/src/Hy3Layout.hpp b/src/Hy3Layout.hpp index d6728e2..83f81c7 100644 --- a/src/Hy3Layout.hpp +++ b/src/Hy3Layout.hpp @@ -102,7 +102,7 @@ class Hy3Layout: public IHyprLayout { void toggleTabGroupOn(Hy3Node&); void changeGroupToOppositeOn(Hy3Node&); void changeGroupEphemeralityOn(Hy3Node&, bool ephemeral); - void shiftWindow(int workspace, ShiftDirection, bool once); + void shiftWindow(int workspace, ShiftDirection, bool once, bool visible); void shiftFocus(int workspace, ShiftDirection, bool visible); void changeFocus(int workspace, FocusShift); void focusTab(int workspace, TabFocus target, TabFocusMousePriority, bool wrap_scroll, int index); diff --git a/src/dispatchers.cpp b/src/dispatchers.cpp index f56b2fb..a1a6da1 100644 --- a/src/dispatchers.cpp +++ b/src/dispatchers.cpp @@ -90,8 +90,21 @@ void dispatch_movewindow(std::string value) { auto args = CVarList(value); if (auto shift = parseShiftArg(args[0])) { - auto once = args[1] == "once"; - g_Hy3Layout->shiftWindow(workspace, shift.value(), once); + int i = 1; + bool once = false; + bool visible = false; + + if (args[i] == "once") { + once = true; + i++; + } + + if (args[i] == "visible") { + visible = true; + i++; + } + + g_Hy3Layout->shiftWindow(workspace, shift.value(), once, visible); } }