From 8bf4e9e05965a1bbcada062026a214c4356c4162 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Fernando=20Tarl=C3=A1=20Cardoso=20Lemos?= Date: Sat, 26 May 2012 19:53:02 -0300 Subject: [PATCH] Restrict directional focus in fullscreen. This reuses the same fullscreen focus logic to ensure that focus doesn't escape a fullscreen container. --- src/tree.c | 4 ++ testcases/t/156-fullscreen-focus.t | 73 ++++++++++++++++++++++++++++++ 2 files changed, 77 insertions(+) diff --git a/src/tree.c b/src/tree.c index cb3d044a..3ed392ac 100644 --- a/src/tree.c +++ b/src/tree.c @@ -556,6 +556,10 @@ static bool _tree_next(Con *con, char way, orientation_t orientation, bool wrap) else next = TAILQ_LAST(&(parent->nodes_head), nodes_head); } + /* Don't violate fullscreen focus restrictions. */ + if (!con_fullscreen_permits_focusing(next)) + return false; + /* 3: focus choice comes in here. at the moment we will go down * until we find a window */ /* TODO: check for window, atm we only go down as far as possible */ diff --git a/testcases/t/156-fullscreen-focus.t b/testcases/t/156-fullscreen-focus.t index 65d23815..f76588f9 100644 --- a/testcases/t/156-fullscreen-focus.t +++ b/testcases/t/156-fullscreen-focus.t @@ -131,6 +131,24 @@ is($x->input_focus, $right2->id, 'bottom right window focused again'); cmd '[id="' . $left->id . '"] focus'; is($x->input_focus, $right2->id, 'prevented focus change to left window'); +cmd 'focus up'; +is($x->input_focus, $right1->id, 'allowed focus up'); + +cmd 'focus down'; +is($x->input_focus, $right2->id, 'allowed focus down'); + +cmd 'focus left'; +is($x->input_focus, $right2->id, 'prevented focus left'); + +cmd 'focus right'; +is($x->input_focus, $right2->id, 'prevented focus right'); + +cmd 'focus down'; +is($x->input_focus, $right1->id, 'allowed focus wrap (down)'); + +cmd 'focus up'; +is($x->input_focus, $right2->id, 'allowed focus wrap (up)'); + cmd '[id="' . $diff_ws->id . '"] focus'; is($x->input_focus, $right2->id, 'prevented focus change to different ws'); @@ -158,7 +176,62 @@ is($x->input_focus, $right2->id, 'bottom right window focused again'); cmd '[id="' . $left->id . '"] focus'; is($x->input_focus, $right2->id, 'prevented focus change to left window'); +cmd 'focus up'; +is($x->input_focus, $right1->id, 'allowed focus up'); + +cmd 'focus down'; +is($x->input_focus, $right2->id, 'allowed focus down'); + +cmd 'focus left'; +is($x->input_focus, $right2->id, 'prevented focus left'); + +cmd 'focus right'; +is($x->input_focus, $right2->id, 'prevented focus right'); + +cmd 'focus down'; +is($x->input_focus, $right1->id, 'allowed focus wrap (down)'); + +cmd 'focus up'; +is($x->input_focus, $right2->id, 'allowed focus wrap (up)'); + cmd '[id="' . $diff_ws->id . '"] focus'; is($x->input_focus, $diff_ws->id, 'allowed focus change to different ws'); +################################################################################ +# More testing of the interaction between wrapping and the fullscreen focus +# restrictions. +################################################################################ + +cmd '[id="' . $right1->id . '"] focus'; +is($x->input_focus, $right1->id, 'upper right window focused'); + +cmd 'focus parent'; +cmd 'fullscreen'; +cmd 'focus child'; + +cmd 'split v'; +my $right12 = open_window; + +cmd 'focus down'; +is($x->input_focus, $right2->id, 'bottom right window focused'); + +cmd 'split v'; +my $right22 = open_window; + +cmd 'focus parent'; +cmd 'fullscreen'; +cmd 'focus child'; + +cmd 'focus down'; +is($x->input_focus, $right2->id, 'focus did not leave parent container (1)'); + +cmd 'focus down'; +is($x->input_focus, $right22->id, 'focus did not leave parent container (2)'); + +cmd 'focus up'; +is($x->input_focus, $right2->id, 'focus did not leave parent container (3)'); + +cmd 'focus up'; +is($x->input_focus, $right22->id, 'focus did not leave parent container (4)'); + done_testing; -- 2.39.5