con_set_layout: always use the parent container, handle workspaces properly
Previously, in case 'layout stacked' (for example) had been called interactively, con_set_layout would be called with focused->parent, while with for_window, it’d be called on the actual matching container. This difference in behavior was the cause for the inability to use 'for_window [class="XTerm"] layout tabbed', which now works \o/, but more on that below. The change also allows us to handle the case of the user selecting a CT_WORKSPACE container properly, that is, by using the special case and creating a new split container on the workspace which gets all the contents, but a new layout. Now, before you are enthusiastic about the change and try to use for_window magic in your config file, keep in mind: The 'layout' command acts on the parent split container. That is, when using a line such as this one: for_window [class="XTerm"] layout tabbed …and opening an XTerm when on a workspace with one single other window, the whole workspace will be set tabbed (just as previously when you opened an XTerm and sent 'layout tabbed' manually). Therefore, to open XTerm in its own tabbed split container, you need to split before: for_window [class="XTerm"] split v, layout tabbed The comma here is important! It says that the second command should not be treated as an entirely unrelated command, but it should also relate the matching window (while it does work with a ';', that is prone to race-conditions and should be avoided). fixes #358
This commit is contained in:
@ -4,6 +4,7 @@
|
||||
# Tests splitting
|
||||
#
|
||||
use i3test;
|
||||
use List::Util qw(first);
|
||||
|
||||
my $tmp;
|
||||
my $ws;
|
||||
@ -119,4 +120,29 @@ cmd 'open';
|
||||
is(scalar @content, 1, 'Still one container on this ws');
|
||||
is(scalar @{$content[0]->{nodes}}, 1, 'Stacked con still has one child node');
|
||||
|
||||
################################################################################
|
||||
# When focusing the workspace, changing the layout should have an effect on the
|
||||
# workspace, not on the parent (CT_CONTENT) container.
|
||||
################################################################################
|
||||
|
||||
sub get_output_content {
|
||||
my $tree = i3(get_socket_path())->get_tree->recv;
|
||||
|
||||
my @outputs = grep { $_->{name} !~ /^__/ } @{$tree->{nodes}};
|
||||
is(scalar @outputs, 1, 'exactly one output (testcase not multi-monitor capable)');
|
||||
my $output = $outputs[0];
|
||||
# get the first (and only) CT_CON
|
||||
return first { $_->{type} == 2 } @{$output->{nodes}};
|
||||
}
|
||||
|
||||
$tmp = fresh_workspace;
|
||||
|
||||
cmd 'open';
|
||||
cmd 'split v';
|
||||
cmd 'open';
|
||||
cmd 'focus parent';
|
||||
is(get_output_content()->{layout}, 'splith', 'content container layout ok');
|
||||
cmd 'layout stacked';
|
||||
is(get_output_content()->{layout}, 'splith', 'content container layout still ok');
|
||||
|
||||
done_testing;
|
||||
|
Reference in New Issue
Block a user