2 # vim:ts=4:sw=4:expandtab
4 # Please read the following documents before working on tests:
5 # • https://build.i3wm.org/docs/testsuite.html
8 # • https://build.i3wm.org/docs/lib-i3test.html
9 # (alternatively: perldoc ./testcases/lib/i3test.pm)
11 # • https://build.i3wm.org/docs/ipc.html
14 # • http://onyxneon.com/books/modern_perl/modern_perl_a4.pdf
15 # (unless you are already familiar with Perl)
17 # Ensures that mouse bindings on the i3bar work correctly.
19 use i3test i3_config => <<EOT;
21 font -misc-fixed-medium-r-normal--13-120-75-75-C-70-iso10646-1
22 focus_follows_mouse no
25 font -misc-fixed-medium-r-normal--13-120-75-75-C-70-iso10646-1
28 bindsym button1 focus left
29 bindsym button2 focus right
30 bindsym button3 focus left
31 bindsym button4 focus right
32 bindsym button5 focus left
37 my $i3 = i3(get_socket_path());
39 my $ws = fresh_workspace;
41 my $cv = AnyEvent->condvar;
42 my $timer = AnyEvent->timer(after => 1, interval => 0, cb => sub { $cv->send(0) });
46 if ($event->{change} eq 'focus') {
47 $cv->send($event->{container});
49 if ($event->{change} eq 'new') {
50 if (defined($event->{container}->{window_properties}->{class}) &&
51 $event->{container}->{window_properties}->{class} eq 'i3bar') {
52 $cv->send($event->{container});
61 for my $node (@{$nodes}) {
62 my $props = $node->{window_properties};
63 if (defined($props) && $props->{class} eq 'i3bar') {
64 return $node->{window};
68 return 0 if !@{$nodes};
70 my @children = (map { @{$_->{nodes}} } @{$nodes},
71 map { @{$_->{'floating_nodes'}} } @{$nodes});
73 return i3bar_present(\@children);
76 my $i3bar_window = i3bar_present($i3->get_tree->recv->{nodes});
78 ok(1, 'i3bar present');
81 ok($con, 'i3bar appeared');
82 $i3bar_window = $con->{window};
85 diag('i3bar window = ' . $i3bar_window);
87 my $left = open_window;
88 my $right = open_window;
92 my ($subscribecb, $want, $msg) = @_;
93 my @events = events_for(
96 my @focus = map { $_->{container}->{window} } grep { $_->{change} eq 'focus' } @events;
97 is_deeply(\@focus, $want, $msg);
100 subtest 'button 1 moves focus left', \&focus_subtest,
102 xtest_button_press(1, 3, 3);
103 xtest_button_release(1, 3, 3);
104 xtest_sync_with($i3bar_window);
107 'button 1 moves focus left';
109 subtest 'button 2 moves focus right', \&focus_subtest,
111 xtest_button_press(2, 3, 3);
112 xtest_button_release(2, 3, 3);
113 xtest_sync_with($i3bar_window);
116 'button 2 moves focus right';
118 subtest 'button 3 moves focus left', \&focus_subtest,
120 xtest_button_press(3, 3, 3);
121 xtest_button_release(3, 3, 3);
122 xtest_sync_with($i3bar_window);
125 'button 3 moves focus left';
127 subtest 'button 4 moves focus right', \&focus_subtest,
129 xtest_button_press(4, 3, 3);
130 xtest_button_release(4, 3, 3);
131 xtest_sync_with($i3bar_window);
134 'button 4 moves focus right';
136 subtest 'button 5 moves focus left', \&focus_subtest,
138 xtest_button_press(5, 3, 3);
139 xtest_button_release(5, 3, 3);
140 xtest_sync_with($i3bar_window);
143 'button 5 moves focus left';