From ec877f2ec48cbdb70d44081a92596abd9a19a356 Mon Sep 17 00:00:00 2001 From: Maik Fischer Date: Wed, 23 Nov 2011 17:21:11 +0100 Subject: [PATCH] i3test.pm: add before_map hook to open_window --- testcases/lib/i3test.pm | 13 +++++++++++++ 1 file changed, 13 insertions(+) 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; -- 2.39.5