From 28212709490e54e2517dc772289e5fd598349f0a Mon Sep 17 00:00:00 2001 From: Orestis Floros Date: Mon, 14 Oct 2019 15:38:44 +0300 Subject: [PATCH] _con_move_to_con: focus_next only if in different workspaces --- src/con.c | 2 +- testcases/t/294-focus-order.t | 29 +++++++++++++++++++++++++++++ 2 files changed, 30 insertions(+), 1 deletion(-) diff --git a/src/con.c b/src/con.c index e0993ade..4d1c6167 100644 --- a/src/con.c +++ b/src/con.c @@ -1195,7 +1195,7 @@ static bool _con_move_to_con(Con *con, Con *target, bool behind_focused, bool fi /* 1: save the container which is going to be focused after the current * container is moved away */ Con *focus_next = NULL; - if (!ignore_focus && source_ws == current_ws) { + if (!ignore_focus && source_ws == current_ws && target_ws != source_ws) { focus_next = con_descend_focused(source_ws); if (focus_next == con || con_has_parent(focus_next, con)) { focus_next = con_next_focused(con); diff --git a/testcases/t/294-focus-order.t b/testcases/t/294-focus-order.t index 86adb819..ce790019 100644 --- a/testcases/t/294-focus-order.t +++ b/testcases/t/294-focus-order.t @@ -280,4 +280,33 @@ cmd '[id=' . $windows[0]->id . '] kill'; kill_and_confirm_focus($windows[2]->id, 'window 2 focused after tiling killed'); kill_and_confirm_focus($windows[3]->id, 'window 3 focused after tiling killed'); +###################################################################### +# cmp_tree tests +###################################################################### + +cmp_tree( + msg => 'Basic test', + layout_before => 'S[a b] V[c d T[e f g*]]', + layout_after => ' ', + cb => sub { + @windows = reverse @{$_[0]}; + confirm_focus('focus order'); + }); + +cmp_tree( + msg => 'Focused container that is moved to mark keeps focus', + layout_before => 'S[a b] V[2 3 T[4 5* 6]]', + layout_after => 'S[a b*]', + cb => sub { + cmd '[class=' . $_[0][3]->id . '] mark 3'; + cmd 'move to mark 3'; + + $windows[0] = $_[0][5]; + $windows[1] = $_[0][6]; + $windows[2] = $_[0][4]; + $windows[3] = $_[0][3]; + $windows[4] = $_[0][2]; + confirm_focus('focus order'); + }); + done_testing;