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
40 $timer = AE::timer(1, 0, sub { $cv->send(0); });
43 my $i3 = i3(get_socket_path());
45 my $ws = fresh_workspace;
51 if ($event->{change} eq 'focus') {
52 $cv->send($event->{container});
54 if ($event->{change} eq 'new') {
55 if (defined($event->{container}->{window_properties}->{class}) &&
56 $event->{container}->{window_properties}->{class} eq 'i3bar') {
57 $cv->send($event->{container});
68 for my $node (@{$nodes}) {
69 my $props = $node->{window_properties};
70 if (defined($props) && $props->{class} eq 'i3bar') {
75 return 0 if !@{$nodes};
77 my @children = (map { @{$_->{nodes}} } @{$nodes},
78 map { @{$_->{'floating_nodes'}} } @{$nodes});
80 return i3bar_present(\@children);
83 if (i3bar_present($i3->get_tree->recv->{nodes})) {
84 ok(1, 'i3bar present');
87 ok($con, 'i3bar appeared');
90 my $left = open_window;
91 my $right = open_window;
94 is($con->{window}, $right->{id}, 'focus is initially on the right container');
97 xtest_button_press(1, 3, 3);
98 xtest_button_release(1, 3, 3);
101 is($con->{window}, $left->{id}, 'button 1 moves focus left');
104 xtest_button_press(2, 3, 3);
105 xtest_button_release(2, 3, 3);
108 is($con->{window}, $right->{id}, 'button 2 moves focus right');
111 xtest_button_press(3, 3, 3);
112 xtest_button_release(3, 3, 3);
115 is($con->{window}, $left->{id}, 'button 3 moves focus left');
118 xtest_button_press(4, 3, 3);
119 xtest_button_release(4, 3, 3);
122 is($con->{window}, $right->{id}, 'button 4 moves focus right');
125 xtest_button_press(5, 3, 3);
126 xtest_button_release(5, 3, 3);
129 is($con->{window}, $left->{id}, 'button 5 moves focus left');