Add visible option to movewindow

Allows movement between only visible nodes, skipping all hidden tab groups
This commit is contained in:
outfoxxed 2023-08-20 03:13:08 -07:00
parent 6c20af2cfd
commit 0cc5af9e60
No known key found for this signature in database
GPG key ID: 4C88A185FB89301E
4 changed files with 31 additions and 7 deletions

View file

@ -222,8 +222,9 @@ plugin {
- `hy3:setephemeral, <true | false>` - change the ephemerality of the group the node belongs to - `hy3:setephemeral, <true | false>` - change the ephemerality of the group the node belongs to
- `hy3:movefocus, <l | u | d | r | left | down | up | right>, [visible]` - move the focus left, up, down, or right - `hy3:movefocus, <l | u | d | r | left | down | up | right>, [visible]` - move the focus left, up, down, or right
- `visible` - only move between visible nodes, not hidden tabs - `visible` - only move between visible nodes, not hidden tabs
- `hy3:movewindow, <l | u | d | r | left | down | up | right>, [once]` - move a window left, up, down, or right - `hy3:movewindow, <l | u | d | r | left | down | up | right>, [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 - `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:killactive` - close all windows in the focused node
- `hy3:changefocus, <top | bottom | raise | lower | tab | tabnode>` - `hy3:changefocus, <top | bottom | raise | lower | tab | tabnode>`
- `top` - focus all nodes in the workspace - `top` - focus all nodes in the workspace

View file

@ -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); auto* node = this->getWorkspaceFocusedNode(workspace);
Debug::log(LOG, "ShiftWindow %p %d", node, direction); Debug::log(LOG, "ShiftWindow %p %d", node, direction);
if (node == nullptr) return; if (node == nullptr) return;
@ -890,7 +890,7 @@ void Hy3Layout::shiftWindow(int workspace, ShiftDirection direction, bool once)
node2->recalcSizePosRecursive(); node2->recalcSizePosRecursive();
} }
} else { } 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.children.end(),
group_data.focused_child 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 // if the group has the same orientation as movement pick the
// last/first child based on movement direction // last/first child based on movement direction
if (shiftIsForward(direction)) iter = group_data.children.begin(); if (shiftIsForward(direction)) iter = group_data.children.begin();

View file

@ -102,7 +102,7 @@ public:
void toggleTabGroupOn(Hy3Node&); void toggleTabGroupOn(Hy3Node&);
void changeGroupToOppositeOn(Hy3Node&); void changeGroupToOppositeOn(Hy3Node&);
void changeGroupEphemeralityOn(Hy3Node&, bool ephemeral); 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 shiftFocus(int workspace, ShiftDirection, bool visible);
void changeFocus(int workspace, FocusShift); void changeFocus(int workspace, FocusShift);
void focusTab(int workspace, TabFocus target, TabFocusMousePriority, bool wrap_scroll, int index); void focusTab(int workspace, TabFocus target, TabFocusMousePriority, bool wrap_scroll, int index);

View file

@ -90,8 +90,21 @@ void dispatch_movewindow(std::string value) {
auto args = CVarList(value); auto args = CVarList(value);
if (auto shift = parseShiftArg(args[0])) { if (auto shift = parseShiftArg(args[0])) {
auto once = args[1] == "once"; int i = 1;
g_Hy3Layout->shiftWindow(workspace, shift.value(), once); 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);
} }
} }