2 # vim:ts=4:sw=4:expandtab
7 my $tmp = fresh_workspace;
11 #####################################################################
12 # Create two windows and make sure focus switching works
13 #####################################################################
15 my $top = open_window;
16 my $mid = open_window;
17 my $bottom = open_window;
20 # Returns the input focus after sending the given command to i3 via IPC
28 return $x->input_focus;
31 my $focus = $x->input_focus;
32 is($focus, $bottom->id, "Latest window focused");
34 $focus = focus_after('focus left');
35 is($focus, $mid->id, "Middle window focused");
37 #####################################################################
38 # Now goto a mark which does not exist
39 #####################################################################
41 my $random_mark = mktemp('mark.XXXXXX');
43 $focus = focus_after(qq|[con_mark="$random_mark"] focus|);
44 is($focus, $mid->id, "focus unchanged");
46 cmd "mark $random_mark";
48 $focus = focus_after('focus left');
49 is($focus, $top->id, "Top window focused");
51 $focus = focus_after(qq|[con_mark="$random_mark"] focus|);
52 is($focus, $mid->id, "goto worked");
54 # check that we can specify multiple criteria
56 $focus = focus_after('focus left');
57 is($focus, $top->id, "Top window focused");
59 $focus = focus_after(qq|[con_mark="$random_mark" con_mark="$random_mark"] focus|);
60 is($focus, $mid->id, "goto worked");
62 #####################################################################
63 # Check whether the focus command will switch to a different
64 # workspace if necessary
65 #####################################################################
67 my $tmp2 = fresh_workspace;
69 is(focused_ws(), $tmp2, 'tmp2 now focused');
71 cmd qq|[con_mark="$random_mark"] focus|;
73 is(focused_ws(), $tmp, 'tmp now focused');