GET_TREE: serialize container type into a string

So far, this was blessed for internal use only (by virtue of not being
in the documentation), but we want to expose it for the stored layouts.
This commit is contained in:
Michael Stapelberg
2013-12-14 14:50:44 +01:00
parent 58297f4ab5
commit 6800524f2e
11 changed files with 69 additions and 24 deletions

View File

@ -34,7 +34,7 @@ my @outputs = @{$tree->{nodes}};
my $output;
for my $o (@outputs) {
# get the first CT_CON of each output
my $content = first { $_->{type} == 2 } @{$o->{nodes}};
my $content = first { $_->{type} eq 'con' } @{$o->{nodes}};
if (defined(first { $_->{name} eq $tmp } @{$content->{nodes}})) {
$output = $o;
last;

View File

@ -51,7 +51,7 @@ my $expected = {
window => undef,
name => 'root',
orientation => $ignore,
type => 0,
type => 'root',
id => $ignore,
rect => $ignore,
window_rect => $ignore,
@ -90,16 +90,16 @@ my @nodes = @{$tree->{nodes}};
ok(@nodes > 0, 'root node has at least one leaf');
ok((all { $_->{type} == 1 } @nodes), 'all nodes are of type CT_OUTPUT');
ok((all { $_->{type} eq 'output' } @nodes), 'all nodes are of type CT_OUTPUT');
ok((none { defined($_->{window}) } @nodes), 'no CT_OUTPUT contains a window');
ok((all { @{$_->{nodes}} > 0 } @nodes), 'all nodes have at least one leaf (workspace)');
my @workspaces;
for my $ws (@nodes) {
my $content = first { $_->{type} == 2 } @{$ws->{nodes}};
my $content = first { $_->{type} eq 'con' } @{$ws->{nodes}};
@workspaces = (@workspaces, @{$content->{nodes}});
}
ok((all { $_->{type} == 4 } @workspaces), 'all workspaces are of type CT_WORKSPACE');
ok((all { $_->{type} eq 'workspace' } @workspaces), 'all workspaces are of type CT_WORKSPACE');
#ok((all { @{$_->{nodes}} == 0 } @workspaces), 'all workspaces are empty yet');
ok((none { defined($_->{window}) } @workspaces), 'no CT_OUTPUT contains a window');

View File

@ -196,8 +196,7 @@ sub workspace_numbers_sorted {
my @outputs = @{$tree->{nodes}};
my @workspaces;
for my $output (@outputs) {
# get the first CT_CON of each output
my $content = first { $_->{type} == 2 } @{$output->{nodes}};
my $content = first { $_->{type} eq 'con' } @{$output->{nodes}};
@workspaces = (@workspaces, @{$content->{nodes}});
}

View File

@ -145,7 +145,7 @@ sub get_output_content {
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}};
return first { $_->{type} eq 'con' } @{$output->{nodes}};
}
$tmp = fresh_workspace;

View File

@ -35,7 +35,7 @@ is($tree->{name}, 'root', 'root node is the first thing we get');
my @__i3 = grep { $_->{name} eq '__i3' } @{$tree->{nodes}};
is(scalar @__i3, 1, 'output __i3 found');
my $content = first { $_->{type} == 2 } @{$__i3[0]->{nodes}};
my $content = first { $_->{type} eq 'con' } @{$__i3[0]->{nodes}};
my @workspaces = @{$content->{nodes}};
my @workspace_names = map { $_->{name} } @workspaces;
ok('__i3_scratch' ~~ @workspace_names, '__i3_scratch workspace found');

View File

@ -77,10 +77,10 @@ sub workspaces_per_screen {
my @outputs = @{$tree->{nodes}};
my $fake0 = first { $_->{name} eq 'fake-0' } @outputs;
my $fake0_content = first { $_->{type} == 2 } @{$fake0->{nodes}};
my $fake0_content = first { $_->{type} eq 'con' } @{$fake0->{nodes}};
my $fake1 = first { $_->{name} eq 'fake-1' } @outputs;
my $fake1_content = first { $_->{type} == 2 } @{$fake1->{nodes}};
my $fake1_content = first { $_->{type} eq 'con' } @{$fake1->{nodes}};
my @fake0_workspaces = map { $_->{name} } @{$fake0_content->{nodes}};
my @fake1_workspaces = map { $_->{name} } @{$fake1_content->{nodes}};

View File

@ -37,10 +37,10 @@ sub workspaces_per_screen {
my @outputs = @{$tree->{nodes}};
my $fake0 = first { $_->{name} eq 'fake-0' } @outputs;
my $fake0_content = first { $_->{type} == 2 } @{$fake0->{nodes}};
my $fake0_content = first { $_->{type} eq 'con' } @{$fake0->{nodes}};
my $fake1 = first { $_->{name} eq 'fake-1' } @outputs;
my $fake1_content = first { $_->{type} == 2 } @{$fake1->{nodes}};
my $fake1_content = first { $_->{type} eq 'con' } @{$fake1->{nodes}};
my @fake0_workspaces = map { $_->{name} } @{$fake0_content->{nodes}};
my @fake1_workspaces = map { $_->{name} } @{$fake1_content->{nodes}};