From 95d4ce3ed6f7a5cf8c85445a0d9e95f9cc988458 Mon Sep 17 00:00:00 2001 From: Orestis Floros Date: Thu, 17 Oct 2019 18:14:21 +0300 Subject: [PATCH] scratchpad_move: un-fullscreen correct container Fixes https://github.com/i3/i3/issues/2857#issuecomment-496264445 --- src/scratchpad.c | 4 +-- testcases/t/206-fullscreen-scratchpad.t | 43 ++++++++++++++++++++----- 2 files changed, 36 insertions(+), 11 deletions(-) diff --git a/src/scratchpad.c b/src/scratchpad.c index b74e4a6f..261a8bfd 100644 --- a/src/scratchpad.c +++ b/src/scratchpad.c @@ -40,9 +40,7 @@ void scratchpad_move(Con *con) { /* If the current con is in fullscreen mode, we need to disable that, * as a scratchpad window should never be in fullscreen mode */ - if (focused && focused->type != CT_WORKSPACE && focused->fullscreen_mode != CF_NONE) { - con_toggle_fullscreen(focused, CF_OUTPUT); - } + con_disable_fullscreen(con); /* 1: Ensure the window or any parent is floating. From now on, we deal * with the CT_FLOATING_CON. We use automatic == false because the user diff --git a/testcases/t/206-fullscreen-scratchpad.t b/testcases/t/206-fullscreen-scratchpad.t index 95245099..cd7c4919 100644 --- a/testcases/t/206-fullscreen-scratchpad.t +++ b/testcases/t/206-fullscreen-scratchpad.t @@ -21,9 +21,10 @@ use i3test; my $tmp = fresh_workspace; -########################################################################################## -# map two windows in one container, fullscreen one of them and then move it to scratchpad -########################################################################################## +############################################################################### +# map two windows in one container, fullscreen one of them and then move it to +# scratchpad +############################################################################### my $first_win = open_window; my $second_win = open_window; @@ -50,9 +51,10 @@ cmd 'floating toggle'; # see if no window is in fullscreen mode is_num_fullscreen($tmp, 0, 'amount of fullscreen windows after showing previously fullscreened scratchpad window'); -######################################################################################## -# move a window to scratchpad, focus parent container, make it fullscreen, focus a child -######################################################################################## +############################################################################### +# move a window to scratchpad, focus parent container, make it fullscreen, +# focus a child +############################################################################### # make layout tabbed cmd 'layout tabbed'; @@ -72,9 +74,9 @@ cmd 'focus child'; # see if the window really is in fullscreen mode is_num_fullscreen($tmp, 1, 'amount of fullscreen windows after enabling fullscreen on parent'); -########################################################################## +############################################################################### # show a scratchpad window; no window should be in fullscreen mode anymore -########################################################################## +############################################################################### # show the scratchpad window cmd 'scratchpad show'; @@ -82,4 +84,29 @@ cmd 'scratchpad show'; # see if no window is in fullscreen mode is_num_fullscreen($tmp, 0, 'amount of fullscreen windows after showing a scratchpad window while a parent container was in fullscreen mode'); +############################################################################### +# Moving window to scratchpad with command criteria does not unfullscreen +# currently focused container +# See https://github.com/i3/i3/issues/2857#issuecomment-496264445 +############################################################################### + +kill_all_windows; +$tmp = fresh_workspace; + +$first_win = open_window; +$second_win = open_window; +cmd 'fullscreen'; +cmd '[id=' . $first_win->id . '] move scratchpad'; + +is_num_fullscreen($tmp, 1, 'second window still fullscreen'); +my $__i3_scratch = get_ws('__i3_scratch'); +my @scratch_nodes = @{$__i3_scratch->{floating_nodes}}; +is(scalar @scratch_nodes, 1, 'one window in scratchpad'); + +cmd '[id=' . $first_win->id . '] scratchpad show'; +is_num_fullscreen($tmp, 0, 'second window not fullscreen'); +$__i3_scratch = get_ws('__i3_scratch'); +@scratch_nodes = @{$__i3_scratch->{floating_nodes}}; +is(scalar @scratch_nodes, 0, 'windows in scratchpad'); + done_testing;