diff options
author | Ingo Bürk <admin@airblader.de> | 2020-04-09 11:47:32 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-04-09 11:47:32 +0200 |
commit | 26cbca3d279d698a92e907d5cb95b32a7941f3fc (patch) | |
tree | 0e3a51598578b9b913bf6c984c906aeae3177979 | |
parent | 016d4a3f45903229205bde6ef04887d179c924bd (diff) | |
parent | 4b4f1f604f98f0f7fbfc1d539db0b3a4147b9b4d (diff) | |
download | i3-26cbca3d279d698a92e907d5cb95b32a7941f3fc.tar.gz i3-26cbca3d279d698a92e907d5cb95b32a7941f3fc.zip |
Merge pull request #3999 from orestisfl/cmd_focus_sibling_workspace_crash
cmd_focus_sibling: Fix crash on workspace level
-rw-r--r-- | src/commands.c | 11 | ||||
-rw-r--r-- | testcases/t/307-focus-next-prev.t | 12 |
2 files changed, 22 insertions, 1 deletions
diff --git a/src/commands.c b/src/commands.c index 897ba288..14bd877d 100644 --- a/src/commands.c +++ b/src/commands.c @@ -1299,7 +1299,16 @@ void cmd_focus_sibling(I3_CMD, const char *direction_str) { } Con *next = get_tree_next_sibling(current->con, direction); if (next) { - con_activate(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); + } } } diff --git a/testcases/t/307-focus-next-prev.t b/testcases/t/307-focus-next-prev.t index c7f06589..4f8a8ecd 100644 --- a/testcases/t/307-focus-next-prev.t +++ b/testcases/t/307-focus-next-prev.t @@ -69,4 +69,16 @@ cmp_tree( 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; |