2 # vim:ts=4:sw=4:expandtab
4 # Tests all kinds of matching methods
7 use X11::XCB qw(PROP_MODE_REPLACE);
9 my $tmp = fresh_workspace;
11 ok(@{get_ws_content($tmp)} == 0, 'no containers yet');
14 my $window = open_window;
15 my $content = get_ws_content($tmp);
16 ok(@{$content} == 1, 'window mapped');
17 my $win = $content->[0];
19 ######################################################################
20 # first test that matches which should not match this window really do
22 ######################################################################
23 # TODO: specify more match types
24 # we can match on any (non-empty) class here since that window does not have
26 cmd q|[class=".*"] kill|;
27 cmd q|[con_id="99999"] kill|;
29 is_num_children($tmp, 1, 'window still there');
32 cmd 'nop now killing the window';
34 cmd qq|[con_id="$id"] kill|;
36 wait_for_unmap $window;
38 cmd 'nop checking if its gone';
39 is_num_children($tmp, 0, 'window killed');
41 # TODO: same test, but with pcre expressions
43 ######################################################################
44 # check that multiple criteria work are checked with a logical AND,
45 # not a logical OR (that is, matching is not cancelled after the first
47 ######################################################################
49 $tmp = fresh_workspace;
51 # TODO: move to X11::XCB
53 my ($id, $class, $instance) = @_;
55 # Add a _NET_WM_STRUT_PARTIAL hint
56 my $atomname = $x->atom(name => 'WM_CLASS');
57 my $atomtype = $x->atom(name => 'STRING');
65 length($class) + length($instance) + 2,
66 "$instance\x00$class\x00"
72 my $wm_class = delete($args{wm_class}) || 'special';
76 before_map => sub { set_wm_class($_->id, $wm_class, $wm_class) },
80 my $left = open_special(name => 'left');
81 ok($left->mapped, 'left window mapped');
83 my $right = open_special(name => 'right');
84 ok($right->mapped, 'right window mapped');
86 # two windows should be here
87 is_num_children($tmp, 2, 'two windows opened');
89 cmd '[class="special" title="left"] kill';
93 is_num_children($tmp, 1, 'one window still there');
95 ######################################################################
96 # check that regular expressions work
97 ######################################################################
99 $tmp = fresh_workspace;
101 $left = open_special(name => 'left', wm_class => 'special7');
102 ok($left->mapped, 'left window mapped');
103 is_num_children($tmp, 1, 'window opened');
105 cmd '[class="^special[0-9]$"] kill';
106 wait_for_unmap $left;
107 is_num_children($tmp, 0, 'window killed');
109 ######################################################################
110 # check that UTF-8 works when matching
111 ######################################################################
113 $tmp = fresh_workspace;
115 $left = open_special(name => 'รค 3', wm_class => 'special7');
116 ok($left->mapped, 'left window mapped');
117 is_num_children($tmp, 1, 'window opened');
119 cmd '[title="^\w [3]$"] kill';
120 wait_for_unmap $left;
121 is_num_children($tmp, 0, 'window killed');