Skip to content

Commit

Permalink
Allow switching workspaces when in global fullscreen mode (#5398)
Browse files Browse the repository at this point in the history
Fixes #2974
  • Loading branch information
orestisfl committed Apr 2, 2023
1 parent d7583fb commit 74785f4
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 21 deletions.
1 change: 1 addition & 0 deletions release-notes/changes/3-global-fullscreen
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Allow switching workspaces when in global fullscreen mode
27 changes: 11 additions & 16 deletions src/commands.c
Original file line number Diff line number Diff line change
Expand Up @@ -844,6 +844,13 @@ void cmd_append_layout(I3_CMD, const char *cpath) {
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'.
*
Expand All @@ -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();
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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();

Expand All @@ -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)) {
Expand Down
12 changes: 7 additions & 5 deletions testcases/t/100-fullscreen.t
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;

################################################################################
Expand Down

0 comments on commit 74785f4

Please sign in to comment.