From 0a2ee1d2aa52c5bc793b2292a9d653fddb9a2395 Mon Sep 17 00:00:00 2001 From: Michael Stapelberg Date: Fri, 4 Mar 2011 15:21:18 +0100 Subject: [PATCH] Bugfix: Focus workspace after closing one of multiple dock clients (+testcase) (Thanks mseed) --- src/con.c | 6 +++ testcases/t/54-regress-multiple-dock.t | 72 ++++++++++++++++++++++++++ 2 files changed, 78 insertions(+) create mode 100644 testcases/t/54-regress-multiple-dock.t diff --git a/src/con.c b/src/con.c index da41f944..01381206 100644 --- a/src/con.c +++ b/src/con.c @@ -617,6 +617,12 @@ Con *con_next_focused(Con *con) { return next; } + /* dock clients cannot be focused, so we focus the workspace instead */ + if (con->parent->type == CT_DOCKAREA) { + DLOG("selecting workspace for dock client\n"); + return con_descend_focused(output_get_content(con->parent->parent)); + } + /* try to focus the next container on the same level as this one */ next = TAILQ_NEXT(con, focused); diff --git a/testcases/t/54-regress-multiple-dock.t b/testcases/t/54-regress-multiple-dock.t new file mode 100644 index 00000000..9e7353d4 --- /dev/null +++ b/testcases/t/54-regress-multiple-dock.t @@ -0,0 +1,72 @@ +#!perl +# vim:ts=4:sw=4:expandtab +# +# Regression test for closing one of multiple dock clients +# +use X11::XCB qw(:all); +use Time::HiRes qw(sleep); +use i3test; + +BEGIN { + use_ok('X11::XCB::Window'); +} + +my $x = X11::XCB::Connection->new; +my $i3 = i3("/tmp/nestedcons"); + +my $tmp = get_unused_workspace; +cmd "workspace $tmp"; + +##################################################################### +# verify that there is no dock window yet +##################################################################### + +# Children of all dockareas +my @docked = get_dock_clients; + +is(@docked, 0, 'no dock clients yet'); + +##################################################################### +# open a dock client +##################################################################### + +my $first = $x->root->create_child( + class => WINDOW_CLASS_INPUT_OUTPUT, + rect => [ 0, 0, 30, 30], + background_color => '#FF0000', + window_type => $x->atom(name => '_NET_WM_WINDOW_TYPE_DOCK'), +); + +$first->map; + +sleep 0.25; + +##################################################################### +# Open a second dock client +##################################################################### + +my $second = $x->root->create_child( + class => WINDOW_CLASS_INPUT_OUTPUT, + rect => [ 0, 0, 30, 30], + background_color => '#FF0000', + window_type => $x->atom(name => '_NET_WM_WINDOW_TYPE_DOCK'), +); + +$second->map; + +sleep 0.25; + +##################################################################### +# Kill the second dock client +##################################################################### +cmd "nop destroying dock client"; +$second->destroy; + +##################################################################### +# Now issue a focus command +##################################################################### +cmd 'next v'; + +does_i3_live; + +done_testing; -- 2.39.5