_con_move_to_con: Traverse below con to check for fullscreen

Fixes #4124
This commit is contained in:
Orestis Floros 2020-06-10 03:38:30 +02:00
parent f4964faef0
commit 4d9c3131ad
No known key found for this signature in database
GPG Key ID: A09DBD7D3222C1C3
3 changed files with 58 additions and 2 deletions

View File

@ -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

View File

@ -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;
}

View File

@ -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.