diff options
author | Orestis Floros <orestisflo@gmail.com> | 2023-04-02 18:55:21 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-04-02 18:55:21 +0200 |
commit | 74785f479582c885b871b209b79c3a637021357e (patch) | |
tree | 78df4a63bb6a1c44e2218d85daf211d76f4056d9 | |
parent | d7583fbc179b856d489d4b9fadabd440cea16a45 (diff) | |
download | i3-74785f479582c885b871b209b79c3a637021357e.tar.gz i3-74785f479582c885b871b209b79c3a637021357e.zip |
Allow switching workspaces when in global fullscreen mode (#5398)
Fixes #2974
-rw-r--r-- | release-notes/changes/3-global-fullscreen | 1 | ||||
-rw-r--r-- | src/commands.c | 27 | ||||
-rw-r--r-- | testcases/t/100-fullscreen.t | 12 |
3 files changed, 19 insertions, 21 deletions
diff --git a/release-notes/changes/3-global-fullscreen b/release-notes/changes/3-global-fullscreen new file mode 100644 index 00000000..e09aaf44 --- /dev/null +++ b/release-notes/changes/3-global-fullscreen @@ -0,0 +1 @@ +Allow switching workspaces when in global fullscreen mode diff --git a/src/commands.c b/src/commands.c index a2f42dce..b5bc2416 100644 --- a/src/commands.c +++ b/src/commands.c @@ -844,6 +844,13 @@ out: free(buf); } +static void disable_global_fullscreen(void) { + Con *fs = con_get_fullscreen_con(croot, CF_GLOBAL); + if (fs) { + con_disable_fullscreen(fs); + } +} + /* * Implementation of 'workspace next|prev|next_on_output|prev_on_output'. * @@ -853,10 +860,7 @@ void cmd_workspace(I3_CMD, const char *which) { DLOG("which=%s\n", which); - if (con_get_fullscreen_con(croot, CF_GLOBAL)) { - yerror("Cannot switch workspace while in global fullscreen"); - return; - } + disable_global_fullscreen(); if (strcmp(which, "next") == 0) ws = workspace_next(); @@ -885,10 +889,7 @@ void cmd_workspace(I3_CMD, const char *which) { void cmd_workspace_number(I3_CMD, const char *which, const char *_no_auto_back_and_forth) { const bool no_auto_back_and_forth = (_no_auto_back_and_forth != NULL); - if (con_get_fullscreen_con(croot, CF_GLOBAL)) { - yerror("Cannot switch workspace while in global fullscreen"); - return; - } + disable_global_fullscreen(); long parsed_num = ws_name_to_number(which); if (parsed_num == -1) { @@ -920,10 +921,7 @@ void cmd_workspace_number(I3_CMD, const char *which, const char *_no_auto_back_a * */ void cmd_workspace_back_and_forth(I3_CMD) { - if (con_get_fullscreen_con(croot, CF_GLOBAL)) { - yerror("Cannot switch workspace while in global fullscreen"); - return; - } + disable_global_fullscreen(); workspace_back_and_forth(); @@ -944,10 +942,7 @@ void cmd_workspace_name(I3_CMD, const char *name, const char *_no_auto_back_and_ return; } - if (con_get_fullscreen_con(croot, CF_GLOBAL)) { - yerror("Cannot switch workspace while in global fullscreen"); - return; - } + disable_global_fullscreen(); DLOG("should switch to workspace %s\n", name); if (!no_auto_back_and_forth && maybe_back_and_forth(cmd_output, name)) { diff --git a/testcases/t/100-fullscreen.t b/testcases/t/100-fullscreen.t index d817bee0..a14cb8ba 100644 --- a/testcases/t/100-fullscreen.t +++ b/testcases/t/100-fullscreen.t @@ -185,7 +185,9 @@ cmd 'focus left'; is($x->input_focus, $window->id, 'fullscreen window still focused'); ################################################################################ -# Verify that changing workspace while in global fullscreen does not work. +# Verify that changing workspace while in global fullscreen disables fullscreen +# first. +# See #2974 ################################################################################ $tmp = fresh_workspace; @@ -197,11 +199,11 @@ is(focused_ws(), $tmp, 'workspace selected'); $other = get_unused_workspace; cmd "workspace $other"; -is($x->input_focus, $window->id, 'window still focused'); -is(focused_ws(), $tmp, 'workspace still selected'); +isnt($x->input_focus, $window->id, 'window not focused anymore'); +is(focused_ws(), $other, 'workspace switched'); +is_num_fullscreen($other, 0, 'no fullscreen windows'); +is_num_fullscreen($tmp, 0, 'no fullscreen windows'); -# leave global fullscreen so that is does not interfere with the other tests -$window->fullscreen(0); sync_with_i3; ################################################################################ |