]> git.sur5r.net Git - i3/i3/blob - testcases/t/525-i3bar-mouse-bindings.t
Merge pull request #2942 from stapelberg/append
[i3/i3] / testcases / t / 525-i3bar-mouse-bindings.t
1 #!perl
2 # vim:ts=4:sw=4:expandtab
3 #
4 # Please read the following documents before working on tests:
5 # • http://build.i3wm.org/docs/testsuite.html
6 #   (or docs/testsuite)
7 #
8 # • http://build.i3wm.org/docs/lib-i3test.html
9 #   (alternatively: perldoc ./testcases/lib/i3test.pm)
10 #
11 # • http://build.i3wm.org/docs/ipc.html
12 #   (or docs/ipc)
13 #
14 # • http://onyxneon.com/books/modern_perl/modern_perl_a4.pdf
15 #   (unless you are already familiar with Perl)
16 #
17 # Ensures that mouse bindings on the i3bar work correctly.
18 # Ticket: #1695
19 use i3test i3_autostart => 0;
20 use i3test::XTEST;
21
22 my ($cv, $timer);
23 sub reset_test {
24     $cv = AE::cv;
25     $timer = AE::timer(1, 0, sub { $cv->send(0); });
26 }
27
28 my $config = <<EOT;
29 # i3 config file (v4)
30 font -misc-fixed-medium-r-normal--13-120-75-75-C-70-iso10646-1
31 focus_follows_mouse no
32
33 bar {
34     font -misc-fixed-medium-r-normal--13-120-75-75-C-70-iso10646-1
35     position top
36
37     bindsym button1 focus left
38     bindsym button2 focus right
39     bindsym button3 focus left
40     bindsym button4 focus right
41     bindsym button5 focus left
42 }
43 EOT
44
45 my $pid = launch_with_config($config);
46 my $i3 = i3(get_socket_path());
47 $i3->connect()->recv;
48 my $ws = fresh_workspace;
49
50 reset_test;
51 $i3->subscribe({
52         window => sub {
53             my ($event) = @_;
54             if ($event->{change} eq 'focus') {
55                 $cv->send($event->{container});
56             }
57             if ($event->{change} eq 'new') {
58                 if (defined($event->{container}->{window_properties}->{class}) &&
59                     $event->{container}->{window_properties}->{class} eq 'i3bar') {
60                     $cv->send($event->{container});
61                 }
62             }
63         },
64     })->recv;
65
66 my $con = $cv->recv;
67 ok($con, 'i3bar appeared');
68
69 my $left = open_window;
70 my $right = open_window;
71 sync_with_i3;
72 $con = $cv->recv;
73 is($con->{window}, $right->{id}, 'focus is initially on the right container');
74 reset_test;
75
76 xtest_button_press(1, 3, 3);
77 xtest_button_release(1, 3, 3);
78 sync_with_i3;
79 $con = $cv->recv;
80 is($con->{window}, $left->{id}, 'button 1 moves focus left');
81 reset_test;
82
83 xtest_button_press(2, 3, 3);
84 xtest_button_release(2, 3, 3);
85 sync_with_i3;
86 $con = $cv->recv;
87 is($con->{window}, $right->{id}, 'button 2 moves focus right');
88 reset_test;
89
90 xtest_button_press(3, 3, 3);
91 xtest_button_release(3, 3, 3);
92 sync_with_i3;
93 $con = $cv->recv;
94 is($con->{window}, $left->{id}, 'button 3 moves focus left');
95 reset_test;
96
97 xtest_button_press(4, 3, 3);
98 xtest_button_release(4, 3, 3);
99 sync_with_i3;
100 $con = $cv->recv;
101 is($con->{window}, $right->{id}, 'button 4 moves focus right');
102 reset_test;
103
104 xtest_button_press(5, 3, 3);
105 xtest_button_release(5, 3, 3);
106 sync_with_i3;
107 $con = $cv->recv;
108 is($con->{window}, $left->{id}, 'button 5 moves focus left');
109 reset_test;
110
111 exit_gracefully($pid);
112
113 done_testing;