From: Maik Fischer Date: Wed, 23 Nov 2011 16:21:11 +0000 (+0100) Subject: i3test.pm: add before_map hook to open_window X-Git-Tag: 4.2~225^2~1 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=ec877f2ec48cbdb70d44081a92596abd9a19a356;p=i3%2Fi3 i3test.pm: add before_map hook to open_window --- diff --git a/testcases/lib/i3test.pm b/testcases/lib/i3test.pm index f8ad4e2f..4de97c1f 100644 --- a/testcases/lib/i3test.pm +++ b/testcases/lib/i3test.pm @@ -144,6 +144,12 @@ sub wait_for_unmap { # # set dont_map to a true value to avoid mapping # +# if you want to change aspects of your window before it would be mapped, +# set before_map to a coderef. $window gets passed as $_ and as first argument. +# +# if you set both dont_map and before_map, the coderef will be called nevertheless +# +# # default values: # class => WINDOW_CLASS_INPUT_OUTPUT # rect => [ 0, 0, 30, 30 ] @@ -155,6 +161,7 @@ sub open_window { my %args = @_ == 1 ? %{$_[0]} : @_; my $dont_map = delete $args{dont_map}; + my $before_map = delete $args{before_map}; $args{class} //= WINDOW_CLASS_INPUT_OUTPUT; $args{rect} //= [ 0, 0, 30, 30 ]; @@ -164,6 +171,12 @@ sub open_window { my $window = $x->root->create_child(%args); + if ($before_map) { + # TODO: investigate why _create is not needed + $window->_create; + $before_map->($window) for $window; + } + return $window if $dont_map; $window->map;