2 # vim:ts=4:sw=4:expandtab
6 use Digest::SHA1 qw(sha1_base64);
9 use_ok('X11::XCB::Connection') or BAIL_OUT('Cannot load X11::XCB::Connection');
12 my $x = X11::XCB::Connection->new;
14 my $i3 = i3("/tmp/nestedcons");
19 #####################################################################
20 # Create two windows and make sure focus switching works
21 #####################################################################
23 my $top = open_standard_window($x);
25 my $mid = open_standard_window($x);
27 my $bottom = open_standard_window($x);
30 diag("top id = " . $top->id);
31 diag("mid id = " . $mid->id);
32 diag("bottom id = " . $bottom->id);
35 # Returns the input focus after sending the given command to i3 via IPC
36 # end sleeping for half a second to make sure i3 reacted
42 return $x->input_focus;
45 $focus = $x->input_focus;
46 is($focus, $bottom->id, "Latest window focused");
48 $focus = focus_after("prev h");
49 is($focus, $mid->id, "Middle window focused");
51 #####################################################################
52 # Now goto a mark which does not exist
53 #####################################################################
55 my $random_mark = sha1_base64(rand());
57 $focus = focus_after(qq|[con_mark="$random_mark"] focus|);
58 is($focus, $mid->id, "focus unchanged");
60 $i3->command("mark $random_mark")->recv;
62 $focus = focus_after("prev h");
63 is($focus, $top->id, "Top window focused");
65 $focus = focus_after(qq|[con_mark="$random_mark"] focus|);
66 is($focus, $mid->id, "goto worked");