2 # vim:ts=4:sw=4:expandtab
6 use List::Util qw(first);
9 use_ok('X11::XCB::Connection') or BAIL_OUT('Cannot load X11::XCB::Connection');
12 my $x = X11::XCB::Connection->new;
14 my $tmp = fresh_workspace;
16 #####################################################################
17 # Create two windows and put them in stacking mode
18 #####################################################################
22 my $top = open_window($x);
23 my $bottom = open_window($x);
25 my @urgent = grep { $_->{urgent} } @{get_ws_content($tmp)};
26 is(@urgent, 0, 'no window got the urgent flag');
28 # cmd 'layout stacking';
30 #####################################################################
31 # Add the urgency hint, switch to a different workspace and back again
32 #####################################################################
33 $top->add_hint('urgency');
36 @content = @{get_ws_content($tmp)};
37 @urgent = grep { $_->{urgent} } @content;
38 $top_info = first { $_->{window} == $top->id } @content;
39 $bottom_info = first { $_->{window} == $bottom->id } @content;
41 ok($top_info->{urgent}, 'top window is marked urgent');
42 ok(!$bottom_info->{urgent}, 'bottom window is not marked urgent');
43 is(@urgent, 1, 'exactly one window got the urgent flag');
45 cmd '[id="' . $top->id . '"] focus';
47 @urgent = grep { $_->{urgent} } @{get_ws_content($tmp)};
48 is(@urgent, 0, 'no window got the urgent flag after focusing');
50 $top->add_hint('urgency');
53 @urgent = grep { $_->{urgent} } @{get_ws_content($tmp)};
54 is(@urgent, 0, 'no window got the urgent flag after re-setting urgency hint');
56 #####################################################################
57 # Check if the workspace urgency hint gets set/cleared correctly
58 #####################################################################
59 my $ws = get_ws($tmp);
60 ok(!$ws->{urgent}, 'urgent flag not set on workspace');
62 my $otmp = fresh_workspace;
64 $top->add_hint('urgency');
68 ok($ws->{urgent}, 'urgent flag set on workspace');
73 ok(!$ws->{urgent}, 'urgent flag not set on workspace after switching');