2 # vim:ts=4:sw=4:expandtab
4 use i3test tests => 10;
6 use Time::HiRes qw(sleep);
7 use List::Util qw(first);
10 use_ok('X11::XCB::Connection') or BAIL_OUT('Cannot load X11::XCB::Connection');
13 my $x = X11::XCB::Connection->new;
15 my $i3 = i3("/tmp/nestedcons");
16 my $tmp = get_unused_workspace();
17 $i3->command("workspace $tmp")->recv;
19 #####################################################################
20 # Create two windows and put them in stacking mode
21 #####################################################################
23 $i3->command('split v')->recv;
25 my $top = i3test::open_standard_window($x);
26 my $bottom = i3test::open_standard_window($x);
28 my @urgent = grep { $_->{urgent} == 1 } @{get_ws_content($tmp)};
29 is(@urgent, 0, 'no window got the urgent flag');
31 #$i3->command('layout stacking')->recv;
33 #####################################################################
34 # Add the urgency hint, switch to a different workspace and back again
35 #####################################################################
36 $top->add_hint('urgency');
39 @content = @{get_ws_content($tmp)};
40 @urgent = grep { $_->{urgent} == 1 } @content;
41 $top_info = first { $_->{window} == $top->id } @content;
42 $bottom_info = first { $_->{window} == $bottom->id } @content;
44 is($top_info->{urgent}, 1, 'top window is marked urgent');
45 is($bottom_info->{urgent}, 0, 'bottom window is not marked urgent');
46 is(@urgent, 1, 'exactly one window got the urgent flag');
48 $i3->command('[id="' . $top->id . '"] focus')->recv;
50 @urgent = grep { $_->{urgent} == 1 } @{get_ws_content($tmp)};
51 is(@urgent, 0, 'no window got the urgent flag after focusing');
53 $top->add_hint('urgency');
56 @urgent = grep { $_->{urgent} == 1 } @{get_ws_content($tmp)};
57 is(@urgent, 0, 'no window got the urgent flag after re-setting urgency hint');
59 #####################################################################
60 # Check if the workspace urgency hint gets set/cleared correctly
61 #####################################################################
62 my $ws = get_ws($tmp);
63 is($ws->{urgent}, 0, 'urgent flag not set on workspace');
65 my $otmp = get_unused_workspace();
66 $i3->command("workspace $otmp")->recv;
68 $top->add_hint('urgency');
72 is($ws->{urgent}, 1, 'urgent flag set on workspace');
74 $i3->command("workspace $tmp")->recv;
77 is($ws->{urgent}, 0, 'urgent flag not set on workspace after switching');
79 diag( "Testing i3, Perl $], $^X" );