From a25dc3e988802037ccd248ef9c053d5c2d494b50 Mon Sep 17 00:00:00 2001 From: Michael Stapelberg Date: Tue, 1 Jun 2010 18:49:43 +0200 Subject: [PATCH] Implement focus command (and extend t/21-next-prev.t to test it) --- src/cmdparse.y | 14 ++++++++++++++ testcases/t/21-next-prev.t | 9 ++++++++- 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/src/cmdparse.y b/src/cmdparse.y index cc710a49..40fd65af 100644 --- a/src/cmdparse.y +++ b/src/cmdparse.y @@ -303,7 +303,21 @@ attach: focus: TOK_FOCUS { + owindow *current; + printf("should focus\n"); + if (match_is_empty(¤t_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); + } } ; diff --git a/testcases/t/21-next-prev.t b/testcases/t/21-next-prev.t index bc0e6025..6d9a6e5c 100644 --- a/testcases/t/21-next-prev.t +++ b/testcases/t/21-next-prev.t @@ -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" ); -- 2.39.5