2 # vim:ts=4:sw=4:expandtab
3 # !NO_I3_INSTANCE! will prevent complete-run.pl from starting i3
5 # Tests if the 'force_focus_wrapping' config directive works correctly.
10 use File::Temp qw(tempfile tempdir);
11 use X11::XCB qw(:all);
12 use X11::XCB::Connection;
14 my $x = X11::XCB::Connection->new;
16 # assuming we are run by complete-run.pl
17 my $i3_path = abs_path("../i3");
18 my $socketpath = File::Temp::tempnam('/tmp', 'i3-test-socket-');
20 #####################################################################
21 # 1: test the wrapping behaviour without force_focus_wrapping
22 #####################################################################
24 my ($fh, $tmpfile) = tempfile();
25 say $fh "# i3 config file (v4)";
26 say $fh "font -misc-fixed-medium-r-normal--13-120-75-75-C-70-iso10646-1";
27 say $fh "ipc-socket $socketpath";
31 my $i3cmd = "exec " . abs_path("../i3") . " -V -d all --disable-signalhandler -c $tmpfile >/dev/null 2>/dev/null";
32 my $process = Proc::Background->new($i3cmd);
35 # force update of the cached socket path in lib/i3test
38 diag("pid = " . $process->pid);
40 my $tmp = fresh_workspace;
42 ok(@{get_ws_content($tmp)} == 0, 'no containers yet');
44 my $first = open_standard_window($x);
45 my $second = open_standard_window($x);
50 my $third = open_standard_window($x);
51 is($x->input_focus, $third->id, 'third window focused');
54 is($x->input_focus, $second->id, 'second window focused');
57 is($x->input_focus, $first->id, 'first window focused');
59 # now test the wrapping
61 is($x->input_focus, $second->id, 'second window focused');
63 # but focusing right should not wrap now, but instead focus the third window
65 is($x->input_focus, $third->id, 'third window focused');
67 exit_gracefully($process->pid);
69 #####################################################################
70 # 2: test the wrapping behaviour with force_focus_wrapping
71 #####################################################################
73 ($fh, $tmpfile) = tempfile();
74 say $fh "# i3 config file (v4)";
75 say $fh "font -misc-fixed-medium-r-normal--13-120-75-75-C-70-iso10646-1";
76 say $fh "ipc-socket $socketpath";
77 say $fh "force_focus_wrapping true";
81 $i3cmd = "exec " . abs_path("../i3") . " -V -d all --disable-signalhandler -c $tmpfile >/dev/null 2>/dev/null";
82 $process = Proc::Background->new($i3cmd);
85 # force update of the cached socket path in lib/i3test
88 diag("pid = " . $process->pid);
90 $tmp = fresh_workspace;
92 ok(@{get_ws_content($tmp)} == 0, 'no containers yet');
94 $first = open_standard_window($x);
95 $second = open_standard_window($x);
100 $third = open_standard_window($x);
101 is($x->input_focus, $third->id, 'third window focused');
104 is($x->input_focus, $second->id, 'second window focused');
107 is($x->input_focus, $first->id, 'first window focused');
109 # now test the wrapping
111 is($x->input_focus, $second->id, 'second window focused');
113 # focusing right should now be forced to wrap
115 is($x->input_focus, $first->id, 'first window focused');
117 exit_gracefully($process->pid);