Adds ability to toggle tabbing

This commit is contained in:
Rehan 2023-08-19 10:44:52 -04:00
parent a15a058250
commit f8453add50
4 changed files with 21 additions and 1 deletions

View file

@ -215,8 +215,9 @@ plugin {
- `hy3:makegroup, <h | v | opposite | tab>, [ephemeral | force_ephemeral]` - make a vertical / horizontal split or tab group
- `ephemeral` - the group will be removed once it contains only one node. does not affect existing groups.
- `force_ephemeral` - same as ephemeral, but converts existing single windows groups.
- `hy3:changegroup, <h | v | tab | untab | opposite>` - change the group the node belongs to, to a different layout
- `hy3:changegroup, <h | v | tab | untab | toggletab | opposite>` - change the group the node belongs to, to a different layout
- `untab` will untab the group if it was previously tabbed
- `toggletab` will untab if group is tabbed, and tab if group is untabbed
- `opposite` will toggle between horizontal and vertical layouts if the group is not tabbed.
- `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

View file

@ -762,6 +762,13 @@ void Hy3Layout::untabGroupOnWorkspace(int workspace) {
this->untabGroupOn(*node);
}
void Hy3Layout::toggleTabGroupOnWorkspace(int workspace) {
auto* node = this->getWorkspaceFocusedNode(workspace);
if (node == nullptr) return;
this->toggleTabGroupOn(*node);
}
void Hy3Layout::changeGroupToOppositeOnWorkspace(int workspace) {
auto* node = this->getWorkspaceFocusedNode(workspace);
if (node == nullptr) return;
@ -838,6 +845,14 @@ void Hy3Layout::untabGroupOn(Hy3Node& node) {
changeGroupOn(node, group.previous_nontab_layout);
}
void Hy3Layout::toggleTabGroupOn(Hy3Node& node) {
if (node.parent == nullptr) return;
auto& group = node.parent->data.as_group;
if (group.layout != Hy3GroupLayout::Tabbed) changeGroupOn(node, Hy3GroupLayout::Tabbed);
else changeGroupOn(node, group.previous_nontab_layout);
}
void Hy3Layout::changeGroupToOppositeOn(Hy3Node& node) {
if (node.parent == nullptr) return;

View file

@ -92,12 +92,14 @@ public:
void makeOppositeGroupOnWorkspace(int workspace, GroupEphemeralityOption);
void changeGroupOnWorkspace(int workspace, Hy3GroupLayout);
void untabGroupOnWorkspace(int workspace);
void toggleTabGroupOnWorkspace(int workspace);
void changeGroupToOppositeOnWorkspace(int workspace);
void changeGroupEphemeralityOnWorkspace(int workspace, bool ephemeral);
void makeGroupOn(Hy3Node*, Hy3GroupLayout, GroupEphemeralityOption);
void makeOppositeGroupOn(Hy3Node*, GroupEphemeralityOption);
void changeGroupOn(Hy3Node&, Hy3GroupLayout);
void untabGroupOn(Hy3Node&);
void toggleTabGroupOn(Hy3Node&);
void changeGroupToOppositeOn(Hy3Node&);
void changeGroupEphemeralityOn(Hy3Node&, bool ephemeral);
void shiftWindow(int workspace, ShiftDirection, bool once);

View file

@ -57,6 +57,8 @@ void dispatch_changegroup(std::string value) {
g_Hy3Layout->changeGroupOnWorkspace(workspace, Hy3GroupLayout::Tabbed);
} else if (args[0] == "untab") {
g_Hy3Layout->untabGroupOnWorkspace(workspace);
} else if (args[0] == "toggletab") {
g_Hy3Layout->toggleTabGroupOnWorkspace(workspace);
} else if (args[0] == "opposite") {
g_Hy3Layout->changeGroupToOppositeOnWorkspace(workspace);
}