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?
7 use i3test tests => 22;
9 use Time::HiRes qw(sleep);
12 use_ok('X11::XCB::Connection') or BAIL_OUT('Cannot load X11::XCB::Connection');
16 skip "stacking test not yet updated", 21;
18 my $x = X11::XCB::Connection->new;
22 # Switch to the nineth workspace
23 $i3->command('9')->recv;
25 #####################################################################
26 # Create two windows and make sure focus switching works
27 #####################################################################
29 my $top = i3test::open_standard_window($x);
31 my $mid = i3test::open_standard_window($x);
33 my $bottom = i3test::open_standard_window($x);
36 diag("top id = " . $top->id);
37 diag("mid id = " . $mid->id);
38 diag("bottom id = " . $bottom->id);
41 # Returns the input focus after sending the given command to i3 via IPC
42 # end sleeping for half a second to make sure i3 reacted
47 $i3->command($msg)->recv;
48 return $x->input_focus;
51 $focus = $x->input_focus;
52 is($focus, $bottom->id, "Latest window focused");
54 $focus = focus_after("s");
55 is($focus, $bottom->id, "Last window still focused");
57 $focus = focus_after("k");
58 is($focus, $mid->id, "Middle window focused");
60 $focus = focus_after("k");
61 is($focus, $top->id, "Top window focused");
63 #####################################################################
65 #####################################################################
67 $focus = focus_after("k");
68 is($focus, $bottom->id, "Bottom window focused (wrapping to the top works)");
70 $focus = focus_after("j");
71 is($focus, $top->id, "Top window focused (wrapping to the bottom works)");
73 #####################################################################
74 # Restore of focus after moving windows out/into the stack
75 #####################################################################
77 $focus = focus_after("ml");
78 is($focus, $top->id, "Top window still focused (focus after moving)");
80 $focus = focus_after("h");
81 is($focus, $bottom->id, "Bottom window focused (focus after moving)");
83 my $new = i3test::open_standard_window($x);
86 # By now, we have this layout:
93 $focus = focus_after("l");
94 is($focus, $top->id, "Got top window");
96 $focus = focus_after("mh");
97 is($focus, $top->id, "Moved it into the stack");
99 $focus = focus_after("k");
100 is($focus, $new->id, "Window above is new");
102 $focus = focus_after("k");
103 is($focus, $bottom->id, "Window above is bottom");
105 $focus = focus_after("k");
106 is($focus, $mid->id, "Window above is mid");
108 $focus = focus_after("k");
109 is($focus, $top->id, "At top again");
111 $focus = focus_after("ml");
112 is($focus, $top->id, "Still at top, moved out");
114 $focus = focus_after("h");
115 is($focus, $mid->id, "At mid again");
117 $focus = focus_after("j");
118 is($focus, $bottom->id, "At bottom again");
120 $focus = focus_after("l");
121 is($focus, $top->id, "At top again");
123 $focus = focus_after("mh");
124 is($focus, $top->id, "Still at top, moved into");
126 $focus = focus_after("k");
127 is($focus, $bottom->id, "Window above is bottom");
129 $focus = focus_after("k");
130 is($focus, $mid->id, "Window above is mid");