From 4452bfb942d06d76e5fc317b50b99872ec086059 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fernando=20Tarl=C3=A1=20Cardoso=20Lemos?= Date: Sat, 26 May 2012 21:45:15 -0300 Subject: [PATCH] Prevent moving out of fullscreen containers. --- src/move.c | 6 ++++++ testcases/t/156-fullscreen-focus.t | 23 ++++++++++++++++++++++- 2 files changed, 28 insertions(+), 1 deletion(-) diff --git a/src/move.c b/src/move.c index d3065c24..d110312a 100644 --- a/src/move.c +++ b/src/move.c @@ -169,6 +169,12 @@ void tree_move(int direction) { while (above->parent != same_orientation) above = above->parent; + /* Enforce the fullscreen focus restrictions. */ + if (!con_fullscreen_permits_focusing(above->parent)) { + LOG("Cannot move out of fullscreen container\n"); + return; + } + DLOG("above = %p\n", above); Con *next; position_t position; diff --git a/testcases/t/156-fullscreen-focus.t b/testcases/t/156-fullscreen-focus.t index f76588f9..af205c45 100644 --- a/testcases/t/156-fullscreen-focus.t +++ b/testcases/t/156-fullscreen-focus.t @@ -111,7 +111,6 @@ $left = open_window; my $right1 = open_window; cmd 'split v'; my $right2 = open_window; -$nodes = get_ws_content($tmp); cmd 'focus parent'; cmd 'fullscreen global'; @@ -234,4 +233,26 @@ 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)'); +################################################################################ +# Ensure that moving in a direction doesn't violate the focus restrictions. +################################################################################ + +sub verify_move_prevented { + my $msg = shift; + my $nodes = get_ws_content($tmp2); + my $split = $nodes->[1]; + my $fs = $split->{nodes}->[1]; + is(scalar @{$fs->{nodes}}, 2, $msg); +} + +cmd 'move left'; +verify_move_prevented('prevented move left'); +cmd 'move right'; +verify_move_prevented('prevented move right'); +cmd 'move down'; +verify_move_prevented('prevented move down'); +cmd 'move up'; +cmd 'move up'; +verify_move_prevented('prevented move up'); + done_testing;