From: Michael Stapelberg Date: Sun, 5 Jan 2014 19:10:24 +0000 (+0100) Subject: i3-save-tree: only create "swallows" key for leaf nodes (Thanks xeen) X-Git-Tag: 4.8~154 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=bb482e2869dd13e4199815af9ea833ca7dbae7d5;p=i3%2Fi3 i3-save-tree: only create "swallows" key for leaf nodes (Thanks xeen) fixes #1149 --- diff --git a/i3-save-tree b/i3-save-tree index 6ac3e1b1..53d67e99 100755 --- a/i3-save-tree +++ b/i3-save-tree @@ -1,7 +1,7 @@ #!/usr/bin/env perl # vim:ts=4:sw=4:expandtab # -# © 2013 Michael Stapelberg +# © 2013-2014 Michael Stapelberg # # Requires perl ≥ v5.10, AnyEvent::I3 and JSON::XS @@ -149,12 +149,15 @@ sub dump_containers { say "$ws// $desc with " . @{$tree->{nodes}} . " children"; } - # Turn “window_properties” into “swallows” expressions. - my $swallows = {}; - for my $property (keys %{$tree->{window_properties}}) { - $swallows->{$property} = '^' . quotemeta($tree->{window_properties}->{$property}) . '$'; + # Turn “window_properties” into “swallows” expressions, but only for leaf + # nodes. It only makes sense for leaf nodes to swallow anything. + if (leaf_node($tree)) { + my $swallows = {}; + for my $property (keys %{$tree->{window_properties}}) { + $swallows->{$property} = '^' . quotemeta($tree->{window_properties}->{$property}) . '$'; + } + $tree->{swallows} = [ $swallows ]; } - $tree->{swallows} = [ $swallows ]; delete $tree->{window_properties}; my @keys = sort keys %$tree;