From b565bfca134132bdf1e96a5a2fa3a415ab80407c Mon Sep 17 00:00:00 2001 From: Sebastian Rachuj Date: Sat, 9 Feb 2013 20:23:01 +0100 Subject: [PATCH] Bugfix: Do not move focus if a container is moved across outputs fixes #809 This makes the moving behavior more consistent. If you want to focus the workspace you are moving to, just chain the keybinding in your config file: bindsym $mod+Shift+1 move workspace 1; workspace 1 --- src/con.c | 28 ++++++---------- testcases/t/508-move-workspace-focus.t | 46 -------------------------- testcases/t/512-move-wraps.t | 1 + testcases/t/513-move-workspace.t | 3 ++ 4 files changed, 15 insertions(+), 63 deletions(-) delete mode 100644 testcases/t/508-move-workspace-focus.t diff --git a/src/con.c b/src/con.c index 70c7d7f5..c1e4f593 100644 --- a/src/con.c +++ b/src/con.c @@ -762,24 +762,18 @@ void con_move_to_workspace(Con *con, Con *workspace, bool fix_coordinates, bool con_focus(old_focus); } - /* 8: when moving to a visible workspace on a different output, we keep the - * con focused. Otherwise, we leave the focus on the current workspace as we - * don’t want to focus invisible workspaces */ - if (source_output != dest_output && - workspace_is_visible(workspace) && - !con_is_internal(workspace)) { - DLOG("Moved to a different output, focusing target\n"); - } else { - /* Descend focus stack in case focus_next is a workspace which can - * occur if we move to the same workspace. Also show current workspace - * to ensure it is focused. */ - workspace_show(current_ws); - - /* Set focus only if con was on current workspace before moving. - * Otherwise we would give focus to some window on different workspace. */ - if (source_ws == current_ws) + /* 8: when moving to another workspace, we leave the focus on the current + * workspace. (see also #809) */ + + /* Descend focus stack in case focus_next is a workspace which can + * occur if we move to the same workspace. Also show current workspace + * to ensure it is focused. */ + workspace_show(current_ws); + + /* Set focus only if con was on current workspace before moving. + * Otherwise we would give focus to some window on different workspace. */ + if (source_ws == current_ws) con_focus(con_descend_focused(focus_next)); - } /* If anything within the container is associated with a startup sequence, * delete it so child windows won't be created on the old workspace. */ diff --git a/testcases/t/508-move-workspace-focus.t b/testcases/t/508-move-workspace-focus.t deleted file mode 100644 index 7d42ff4e..00000000 --- a/testcases/t/508-move-workspace-focus.t +++ /dev/null @@ -1,46 +0,0 @@ -#!perl -# vim:ts=4:sw=4:expandtab -# -# Please read the following documents before working on tests: -# • http://build.i3wm.org/docs/testsuite.html -# (or docs/testsuite) -# -# • http://build.i3wm.org/docs/lib-i3test.html -# (alternatively: perldoc ./testcases/lib/i3test.pm) -# -# • http://build.i3wm.org/docs/ipc.html -# (or docs/ipc) -# -# • http://onyxneon.com/books/modern_perl/modern_perl_a4.pdf -# (unless you are already familiar with Perl) -# -# Regression test: Verify that focus is correct after moving a floating window -# to a workspace on a different visible output. -# Bug still in: 4.3-83-ge89a25f -use i3test i3_autostart => 0; - -# Ensure the pointer is at (0, 0) so that we really start on the first -# (the left) workspace. -$x->root->warp_pointer(0, 0); - -my $config = < 0); -open_window; - -my $right_ws = fresh_workspace(output => 1); -open_window; -my $right_float = open_floating_window; - -cmd "move workspace $left_ws"; -is($x->input_focus, $right_float->id, 'floating window still focused'); - -exit_gracefully($pid); - -done_testing; diff --git a/testcases/t/512-move-wraps.t b/testcases/t/512-move-wraps.t index d3952e4e..82d5a7cc 100644 --- a/testcases/t/512-move-wraps.t +++ b/testcases/t/512-move-wraps.t @@ -41,6 +41,7 @@ my $win = open_window; is_num_children($left, 1, 'one container on left workspace'); cmd 'move container to output right'; +cmd 'focus output right'; is_num_children($left, 0, 'no containers on left workspace'); is_num_children($right, 1, 'one container on right workspace'); diff --git a/testcases/t/513-move-workspace.t b/testcases/t/513-move-workspace.t index 96ddfba9..17c8de71 100644 --- a/testcases/t/513-move-workspace.t +++ b/testcases/t/513-move-workspace.t @@ -75,16 +75,19 @@ my ($nodes, $focus) = get_ws_content('1'); is($nodes->[0]->{window}, $win1->id, 'window 1 on workspace 1'); cmd 'move workspace next'; +cmd '[id="' . $win1->id . '"] focus'; ($nodes, $focus) = get_ws_content('2'); is($nodes->[1]->{window}, $win1->id, 'window 1 on workspace 2 after moving'); cmd 'move workspace prev'; +cmd '[id="' . $win1->id . '"] focus'; ($nodes, $focus) = get_ws_content('1'); is($nodes->[0]->{window}, $win1->id, 'window 1 on workspace 1'); cmd 'move workspace next_on_output'; +cmd '[id="' . $win1->id . '"] focus'; ($nodes, $focus) = get_ws_content('5'); is($nodes->[1]->{window}, $win1->id, 'window 1 on workspace 5 after moving'); -- 2.39.2