Merge pull request #2139 from jolange/feature_split-toggle
added "toggle" option to "split" command
This commit is contained in:
commit
e70b2f9dcd
|
@ -1750,20 +1750,24 @@ get placed below the current one (splitv).
|
||||||
|
|
||||||
If you apply this command to a split container with the same orientation,
|
If you apply this command to a split container with the same orientation,
|
||||||
nothing will happen. If you use a different orientation, the split container’s
|
nothing will happen. If you use a different orientation, the split container’s
|
||||||
orientation will be changed (if it does not have more than one window). Use
|
orientation will be changed (if it does not have more than one window).
|
||||||
+layout toggle split+ to change the layout of any split container from splitv
|
The +toggle+ option will toggle the orientation of the split container if it
|
||||||
to splith or vice-versa.
|
contains a single window. Otherwise it makes the current window a split
|
||||||
|
container with opposite orientation compared to the parent container.
|
||||||
|
Use +layout toggle split+ to change the layout of any split container from
|
||||||
|
splitv to splith or vice-versa.
|
||||||
|
|
||||||
*Syntax*:
|
*Syntax*:
|
||||||
-------------------------
|
--------------------------------
|
||||||
split vertical|horizontal
|
split vertical|horizontal|toggle
|
||||||
-------------------------
|
--------------------------------
|
||||||
|
|
||||||
*Example*:
|
*Example*:
|
||||||
------------------------------
|
-------------------------------
|
||||||
bindsym $mod+v split vertical
|
bindsym $mod+v split vertical
|
||||||
bindsym $mod+h split horizontal
|
bindsym $mod+h split horizontal
|
||||||
------------------------------
|
bindsym $mod+t split toggle
|
||||||
|
-------------------------------
|
||||||
|
|
||||||
=== Manipulating layout
|
=== Manipulating layout
|
||||||
|
|
||||||
|
|
|
@ -157,7 +157,7 @@ void cmd_floating(I3_CMD, const char *floating_mode);
|
||||||
void cmd_move_workspace_to_output(I3_CMD, const char *name);
|
void cmd_move_workspace_to_output(I3_CMD, const char *name);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Implementation of 'split v|h|vertical|horizontal'.
|
* Implementation of 'split v|h|t|vertical|horizontal|toggle'.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
void cmd_split(I3_CMD, const char *direction);
|
void cmd_split(I3_CMD, const char *direction);
|
||||||
|
|
|
@ -191,9 +191,9 @@ state STICKY:
|
||||||
action = 'enable', 'disable', 'toggle'
|
action = 'enable', 'disable', 'toggle'
|
||||||
-> call cmd_sticky($action)
|
-> call cmd_sticky($action)
|
||||||
|
|
||||||
# split v|h|vertical|horizontal
|
# split v|h|t|vertical|horizontal|toggle
|
||||||
state SPLIT:
|
state SPLIT:
|
||||||
direction = 'horizontal', 'vertical', 'v', 'h'
|
direction = 'horizontal', 'vertical', 'toggle', 'v', 'h', 't'
|
||||||
-> call cmd_split($direction)
|
-> call cmd_split($direction)
|
||||||
|
|
||||||
# floating enable|disable|toggle
|
# floating enable|disable|toggle
|
||||||
|
|
|
@ -1228,7 +1228,7 @@ void cmd_move_workspace_to_output(I3_CMD, const char *name) {
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Implementation of 'split v|h|vertical|horizontal'.
|
* Implementation of 'split v|h|t|vertical|horizontal|toggle'.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
void cmd_split(I3_CMD, const char *direction) {
|
void cmd_split(I3_CMD, const char *direction) {
|
||||||
|
@ -1243,8 +1243,23 @@ void cmd_split(I3_CMD, const char *direction) {
|
||||||
}
|
}
|
||||||
|
|
||||||
DLOG("matching: %p / %s\n", current->con, current->con->name);
|
DLOG("matching: %p / %s\n", current->con, current->con->name);
|
||||||
|
if (direction[0] == 't') {
|
||||||
|
layout_t current_layout;
|
||||||
|
if (current->con->type == CT_WORKSPACE) {
|
||||||
|
current_layout = current->con->layout;
|
||||||
|
} else {
|
||||||
|
current_layout = current->con->parent->layout;
|
||||||
|
}
|
||||||
|
/* toggling split orientation */
|
||||||
|
if (current_layout == L_SPLITH) {
|
||||||
|
tree_split(current->con, VERT);
|
||||||
|
} else {
|
||||||
|
tree_split(current->con, HORIZ);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
tree_split(current->con, (direction[0] == 'v' ? VERT : HORIZ));
|
tree_split(current->con, (direction[0] == 'v' ? VERT : HORIZ));
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
cmd_output->needs_tree_render = true;
|
cmd_output->needs_tree_render = true;
|
||||||
// XXX: default reply for now, make this a better reply
|
// XXX: default reply for now, make this a better reply
|
||||||
|
|
|
@ -178,4 +178,34 @@ is(@{$content}, 2, 'two containers on workspace');
|
||||||
is(@{$fst->{nodes}}, 2, 'first child has two children');
|
is(@{$fst->{nodes}}, 2, 'first child has two children');
|
||||||
is(@{$snd->{nodes}}, 0, 'second child has no children');
|
is(@{$snd->{nodes}}, 0, 'second child has no children');
|
||||||
|
|
||||||
|
######################################################################
|
||||||
|
# Test split toggle
|
||||||
|
######################################################################
|
||||||
|
|
||||||
|
$tmp = fresh_workspace;
|
||||||
|
cmd 'split h';
|
||||||
|
cmd 'split toggle';
|
||||||
|
$ws = get_ws($tmp);
|
||||||
|
is($ws->{layout}, 'splitv', 'toggled workspace split');
|
||||||
|
|
||||||
|
$tmp = fresh_workspace;
|
||||||
|
cmd 'split h';
|
||||||
|
cmd 'split toggle';
|
||||||
|
cmd 'split toggle';
|
||||||
|
$ws = get_ws($tmp);
|
||||||
|
is($ws->{layout}, 'splith', 'toggled workspace back and forth');
|
||||||
|
|
||||||
|
cmd 'open';
|
||||||
|
cmd 'open';
|
||||||
|
cmd 'split toggle';
|
||||||
|
|
||||||
|
$content = get_ws_content($tmp);
|
||||||
|
my $second = $content->[1];
|
||||||
|
is($second->{layout}, 'splitv', 'toggled container orientation to vertical');
|
||||||
|
|
||||||
|
cmd 'split toggle';
|
||||||
|
$content = get_ws_content($tmp);
|
||||||
|
$second = $content->[1];
|
||||||
|
is($second->{layout}, 'splith', 'toggled container orientation back to horizontal');
|
||||||
|
|
||||||
done_testing;
|
done_testing;
|
||||||
|
|
Loading…
Reference in New Issue