2010-04-16 23:04:42 +02:00
|
|
|
#!perl
|
|
|
|
# vim:ts=4:sw=4:expandtab
|
|
|
|
#
|
|
|
|
# Tests all kinds of matching methods
|
|
|
|
#
|
2011-03-09 20:25:17 +01:00
|
|
|
use i3test;
|
2011-11-23 17:22:43 +01:00
|
|
|
use X11::XCB qw(PROP_MODE_REPLACE);
|
2010-04-16 23:04:42 +02:00
|
|
|
|
2011-03-09 20:25:17 +01:00
|
|
|
my $tmp = fresh_workspace;
|
2010-04-16 23:04:42 +02:00
|
|
|
|
|
|
|
ok(@{get_ws_content($tmp)} == 0, 'no containers yet');
|
|
|
|
|
|
|
|
# Open a new window
|
2011-11-22 00:47:32 +01:00
|
|
|
my $window = open_window;
|
2010-04-16 23:04:42 +02:00
|
|
|
my $content = get_ws_content($tmp);
|
|
|
|
ok(@{$content} == 1, 'window mapped');
|
|
|
|
my $win = $content->[0];
|
|
|
|
|
|
|
|
######################################################################
|
|
|
|
# first test that matches which should not match this window really do
|
|
|
|
# not match it
|
|
|
|
######################################################################
|
|
|
|
# TODO: specify more match types
|
2011-09-11 00:52:39 +02:00
|
|
|
# we can match on any (non-empty) class here since that window does not have
|
|
|
|
# WM_CLASS set
|
|
|
|
cmd q|[class=".*"] kill|;
|
2011-03-09 20:25:17 +01:00
|
|
|
cmd q|[con_id="99999"] kill|;
|
2010-04-16 23:04:42 +02:00
|
|
|
|
|
|
|
$content = get_ws_content($tmp);
|
|
|
|
ok(@{$content} == 1, 'window still there');
|
|
|
|
|
|
|
|
# now kill the window
|
2011-03-09 18:47:00 +01:00
|
|
|
cmd 'nop now killing the window';
|
2010-04-16 23:04:42 +02:00
|
|
|
my $id = $win->{id};
|
2011-03-09 20:25:17 +01:00
|
|
|
cmd qq|[con_id="$id"] kill|;
|
2010-04-16 23:04:42 +02:00
|
|
|
|
2011-11-21 23:44:20 +01:00
|
|
|
wait_for_unmap $window;
|
2011-03-09 18:47:00 +01:00
|
|
|
|
|
|
|
cmd 'nop checking if its gone';
|
2010-04-16 23:04:42 +02:00
|
|
|
$content = get_ws_content($tmp);
|
|
|
|
ok(@{$content} == 0, 'window killed');
|
|
|
|
|
|
|
|
# TODO: same test, but with pcre expressions
|
|
|
|
|
2011-07-08 00:21:29 +02:00
|
|
|
######################################################################
|
|
|
|
# check that multiple criteria work are checked with a logical AND,
|
|
|
|
# not a logical OR (that is, matching is not cancelled after the first
|
|
|
|
# criterion matches).
|
|
|
|
######################################################################
|
|
|
|
|
|
|
|
$tmp = fresh_workspace;
|
|
|
|
|
|
|
|
# TODO: move to X11::XCB
|
|
|
|
sub set_wm_class {
|
|
|
|
my ($id, $class, $instance) = @_;
|
|
|
|
|
|
|
|
# Add a _NET_WM_STRUT_PARTIAL hint
|
|
|
|
my $atomname = $x->atom(name => 'WM_CLASS');
|
|
|
|
my $atomtype = $x->atom(name => 'STRING');
|
|
|
|
|
|
|
|
$x->change_property(
|
|
|
|
PROP_MODE_REPLACE,
|
|
|
|
$id,
|
|
|
|
$atomname->id,
|
|
|
|
$atomtype->id,
|
|
|
|
8,
|
|
|
|
length($class) + length($instance) + 2,
|
|
|
|
"$instance\x00$class\x00"
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2011-11-23 17:22:43 +01:00
|
|
|
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');
|
2011-07-08 00:21:29 +02:00
|
|
|
|
|
|
|
# two windows should be here
|
|
|
|
$content = get_ws_content($tmp);
|
|
|
|
ok(@{$content} == 2, 'two windows opened');
|
|
|
|
|
|
|
|
cmd '[class="special" title="left"] kill';
|
|
|
|
|
2011-11-22 01:13:37 +01:00
|
|
|
sync_with_i3;
|
2011-07-09 01:01:52 +02:00
|
|
|
|
2011-07-08 00:21:29 +02:00
|
|
|
$content = get_ws_content($tmp);
|
|
|
|
is(@{$content}, 1, 'one window still there');
|
|
|
|
|
2011-09-11 00:52:39 +02:00
|
|
|
######################################################################
|
|
|
|
# check that regular expressions work
|
|
|
|
######################################################################
|
|
|
|
|
|
|
|
$tmp = fresh_workspace;
|
|
|
|
|
2011-11-23 17:22:43 +01:00
|
|
|
$left = open_special(name => 'left', wm_class => 'special7');
|
|
|
|
ok($left->mapped, 'left window mapped');
|
2011-09-11 00:52:39 +02:00
|
|
|
|
|
|
|
# two windows should be here
|
|
|
|
$content = get_ws_content($tmp);
|
2011-09-11 12:40:51 +02:00
|
|
|
ok(@{$content} == 1, 'window opened');
|
2011-09-11 00:52:39 +02:00
|
|
|
|
|
|
|
cmd '[class="^special[0-9]$"] kill';
|
|
|
|
|
2011-11-21 23:44:20 +01:00
|
|
|
wait_for_unmap $left;
|
2011-09-11 00:52:39 +02:00
|
|
|
|
|
|
|
$content = get_ws_content($tmp);
|
|
|
|
is(@{$content}, 0, 'window killed');
|
|
|
|
|
2011-09-11 12:40:51 +02:00
|
|
|
######################################################################
|
|
|
|
# check that UTF-8 works when matching
|
|
|
|
######################################################################
|
|
|
|
|
|
|
|
$tmp = fresh_workspace;
|
|
|
|
|
2011-11-23 17:22:43 +01:00
|
|
|
$left = open_special(name => 'ä 3', wm_class => 'special7');
|
|
|
|
ok($left->mapped, 'left window mapped');
|
2011-09-11 12:40:51 +02:00
|
|
|
|
|
|
|
# two windows should be here
|
|
|
|
$content = get_ws_content($tmp);
|
|
|
|
ok(@{$content} == 1, 'window opened');
|
|
|
|
|
|
|
|
cmd '[title="^\w [3]$"] kill';
|
|
|
|
|
2011-11-21 23:44:20 +01:00
|
|
|
wait_for_unmap $left;
|
2011-09-11 12:40:51 +02:00
|
|
|
|
|
|
|
$content = get_ws_content($tmp);
|
|
|
|
is(@{$content}, 0, 'window killed');
|
2011-09-11 00:52:39 +02:00
|
|
|
|
2011-03-09 20:25:17 +01:00
|
|
|
done_testing;
|