]> git.sur5r.net Git - i3/i3/blob - testcases/t/113-urgent.t
Merge branch 'fix-floating-restart'
[i3/i3] / testcases / t / 113-urgent.t
1 #!perl
2 # vim:ts=4:sw=4:expandtab
3
4 use i3test;
5 use X11::XCB qw(:all);
6 use List::Util qw(first);
7
8 BEGIN {
9     use_ok('X11::XCB::Connection') or BAIL_OUT('Cannot load X11::XCB::Connection');
10 }
11
12 my $x = X11::XCB::Connection->new;
13
14 my $tmp = fresh_workspace;
15
16 #####################################################################
17 # Create two windows and put them in stacking mode
18 #####################################################################
19
20 cmd 'split v';
21
22 my $top = open_window($x);
23 my $bottom = open_window($x);
24
25 my @urgent = grep { $_->{urgent} } @{get_ws_content($tmp)};
26 is(@urgent, 0, 'no window got the urgent flag');
27
28 # cmd 'layout stacking';
29
30 #####################################################################
31 # Add the urgency hint, switch to a different workspace and back again
32 #####################################################################
33 $top->add_hint('urgency');
34 sync_with_i3($x);
35
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;
40
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');
44
45 cmd '[id="' . $top->id . '"] focus';
46
47 @urgent = grep { $_->{urgent} } @{get_ws_content($tmp)};
48 is(@urgent, 0, 'no window got the urgent flag after focusing');
49
50 $top->add_hint('urgency');
51 sync_with_i3($x);
52
53 @urgent = grep { $_->{urgent} } @{get_ws_content($tmp)};
54 is(@urgent, 0, 'no window got the urgent flag after re-setting urgency hint');
55
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');
61
62 my $otmp = fresh_workspace;
63
64 $top->add_hint('urgency');
65 sync_with_i3($x);
66
67 $ws = get_ws($tmp);
68 ok($ws->{urgent}, 'urgent flag set on workspace');
69
70 cmd "workspace $tmp";
71
72 $ws = get_ws($tmp);
73 ok(!$ws->{urgent}, 'urgent flag not set on workspace after switching');
74
75 done_testing;