i3test.pm: add before_map hook to open_window
This commit is contained in:
parent
9b8d9f7303
commit
ec877f2ec4
|
@ -144,6 +144,12 @@ sub wait_for_unmap {
|
||||||
#
|
#
|
||||||
# set dont_map to a true value to avoid mapping
|
# 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:
|
# default values:
|
||||||
# class => WINDOW_CLASS_INPUT_OUTPUT
|
# class => WINDOW_CLASS_INPUT_OUTPUT
|
||||||
# rect => [ 0, 0, 30, 30 ]
|
# rect => [ 0, 0, 30, 30 ]
|
||||||
|
@ -155,6 +161,7 @@ sub open_window {
|
||||||
my %args = @_ == 1 ? %{$_[0]} : @_;
|
my %args = @_ == 1 ? %{$_[0]} : @_;
|
||||||
|
|
||||||
my $dont_map = delete $args{dont_map};
|
my $dont_map = delete $args{dont_map};
|
||||||
|
my $before_map = delete $args{before_map};
|
||||||
|
|
||||||
$args{class} //= WINDOW_CLASS_INPUT_OUTPUT;
|
$args{class} //= WINDOW_CLASS_INPUT_OUTPUT;
|
||||||
$args{rect} //= [ 0, 0, 30, 30 ];
|
$args{rect} //= [ 0, 0, 30, 30 ];
|
||||||
|
@ -164,6 +171,12 @@ sub open_window {
|
||||||
|
|
||||||
my $window = $x->root->create_child(%args);
|
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;
|
return $window if $dont_map;
|
||||||
|
|
||||||
$window->map;
|
$window->map;
|
||||||
|
|
Loading…
Reference in New Issue