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;
91 is($con->{window}, $right->{id}, 'focus is initially on the right container');
94 my ($subscribecb, $want, $msg) = @_;
95 my @events = events_for(
98 my @focus = map { $_->{container}->{window} } grep { $_->{change} eq 'focus' } @events;
99 is_deeply(\@focus, $want, $msg);
102 subtest 'button 1 moves focus left', \&focus_subtest,
104 xtest_button_press(1, 3, 3);
105 xtest_button_release(1, 3, 3);
106 xtest_sync_with($i3bar_window);
109 'button 1 moves focus left';
111 subtest 'button 2 moves focus right', \&focus_subtest,
113 xtest_button_press(2, 3, 3);
114 xtest_button_release(2, 3, 3);
115 xtest_sync_with($i3bar_window);
118 'button 2 moves focus right';
120 subtest 'button 3 moves focus left', \&focus_subtest,
122 xtest_button_press(3, 3, 3);
123 xtest_button_release(3, 3, 3);
124 xtest_sync_with($i3bar_window);
127 'button 3 moves focus left';
129 subtest 'button 4 moves focus right', \&focus_subtest,
131 xtest_button_press(4, 3, 3);
132 xtest_button_release(4, 3, 3);
133 xtest_sync_with($i3bar_window);
136 'button 4 moves focus right';
138 subtest 'button 5 moves focus left', \&focus_subtest,
140 xtest_button_press(5, 3, 3);
141 xtest_button_release(5, 3, 3);
142 xtest_sync_with($i3bar_window);
145 'button 5 moves focus left';