From d66fa51f336378c55e266c8aa2ba5fbec64d6a73 Mon Sep 17 00:00:00 2001 From: Orestis Floros Date: Fri, 22 Sep 2017 04:48:32 +0300 Subject: [PATCH] Don't call con_focus in tree_move Fixes: - Issue where moving an urgent (unfocused) window resets it's urgency hint. - Moving an unfocused container to a new parent should not move it to the top of the focus stack. --- src/move.c | 5 ----- testcases/t/113-urgent.t | 28 ++++++++++++++++++++++++++++ testcases/t/294-focus-order.t | 16 ++++++++++++++++ 3 files changed, 44 insertions(+), 5 deletions(-) diff --git a/src/move.c b/src/move.c index 72cf9d61..a60a27ca 100644 --- a/src/move.c +++ b/src/move.c @@ -374,11 +374,6 @@ void tree_move(Con *con, int direction) { } end: - /* We need to call con_focus() to fix the focus stack "above" the container - * we just inserted the focused container into (otherwise, the parent - * container(s) would still point to the old container(s)). */ - con_focus(con); - /* force re-painting the indicators */ FREE(con->deco_render_params); diff --git a/testcases/t/113-urgent.t b/testcases/t/113-urgent.t index 1e2644ad..0de90193 100644 --- a/testcases/t/113-urgent.t +++ b/testcases/t/113-urgent.t @@ -332,6 +332,34 @@ for ($type = 1; $type <= 2; $type++) { ok(!$source_ws->{urgent}, 'Source workspace is no longer marked urgent'); is($target_ws->{urgent}, 1, 'Target workspace is now marked urgent'); +############################################################################## +# Test that moving an unfocused container doesn't reset its urgency hint. +############################################################################## + $tmp = fresh_workspace; + $win1 = open_window; + $win2 = open_window; + cmd 'split v'; + $win3 = open_window; + set_urgency($win1, 1, $type); + sync_with_i3; + + my $win1_info; + + @content = @{get_ws_content($tmp)}; + $win1_info = first { $_->{window} == $win1->id } @content; + ok($win1_info->{urgent}, 'win1 window is marked urgent'); + + cmd '[id="' . $win1->id . '"] move right'; + cmd '[id="' . $win1->id . '"] move right'; + @content = @{get_ws_content($tmp)}; + $win1_info = first { $_->{window} == $win1->id } @content; + ok($win1_info->{urgent}, 'win1 window is still marked urgent after moving'); + + cmd '[id="' . $win1->id . '"] focus'; + @content = @{get_ws_content($tmp)}; + $win1_info = first { $_->{window} == $win1->id } @content; + ok(!$win1_info->{urgent}, 'win1 window is not marked urgent after focusing'); + ############################################################################## exit_gracefully($pid); diff --git a/testcases/t/294-focus-order.t b/testcases/t/294-focus-order.t index 41c0bf07..0f116241 100644 --- a/testcases/t/294-focus-order.t +++ b/testcases/t/294-focus-order.t @@ -106,4 +106,20 @@ $windows[0] = open_window; cmd 'move left'; confirm_focus('split-v + move'); +###################################################################### +# Test that moving an unfocused container maintains the correct focus +# order. +# Layout: H [ A V1 [ B C D ] ] +###################################################################### + +fresh_workspace; +$windows[3] = open_window; +$windows[2] = open_window; +cmd 'split v'; +$windows[1] = open_window; +$windows[0] = open_window; + +cmd '[id=' . $windows[3]->id . '] move right'; +confirm_focus('split-v + unfocused move'); + done_testing; -- 2.39.2