]> git.sur5r.net Git - i3/i3/blob - testcases/t/293-focus-follows-mouse.t
Merge pull request #3469 from yablonsky/patch-1
[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 ###################################################################
61 # Test that floating windows are focused but not raised to the top.
62 # See issue #2990.
63 ###################################################################
64
65 my $ws;
66 my $tmp = fresh_workspace;
67 my ($first_floating, $second_floating);
68
69 synced_warp_pointer(0, 0);
70 $first_floating = open_floating_window(rect => [ 1, 1, 100, 100 ]);
71 $second_floating = open_floating_window(rect => [ 50, 50, 100, 100 ]);
72 $first = open_window;
73
74 is($x->input_focus, $first->id, 'first (tiling) window focused');
75 $ws = get_ws($tmp);
76 is($ws->{floating_nodes}->[1]->{nodes}->[0]->{window}, $second_floating->id, 'second floating on top');
77 is($ws->{floating_nodes}->[0]->{nodes}->[0]->{window}, $first_floating->id, 'first floating behind');
78
79 synced_warp_pointer(40, 40);
80 is($x->input_focus, $first_floating->id, 'first floating window focused');
81 $ws = get_ws($tmp);
82 is($ws->{floating_nodes}->[1]->{nodes}->[0]->{window}, $second_floating->id, 'second floating still on top');
83 is($ws->{floating_nodes}->[0]->{nodes}->[0]->{window}, $first_floating->id, 'first floating still behind');
84
85 done_testing;