# Tests all kinds of matching methods
#
use i3test;
-use X11::XCB qw(PROP_MODE_REPLACE WINDOW_CLASS_INPUT_OUTPUT);
+use X11::XCB qw(PROP_MODE_REPLACE);
my $tmp = fresh_workspace;
ok(@{get_ws_content($tmp)} == 0, 'no containers yet');
# Open a new window
-my $window = open_window($x);
+my $window = open_window;
my $content = get_ws_content($tmp);
ok(@{$content} == 1, 'window mapped');
my $win = $content->[0];
my $id = $win->{id};
cmd qq|[con_id="$id"] kill|;
-wait_for_unmap $x;
+wait_for_unmap $window;
cmd 'nop checking if its gone';
$content = get_ws_content($tmp);
);
}
-my $left = $x->root->create_child(
- class => WINDOW_CLASS_INPUT_OUTPUT,
- rect => [ 0, 0, 30, 30 ],
- background_color => '#0000ff',
- event_mask => [ 'structure_notify' ],
-);
-
-$left->_create;
-set_wm_class($left->id, 'special', 'special');
-$left->name('left');
-$left->map;
-ok(wait_for_map($x), 'left window mapped');
-
-my $right = $x->root->create_child(
- class => WINDOW_CLASS_INPUT_OUTPUT,
- rect => [ 0, 0, 30, 30 ],
- background_color => '#0000ff',
- event_mask => [ 'structure_notify' ],
-);
-
-$right->_create;
-set_wm_class($right->id, 'special', 'special');
-$right->name('right');
-$right->map;
-ok(wait_for_map($x), 'right window mapped');
+sub open_special {
+ my %args = @_;
+ my $wm_class = delete($args{wm_class}) || 'special';
+
+ return open_window(
+ %args,
+ before_map => sub { set_wm_class($_->id, $wm_class, $wm_class) },
+ );
+}
+
+my $left = open_special(name => 'left');
+ok($left->mapped, 'left window mapped');
+
+my $right = open_special(name => 'right');
+ok($right->mapped, 'right window mapped');
# two windows should be here
$content = get_ws_content($tmp);
cmd '[class="special" title="left"] kill';
-sync_with_i3($x);
+sync_with_i3;
$content = get_ws_content($tmp);
is(@{$content}, 1, 'one window still there');
$tmp = fresh_workspace;
-$left = $x->root->create_child(
- class => WINDOW_CLASS_INPUT_OUTPUT,
- rect => [ 0, 0, 30, 30 ],
- background_color => '#0000ff',
- event_mask => [ 'structure_notify' ],
-);
-
-$left->_create;
-set_wm_class($left->id, 'special7', 'special7');
-$left->name('left');
-$left->map;
-ok(wait_for_map($x), 'left window mapped');
+$left = open_special(name => 'left', wm_class => 'special7');
+ok($left->mapped, 'left window mapped');
# two windows should be here
$content = get_ws_content($tmp);
cmd '[class="^special[0-9]$"] kill';
-wait_for_unmap $x;
+wait_for_unmap $left;
$content = get_ws_content($tmp);
is(@{$content}, 0, 'window killed');
$tmp = fresh_workspace;
-$left = $x->root->create_child(
- class => WINDOW_CLASS_INPUT_OUTPUT,
- rect => [ 0, 0, 30, 30 ],
- background_color => '#0000ff',
- event_mask => [ 'structure_notify' ],
-);
-
-$left->_create;
-set_wm_class($left->id, 'special7', 'special7');
-$left->name('ä 3');
-$left->map;
-ok(wait_for_map($x), 'left window mapped');
+$left = open_special(name => 'ä 3', wm_class => 'special7');
+ok($left->mapped, 'left window mapped');
# two windows should be here
$content = get_ws_content($tmp);
cmd '[title="^\w [3]$"] kill';
-wait_for_unmap $x;
+wait_for_unmap $left;
$content = get_ws_content($tmp);
is(@{$content}, 0, 'window killed');