From f78caf8c5815ae7a66de9e4b734546fd740cc19d Mon Sep 17 00:00:00 2001 From: Michael Stapelberg Date: Sat, 7 Jan 2012 18:18:36 +0000 Subject: [PATCH] =?utf8?q?Bugfix:=20Don=E2=80=99t=20lose=20focus=20on=20fu?= =?utf8?q?llscreen=20windows=20when=20another=20window=20gets=20moved=20to?= =?utf8?q?=20that=20workspace=20(+test)=20(Thanks=20rami)?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Fixes: #606 --- src/con.c | 6 ++++-- testcases/t/156-fullscreen-focus.t | 26 ++++++++++++++++++++++++++ 2 files changed, 30 insertions(+), 2 deletions(-) diff --git a/src/con.c b/src/con.c index 7b5cc499..bf22be84 100644 --- a/src/con.c +++ b/src/con.c @@ -656,8 +656,10 @@ void con_move_to_workspace(Con *con, Con *workspace, bool fix_coordinates, bool con_fix_percent(next); /* 7: focus the con on the target workspace (the X focus is only updated by - * calling tree_render(), so for the "real" focus this is a no-op). */ - con_focus(con_descend_focused(con)); + * calling tree_render(), so for the "real" focus this is a no-op). + * We don’t focus when there is a fullscreen con on that workspace. */ + if (con_get_fullscreen_con(workspace, CF_OUTPUT) == NULL) + con_focus(con_descend_focused(con)); /* 8: when moving to a visible workspace on a different output, we keep the * con focused. Otherwise, we leave the focus on the current workspace as we diff --git a/testcases/t/156-fullscreen-focus.t b/testcases/t/156-fullscreen-focus.t index a559b5a5..3f08effd 100644 --- a/testcases/t/156-fullscreen-focus.t +++ b/testcases/t/156-fullscreen-focus.t @@ -68,4 +68,30 @@ sync_with_i3($x); is($x->input_focus, $third->id, 'third window focused'); +################################################################################ +# Ensure that moving a window to a workspace which has a fullscreen window does +# not focus it (otherwise the user cannot get out of fullscreen mode anymore). +################################################################################ + +$tmp = fresh_workspace; + +my $fullscreen_window = open_window; +cmd 'fullscreen'; + +my $nodes = get_ws_content($tmp); +is(scalar @$nodes, 1, 'precisely one window'); +is($nodes->[0]->{focused}, 1, 'fullscreen window focused'); +my $old_id = $nodes->[0]->{id}; + +$tmp2 = fresh_workspace; +my $move_window = open_window; +cmd "move workspace $tmp"; + +cmd "workspace $tmp"; + +$nodes = get_ws_content($tmp); +is(scalar @$nodes, 2, 'precisely two windows'); +is($nodes->[0]->{id}, $old_id, 'id unchanged'); +is($nodes->[0]->{focused}, 1, 'fullscreen window focused'); + done_testing; -- 2.39.5