]> git.sur5r.net Git - i3/i3/commitdiff
Implement focus command (and extend t/21-next-prev.t to test it)
authorMichael Stapelberg <michael@stapelberg.de>
Tue, 1 Jun 2010 16:49:43 +0000 (18:49 +0200)
committerMichael Stapelberg <michael@stapelberg.de>
Tue, 1 Jun 2010 16:49:43 +0000 (18:49 +0200)
src/cmdparse.y
testcases/t/21-next-prev.t

index cc710a49bcf658f386cdc0d1d1ac00a419f176c8..40fd65af0aede67497e2a453be277288735228eb 100644 (file)
@@ -303,7 +303,21 @@ attach:
 focus:
     TOK_FOCUS
     {
+        owindow *current;
+
         printf("should focus\n");
+        if (match_is_empty(&current_match)) {
+            /* TODO: better error message */
+            LOG("Error: The foucs command requires you to use some criteria.\n");
+            return;
+        }
+
+        /* TODO: warning if the match contains more than one entry. does not
+         * make so much sense when focusing */
+        TAILQ_FOREACH(current, &owindows, owindows) {
+            LOG("focusing %p / %s\n", current->con, current->con->name);
+            con_focus(current->con);
+        }
     }
     ;
 
index bc0e6025942f1cec7a588dd668425e6c58bcc66a..6d9a6e5c0611f909f60788e6dfbf86f2d45d3cd5 100644 (file)
@@ -3,7 +3,7 @@
 #
 # Tests focus switching (next/prev)
 #
-use i3test tests => 13;
+use i3test tests => 14;
 use X11::XCB qw(:all);
 use v5.10;
 
@@ -81,4 +81,11 @@ $i3->command('next horizontal')->recv;
 ($nodes, $focus) = get_ws_content($tmp);
 is($focus->[0], $right, 'right container focused');
 
+# Test focus command
+
+$i3->command(qq|[con_id="$mid"] focus|)->recv;
+($nodes, $focus) = get_ws_content($tmp);
+is($focus->[0], $mid, 'middle container focused');
+
+
 diag( "Testing i3, Perl $], $^X" );