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 # Tests the focus_follows_mouse setting.
18 use i3test i3_config => <<EOT;
20 font -misc-fixed-medium-r-normal--13-120-75-75-C-70-iso10646-1
22 fake-outputs 1000x1000+0+0
27 sub synced_warp_pointer {
28 my ($x_px, $y_px) = @_;
30 $x->root->warp_pointer($x_px, $y_px);
34 ###################################################################
35 # Test a simple case with 2 windows.
36 ###################################################################
38 synced_warp_pointer(600, 600);
40 $second = open_window;
41 is($x->input_focus, $second->id, 'second window focused');
43 synced_warp_pointer(0, 0);
44 is($x->input_focus, $first->id, 'first window focused');
46 ###################################################################
47 # Test that focus isn't changed with tabbed windows.
48 ###################################################################
51 synced_warp_pointer(600, 600);
54 $second = open_window;
55 is($x->input_focus, $second->id, 'second (tabbed) window focused');
57 synced_warp_pointer(0, 0);
58 is($x->input_focus, $second->id, 'second window still focused');
60 ###################################################################
61 # Test that floating windows are focused but not raised to the top.
63 ###################################################################
66 my $tmp = fresh_workspace;
67 my ($first_floating, $second_floating);
69 synced_warp_pointer(0, 0);
70 $first_floating = open_floating_window;
71 $first_floating->rect(X11::XCB::Rect->new(x => 1, y => 1, width => 100, height => 100));
72 $second_floating = open_floating_window;
73 $second_floating->rect(X11::XCB::Rect->new(x => 50, y => 50, width => 100, height => 100));
77 is($x->input_focus, $first->id, 'first (tiling) window focused');
79 is($ws->{floating_nodes}->[1]->{nodes}->[0]->{window}, $second_floating->id, 'second floating on top');
80 is($ws->{floating_nodes}->[0]->{nodes}->[0]->{window}, $first_floating->id, 'first floating behind');
82 synced_warp_pointer(40, 40);
83 is($x->input_focus, $first_floating->id, 'first floating window focused');
85 is($ws->{floating_nodes}->[1]->{nodes}->[0]->{window}, $second_floating->id, 'second floating still on top');
86 is($ws->{floating_nodes}->[0]->{nodes}->[0]->{window}, $first_floating->id, 'first floating still behind');