2 # vim:ts=4:sw=4:expandtab
3 # Beware that this test uses workspace 9 to perform some tests (it expects
4 # the workspace to be empty).
5 # TODO: skip it by default?
9 use Time::HiRes qw(sleep);
12 use_ok('X11::XCB::Connection') or BAIL_OUT('Cannot load X11::XCB::Connection');
15 my $x = X11::XCB::Connection->new;
19 # Switch to the nineth workspace
20 $i3->command('9')->recv;
22 #####################################################################
23 # Create two windows and make sure focus switching works
24 #####################################################################
26 my $top = i3test::open_standard_window($x);
28 my $mid = i3test::open_standard_window($x);
30 my $bottom = i3test::open_standard_window($x);
33 diag("top id = " . $top->id);
34 diag("mid id = " . $mid->id);
35 diag("bottom id = " . $bottom->id);
38 # Returns the input focus after sending the given command to i3 via IPC
39 # end sleeping for half a second to make sure i3 reacted
44 $i3->command($msg)->recv;
45 return $x->input_focus;
48 $focus = $x->input_focus;
49 is($focus, $bottom->id, "Latest window focused");
51 $focus = focus_after("ml");
52 is($focus, $bottom->id, "Right window still focused");
54 $focus = focus_after("h");
55 is($focus, $mid->id, "Middle window focused");
57 #####################################################################
58 # Now move to the top window, move right, then move left again
59 # (e.g., does i3 remember the focus in the last container?)
60 #####################################################################
62 $focus = focus_after("k");
63 is($focus, $top->id, "Top window focused");
65 $focus = focus_after("l");
66 is($focus, $bottom->id, "Right window focused");
68 $focus = focus_after("h");
69 is($focus, $top->id, "Top window focused");
71 #####################################################################
72 # Move window cross-workspace
73 #####################################################################
75 for my $cmd (qw(m12 t m13 12 13)) {
76 $i3->command($cmd)->recv;
78 ok(1, "Still living");