Merge pull request #3999 from orestisfl/cmd_focus_sibling_workspace_crash

cmd_focus_sibling: Fix crash on workspace level
This commit is contained in:
Ingo Bürk 2020-04-09 11:47:32 +02:00 committed by GitHub
commit 26cbca3d27
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 22 additions and 1 deletions

View File

@ -1299,9 +1299,18 @@ void cmd_focus_sibling(I3_CMD, const char *direction_str) {
} }
Con *next = get_tree_next_sibling(current->con, direction); Con *next = get_tree_next_sibling(current->con, direction);
if (next) { if (next) {
if (next->type == CT_WORKSPACE) {
/* On the workspace level, we need to make sure that the
* workspace change happens properly. However, workspace_show
* descends focus so we also have to put focus on the workspace
* itself to maintain consistency. See #3997. */
workspace_show(next);
con_focus(next);
} else {
con_activate(next); con_activate(next);
} }
} }
}
cmd_output->needs_tree_render = true; cmd_output->needs_tree_render = true;
// XXX: default reply for now, make this a better reply // XXX: default reply for now, make this a better reply

View File

@ -69,4 +69,16 @@ cmp_tree(
cmd 'focus parent, focus next sibling'; cmd 'focus parent, focus next sibling';
}); });
# See #3997
cmd 'workspace 2';
open_window;
cmd 'workspace 1';
open_window;
cmd 'focus parent, focus parent, focus next sibling, focus prev sibling';
does_i3_live;
is(focused_ws, '1', 'Back and forth between workspaces');
cmd 'focus parent, focus parent, focus next sibling';
is(focused_ws, '2', "Workspace 2 focused with 'focus next sibling'");
done_testing; done_testing;