Split workspace instead of changing orientation
Move all children of the workspace into a new container if there is more than one otherwise simply change the orientation. fixes #922
This commit is contained in:
parent
1e3075e69b
commit
fa4301e06d
20
src/tree.c
20
src/tree.c
|
@ -373,17 +373,23 @@ void tree_close_con(kill_window_t kill_window) {
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
void tree_split(Con *con, orientation_t orientation) {
|
void tree_split(Con *con, orientation_t orientation) {
|
||||||
/* for a workspace, we just need to change orientation */
|
if (con->type == CT_FLOATING_CON) {
|
||||||
if (con->type == CT_WORKSPACE) {
|
|
||||||
DLOG("Workspace, simply changing orientation to %d\n", orientation);
|
|
||||||
con->layout = (orientation == HORIZ) ? L_SPLITH : L_SPLITV;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
else if (con->type == CT_FLOATING_CON) {
|
|
||||||
DLOG("Floating containers can't be split.\n");
|
DLOG("Floating containers can't be split.\n");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (con->type == CT_WORKSPACE) {
|
||||||
|
if (con_num_children(con) < 2) {
|
||||||
|
DLOG("Just changing orientation of workspace\n");
|
||||||
|
con->layout = (orientation == HORIZ) ? L_SPLITH : L_SPLITV;
|
||||||
|
return;
|
||||||
|
} else {
|
||||||
|
/* if there is more than one container on the workspace
|
||||||
|
* move them into a new container and handle this instead */
|
||||||
|
con = workspace_encapsulate(con);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Con *parent = con->parent;
|
Con *parent = con->parent;
|
||||||
|
|
||||||
/* Force re-rendering to make the indicator border visible. */
|
/* Force re-rendering to make the indicator border visible. */
|
||||||
|
|
|
@ -158,4 +158,24 @@ is(get_output_content()->{layout}, 'splith', 'content container layout ok');
|
||||||
cmd 'layout stacked';
|
cmd 'layout stacked';
|
||||||
is(get_output_content()->{layout}, 'splith', 'content container layout still ok');
|
is(get_output_content()->{layout}, 'splith', 'content container layout still ok');
|
||||||
|
|
||||||
|
######################################################################
|
||||||
|
# Splitting a workspace that has more than one child
|
||||||
|
######################################################################
|
||||||
|
|
||||||
|
$tmp = fresh_workspace;
|
||||||
|
|
||||||
|
cmd 'open';
|
||||||
|
cmd 'open';
|
||||||
|
cmd 'focus parent';
|
||||||
|
cmd 'split v';
|
||||||
|
cmd 'open';
|
||||||
|
|
||||||
|
my $content = get_ws_content($tmp);
|
||||||
|
my $fst = $content->[0];
|
||||||
|
my $snd = $content->[1];
|
||||||
|
|
||||||
|
is(@{$content}, 2, 'two containers on workspace');
|
||||||
|
is(@{$fst->{nodes}}, 2, 'first child has two children');
|
||||||
|
is(@{$snd->{nodes}}, 0, 'second child has no children');
|
||||||
|
|
||||||
done_testing;
|
done_testing;
|
||||||
|
|
Loading…
Reference in New Issue