From 98c4cc46e4778a807f151b6a0ce26cc982fc168b Mon Sep 17 00:00:00 2001 From: jj Date: Fri, 27 Sep 2013 11:03:52 +0200 Subject: [PATCH] Do not resize/reposition floating containers when moving them to scratchpad --- src/scratchpad.c | 8 +++++++- testcases/t/185-scratchpad.t | 25 +++++++++++++++++++++++++ 2 files changed, 32 insertions(+), 1 deletion(-) diff --git a/src/scratchpad.c b/src/scratchpad.c index ce3d9b9b..17df77dd 100644 --- a/src/scratchpad.c +++ b/src/scratchpad.c @@ -66,7 +66,13 @@ void scratchpad_move(Con *con) { * adjusted in size according to what the user specifies. */ if (con->scratchpad_state == SCRATCHPAD_NONE) { DLOG("This window was never used as a scratchpad before.\n"); - con->scratchpad_state = SCRATCHPAD_FRESH; + if (con == maybe_floating_con) { + DLOG("It was in floating mode before, set scratchpad state to changed.\n"); + con->scratchpad_state = SCRATCHPAD_CHANGED; + } else { + DLOG("It was in tiling mode before, set scratchpad state to fresh.\n"); + con->scratchpad_state = SCRATCHPAD_FRESH; + } } } diff --git a/testcases/t/185-scratchpad.t b/testcases/t/185-scratchpad.t index 6ee877bd..5901f99c 100644 --- a/testcases/t/185-scratchpad.t +++ b/testcases/t/185-scratchpad.t @@ -446,4 +446,29 @@ is(get_focused($ws), $scratch, 'scratchpad is focused'); # TODO: make i3bar display *something* when a window on the scratchpad has the urgency hint +################################################################################ +# 14: Verify that 'move scratchpad' sends floating containers to scratchpad but +# does not resize/resposition the container on the next 'scratchpad show', i.e., +# i3 sets the scratchpad flag to SCRATCHPAD_CHANGED +################################################################################ + +clear_scratchpad; +$tmp = fresh_workspace; +open_window; + +($nodes, $focus) = get_ws_content($tmp); +is(scalar @$nodes, 1, 'precisely one window on current ws'); +is($nodes->[0]->{scratchpad_state}, 'none', 'scratchpad_state none'); + +cmd 'floating toggle'; +cmd 'move scratchpad'; + +$__i3_scratch = get_ws('__i3_scratch'); +@scratch_nodes = @{$__i3_scratch->{floating_nodes}}; +is(scalar @scratch_nodes, 1, '__i3_scratch contains our window'); +($nodes, $focus) = get_ws_content($tmp); +is(scalar @$nodes, 0, 'no window on current ws anymore'); + +is($scratch_nodes[0]->{scratchpad_state}, 'changed', 'scratchpad_state changed'); + done_testing; -- 2.39.5