Skip to content

Commit

Permalink
Add visible option to movewindow
Browse files Browse the repository at this point in the history
Allows movement between only visible nodes, skipping all hidden tab groups
  • Loading branch information
outfoxxed committed Aug 20, 2023
1 parent 6c20af2 commit 0cc5af9
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 7 deletions.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -222,8 +222,9 @@ plugin {
- `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
- `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
- `visible` - only move between visible nodes, not hidden tabs
- `hy3:killactive` - close all windows in the focused node
- `hy3:changefocus, <top | bottom | raise | lower | tab | tabnode>`
- `top` - focus all nodes in the workspace
Expand Down
16 changes: 13 additions & 3 deletions src/Hy3Layout.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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);
}
}

Expand Down Expand Up @@ -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();
Expand Down
2 changes: 1 addition & 1 deletion src/Hy3Layout.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
17 changes: 15 additions & 2 deletions src/dispatchers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}

Expand Down

0 comments on commit 0cc5af9

Please sign in to comment.