]> git.sur5r.net Git - i3/i3/blob - testcases/t/293-focus-follows-mouse.t
9fb1004e6af14636a2f73cf88ea61a8ddc557e07
[i3/i3] / testcases / t / 293-focus-follows-mouse.t
1 #!perl
2 # vim:ts=4:sw=4:expandtab
3 #
4 # Please read the following documents before working on tests:
5 # • https://build.i3wm.org/docs/testsuite.html
6 #   (or docs/testsuite)
7 #
8 # • https://build.i3wm.org/docs/lib-i3test.html
9 #   (alternatively: perldoc ./testcases/lib/i3test.pm)
10 #
11 # • https://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 # Tests the focus_follows_mouse setting.
18 use i3test i3_config => <<EOT;
19 # i3 config file (v4)
20 font -misc-fixed-medium-r-normal--13-120-75-75-C-70-iso10646-1
21
22 fake-outputs 1000x1000+0+0
23 EOT
24
25 my ($first, $second);
26
27 sub synced_warp_pointer {
28     my ($x_px, $y_px) = @_;
29     sync_with_i3;
30     $x->root->warp_pointer($x_px, $y_px);
31     sync_with_i3;
32 }
33
34 ###################################################################
35 # Test a simple case with 2 windows.
36 ###################################################################
37
38 synced_warp_pointer(600, 600);
39 $first = open_window;
40 $second = open_window;
41 is($x->input_focus, $second->id, 'second window focused');
42
43 synced_warp_pointer(0, 0);
44 is($x->input_focus, $first->id, 'first window focused');
45
46 ###################################################################
47 # Test that focus isn't changed with tabbed windows.
48 ###################################################################
49
50 fresh_workspace;
51 synced_warp_pointer(600, 600);
52 $first = open_window;
53 cmd 'layout tabbed';
54 $second = open_window;
55 is($x->input_focus, $second->id, 'second (tabbed) window focused');
56
57 synced_warp_pointer(0, 0);
58 is($x->input_focus, $second->id, 'second window still focused');
59
60 done_testing;