From d7e5da8b39ec8279588cc60c28dabd2272a6795d Mon Sep 17 00:00:00 2001 From: Deiz Date: Thu, 4 Oct 2012 04:22:41 -0400 Subject: [PATCH] Un-fullscreen as needed when moving fullscreen containers This avoids a case where a fullscreen container could be moved onto a workspace that already had its own fullscreen container, leading to two fullscreen containers on top of each other. --- src/con.c | 11 +++++++++-- testcases/t/100-fullscreen.t | 28 +++++++++++++++++++++++++++- 2 files changed, 36 insertions(+), 3 deletions(-) diff --git a/src/con.c b/src/con.c index 77608489..1389bf53 100644 --- a/src/con.c +++ b/src/con.c @@ -696,6 +696,14 @@ void con_move_to_workspace(Con *con, Con *workspace, bool fix_coordinates, bool } } + /* If moving a fullscreen container and the destination already has a + * fullscreen window on it, un-fullscreen the target's fullscreen con. */ + Con *fullscreen = con_get_fullscreen_con(workspace, CF_OUTPUT); + if (con->fullscreen_mode != CF_NONE && fullscreen != NULL) { + con_toggle_fullscreen(fullscreen, CF_OUTPUT); + fullscreen = NULL; + } + DLOG("Re-attaching container to %p / %s\n", next, next->name); /* 5: re-attach the con to the parent of this focused container */ Con *parent = con->parent; @@ -712,8 +720,7 @@ void con_move_to_workspace(Con *con, Con *workspace, bool fix_coordinates, bool * invisible. * We don’t focus the con for i3 pseudo workspaces like __i3_scratch and * we don’t focus when there is a fullscreen con on that workspace. */ - if (!con_is_internal(workspace) && - con_get_fullscreen_con(workspace, CF_OUTPUT) == NULL) { + if (!con_is_internal(workspace) && !fullscreen) { /* We need to save the focused workspace on the output in case the * new workspace is hidden and it's necessary to immediately switch * back to the originally-focused workspace. */ diff --git a/testcases/t/100-fullscreen.t b/testcases/t/100-fullscreen.t index 81a97d06..cec7000a 100644 --- a/testcases/t/100-fullscreen.t +++ b/testcases/t/100-fullscreen.t @@ -22,7 +22,10 @@ my $i3 = i3(get_socket_path()); my $tmp = fresh_workspace; sub fullscreen_windows { - scalar grep { $_->{fullscreen_mode} != 0 } @{get_ws_content($tmp)} + my $ws = $tmp; + $ws = shift if @_; + + scalar grep { $_->{fullscreen_mode} != 0 } @{get_ws_content($ws)} } # get the output of this workspace @@ -188,4 +191,27 @@ is($x->input_focus, $window->id, 'fullscreen window focused'); cmd 'focus left'; is($x->input_focus, $window->id, 'fullscreen window still focused'); +################################################################################ +# Verify that fullscreening a window on a second workspace and moving it onto +# the first workspace unfullscreens the first window. +################################################################################ + +my $tmp2 = fresh_workspace; +$swindow = open_window; + +cmd 'fullscreen'; + +is(fullscreen_windows($tmp2), 1, 'one fullscreen window on second ws'); + +cmd "move workspace $tmp"; + +is(fullscreen_windows($tmp2), 0, 'no fullscreen windows on second ws'); +is(fullscreen_windows($tmp), 1, 'one fullscreen window on first ws'); + +$swindow->fullscreen(0); +sync_with_i3; + +# Verify that $swindow was the one that initially remained fullscreen. +is(fullscreen_windows($tmp), 0, 'no fullscreen windows on first ws'); + done_testing;