From fffc53c24655ef626b18763bae8c3e5950400f5c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fernando=20Tarl=C3=A1=20Cardoso=20Lemos?= Date: Sat, 26 May 2012 22:13:16 -0300 Subject: [PATCH] Restrict "move to workspace" commands in fullscreen. --- src/con.c | 6 ++++ testcases/t/156-fullscreen-focus.t | 49 ++++++++++++++++++++++++++---- 2 files changed, 49 insertions(+), 6 deletions(-) diff --git a/src/con.c b/src/con.c index a7ae642b..a1491e03 100644 --- a/src/con.c +++ b/src/con.c @@ -576,6 +576,12 @@ void con_move_to_workspace(Con *con, Con *workspace, bool fix_coordinates, bool return; } + /* Prevent moving if this would violate the fullscreen focus restrictions. */ + if (!con_fullscreen_permits_focusing(workspace)) { + LOG("Cannot move out of a fullscreen container"); + return; + } + if (con_is_floating(con)) { DLOG("Using FLOATINGCON instead\n"); con = con->parent; diff --git a/testcases/t/156-fullscreen-focus.t b/testcases/t/156-fullscreen-focus.t index af205c45..b779ce7d 100644 --- a/testcases/t/156-fullscreen-focus.t +++ b/testcases/t/156-fullscreen-focus.t @@ -237,22 +237,59 @@ 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 { +sub verify_move { + my $num = shift; my $msg = shift; my $nodes = get_ws_content($tmp2); my $split = $nodes->[1]; my $fs = $split->{nodes}->[1]; - is(scalar @{$fs->{nodes}}, 2, $msg); + is(scalar @{$fs->{nodes}}, $num, $msg); } cmd 'move left'; -verify_move_prevented('prevented move left'); +verify_move(2, 'prevented move left'); cmd 'move right'; -verify_move_prevented('prevented move right'); +verify_move(2, 'prevented move right'); cmd 'move down'; -verify_move_prevented('prevented move down'); +verify_move(2, 'prevented move down'); cmd 'move up'; cmd 'move up'; -verify_move_prevented('prevented move up'); +verify_move(2, 'prevented move up'); + +################################################################################ +# Moving to a different workspace is allowed with per-output fullscreen +# containers. +################################################################################ + +cmd "move to workspace $tmp"; +verify_move(1, 'did not prevent move to workspace by name'); + +cmd "workspace $tmp"; +cmd "move to workspace $tmp2"; +cmd "workspace $tmp2"; + +cmd "move to workspace prev"; +verify_move(1, 'did not prevent move to workspace by position'); + +################################################################################ +# Ensure that is not allowed with global fullscreen containers. +################################################################################ + +cmd "workspace $tmp"; +cmd "move to workspace $tmp2"; +cmd "workspace $tmp2"; + +cmd 'focus parent'; +cmd 'fullscreen'; +cmd 'fullscreen global'; +cmd 'focus child'; + +cmd "move to workspace $tmp"; +verify_move(2, 'prevented move to workspace by name'); + +cmd "move to workspace prev"; +verify_move(2, 'prevented move to workspace by position'); + +# TODO: Tests for "move to output" and "move workspace to output". done_testing;