Skip to content
This repository has been archived by the owner on Apr 18, 2023. It is now read-only.

Commit

Permalink
Merge pull request #4125 from orestisfl/move-fullscreen-to-ws
Browse files Browse the repository at this point in the history
_con_move_to_con: Traverse below con to check for fullscreen
  • Loading branch information
Airblader committed Jun 10, 2020
2 parents f4964fa + 4d9c313 commit cf09cc7
Show file tree
Hide file tree
Showing 3 changed files with 58 additions and 2 deletions.
1 change: 1 addition & 0 deletions RELEASE-NOTES-next
Expand Up @@ -43,3 +43,4 @@ working. Please reach out to us in that case!
• build: fix issues with parallel build
• set _NET_DESKTOP_VIEWPORT after randr changes
• fix a bug with i3-nagbar not starting after it has already started once
• fix conflict when moving parent of fullscreen window to workspace
12 changes: 10 additions & 2 deletions src/con.c
Expand Up @@ -1261,9 +1261,17 @@ static bool _con_move_to_con(Con *con, Con *target, bool behind_focused, bool fi
}

/* If moving a fullscreen container and the destination already has a
* fullscreen window on it, un-fullscreen the target's fullscreen con. */
* fullscreen window on it, un-fullscreen the target's fullscreen con.
* con->fullscreen_mode is not enough in some edge cases:
* 1. con is CT_FLOATING_CON, child is fullscreen.
* 2. con is the parent of a fullscreen container, can be triggered by
* moving the parent with command criteria.
*/
Con *fullscreen = con_get_fullscreen_con(target_ws, CF_OUTPUT);
if (con->fullscreen_mode != CF_NONE && fullscreen != NULL) {
const bool con_has_fullscreen = con->fullscreen_mode != CF_NONE ||
con_get_fullscreen_con(con, CF_GLOBAL) ||
con_get_fullscreen_con(con, CF_OUTPUT);
if (con_has_fullscreen && fullscreen != NULL) {
con_toggle_fullscreen(fullscreen, CF_OUTPUT);
fullscreen = NULL;
}
Expand Down
47 changes: 47 additions & 0 deletions testcases/t/132-move-workspace.t
Expand Up @@ -339,6 +339,53 @@ $ws = get_ws($tmp2);
is_num_children($tmp2, 0, 'no regular nodes on second workspace');
is(@{$ws->{floating_nodes}}, 1, 'one floating node on second workspace');

###################################################################
# Test that when moving a fullscreen floating window to a workspace
# that already has an other fullscreen container, the second
# container gets un-fullscreened.
# See #4124
###################################################################
$tmp2 = fresh_workspace;
$second = open_window;
cmd 'fullscreen enable';
$ws = get_ws($tmp2);
is($ws->{nodes}->[0]->{fullscreen_mode}, 1, 'sanity check: fullscreen enabled');

$tmp = fresh_workspace;
$first = open_window;
cmd 'floating enable, fullscreen enable';
cmd "move workspace $tmp2";

$ws = get_ws($tmp2);
is_num_children($tmp2, 1, 'one regular node on second workspace');
is_num_fullscreen($tmp2, 1, 'one fullscreen node on second workspace');
is(@{$ws->{floating_nodes}}, 1, 'one floating node on second workspace');
is($ws->{nodes}->[0]->{fullscreen_mode}, 0, 'previous fullscreen disabled');

###################################################################
# Same as above, but trigger the bug with the parent of a
# fullscreen container, instead of a CT_FLOATING_CON.
###################################################################
$tmp2 = fresh_workspace;
$second = open_window;
cmd 'fullscreen enable';
$ws = get_ws($tmp2);
is($ws->{nodes}->[0]->{fullscreen_mode}, 1, 'sanity check: fullscreen enabled');

$tmp = fresh_workspace;
open_window;
$first = open_window;
cmd 'layout tabbed';
cmd 'focus parent, mark a, focus child';
cmd 'fullscreen enable';
cmd "[con_mark=a] move workspace $tmp2";

$ws = get_ws($tmp2);
is(sum_nodes(get_ws_content($tmp2)), 4, '3 leafs & 1 split node in second workspace');
# is_num_fullscreen does not catch this nested fullscreen container
is($ws->{nodes}->[0]->{fullscreen_mode}, 0, 'previous fullscreen disabled');
is($ws->{nodes}->[1]->{nodes}->[1]->{fullscreen_mode}, 1, 'nested fullscreen from moved container preserved');

###################################################################
# Check that moving an empty workspace using criteria doesn't
# create unfocused empty workspace.
Expand Down

0 comments on commit cf09cc7

Please sign in to comment.