2 # vim:ts=4:sw=4:expandtab
4 # Tests whether the urgency timer works as expected and does not break
8 use List::Util qw(first);
9 use i3test i3_autostart => 0;
10 use Time::HiRes qw(sleep);
12 # Ensure the pointer is at (0, 0) so that we really start on the first
13 # (the left) workspace.
14 $x->root->warp_pointer(0, 0);
18 font -misc-fixed-medium-r-normal--13-120-75-75-C-70-iso10646-1
20 force_display_urgency_hint 150ms
22 my $pid = launch_with_config($config);
24 #####################################################################
25 # Initial setup: one window on ws1, empty ws2
26 #####################################################################
28 my $tmp1 = fresh_workspace;
31 my $tmp2 = fresh_workspace;
32 cmd "workspace $tmp2";
34 $w->add_hint('urgency');
37 #######################################################################
38 # Create a window on ws1, then switch to ws2, set urgency, switch back
39 #######################################################################
41 isnt($x->input_focus, $w->id, 'window not focused');
43 my @content = @{get_ws_content($tmp1)};
44 my @urgent = grep { $_->{urgent} } @content;
45 is(@urgent, 1, "window marked as urgent");
48 cmd "workspace $tmp1";
50 # this will start the timer
52 @content = @{get_ws_content($tmp1)};
53 @urgent = grep { $_->{urgent} } @content;
54 is(@urgent, 1, 'window still marked as urgent');
56 # now check if the timer was triggered
57 cmd "workspace $tmp2";
60 @content = @{get_ws_content($tmp1)};
61 @urgent = grep { $_->{urgent} } @content;
62 is(@urgent, 0, 'window not marked as urgent anymore');
64 #######################################################################
65 # Create another window on ws1, focus it, switch to ws2, make the other
66 # window urgent, and switch back. This should not trigger the timer.
67 #######################################################################
69 cmd "workspace $tmp1";
71 is($x->input_focus, $w2->id, 'window 2 focused');
73 cmd "workspace $tmp2";
74 $w->add_hint('urgency');
77 @content = @{get_ws_content($tmp1)};
78 @urgent = grep { $_->{urgent} } @content;
79 is(@urgent, 1, 'window 1 marked as urgent');
81 # Switch back to ws1. This should focus w2.
82 cmd "workspace $tmp1";
83 is($x->input_focus, $w2->id, 'window 2 focused');
85 @content = @{get_ws_content($tmp1)};
86 @urgent = grep { $_->{urgent} } @content;
87 is(@urgent, 1, 'window 1 still marked as urgent');
89 # explicitly focusing the window should result in immediate urgency reset
90 cmd '[id="' . $w->id . '"] focus';
91 @content = @{get_ws_content($tmp1)};
92 @urgent = grep { $_->{urgent} } @content;
93 is(@urgent, 0, 'window 1 not marked as urgent anymore');