2010-11-14 21:43:31 +01:00
|
|
|
#!perl
|
|
|
|
# vim:ts=4:sw=4:expandtab
|
|
|
|
|
2011-03-09 20:25:17 +01:00
|
|
|
use i3test;
|
2010-11-14 21:43:31 +01:00
|
|
|
|
2011-03-09 20:25:17 +01:00
|
|
|
my $tmp = fresh_workspace;
|
2010-11-14 21:43:31 +01:00
|
|
|
|
2010-11-14 22:35:44 +01:00
|
|
|
#############################################################################
|
|
|
|
# 1: see if focus stays the same when toggling tiling/floating mode
|
|
|
|
#############################################################################
|
|
|
|
|
2011-03-09 20:25:17 +01:00
|
|
|
cmd "open";
|
|
|
|
cmd "open";
|
2010-11-14 21:43:31 +01:00
|
|
|
|
|
|
|
my @content = @{get_ws_content($tmp)};
|
|
|
|
cmp_ok(@content, '==', 2, 'two containers opened');
|
|
|
|
cmp_ok($content[1]->{focused}, '==', 1, 'Second container focused');
|
|
|
|
|
2011-03-09 20:25:17 +01:00
|
|
|
cmd "mode floating";
|
|
|
|
cmd "mode tiling";
|
2010-11-14 21:43:31 +01:00
|
|
|
|
|
|
|
@content = @{get_ws_content($tmp)};
|
|
|
|
cmp_ok($content[1]->{focused}, '==', 1, 'Second container still focused after mode toggle');
|
2010-11-14 22:35:44 +01:00
|
|
|
|
|
|
|
#############################################################################
|
|
|
|
# 2: see if the focus gets reverted correctly when closing floating clients
|
|
|
|
# (first to the next floating client, then to the last focused tiling client)
|
|
|
|
#############################################################################
|
|
|
|
|
2011-03-09 20:25:17 +01:00
|
|
|
$tmp = fresh_workspace;
|
2010-11-14 22:35:44 +01:00
|
|
|
|
2011-03-09 20:25:17 +01:00
|
|
|
cmd "open";
|
|
|
|
cmd "open";
|
|
|
|
cmd "open";
|
2010-11-14 22:35:44 +01:00
|
|
|
|
|
|
|
@content = @{get_ws_content($tmp)};
|
|
|
|
cmp_ok(@content, '==', 3, 'two containers opened');
|
|
|
|
cmp_ok($content[2]->{focused}, '==', 1, 'Last container focused');
|
|
|
|
|
|
|
|
my $last_id = $content[2]->{id};
|
|
|
|
my $second_id = $content[1]->{id};
|
|
|
|
my $first_id = $content[0]->{id};
|
|
|
|
diag("last_id = $last_id, second_id = $second_id, first_id = $first_id");
|
|
|
|
|
2011-03-09 20:25:17 +01:00
|
|
|
cmd qq|[con_id="$second_id"] focus|;
|
2010-11-14 22:35:44 +01:00
|
|
|
@content = @{get_ws_content($tmp)};
|
|
|
|
cmp_ok($content[1]->{focused}, '==', 1, 'Second container focused');
|
|
|
|
|
2011-03-09 20:25:17 +01:00
|
|
|
cmd "mode floating";
|
2010-11-14 22:35:44 +01:00
|
|
|
|
2011-03-09 20:25:17 +01:00
|
|
|
cmd qq|[con_id="$last_id"] focus|;
|
2010-11-14 22:35:44 +01:00
|
|
|
@content = @{get_ws_content($tmp)};
|
|
|
|
cmp_ok($content[1]->{focused}, '==', 1, 'Last container focused');
|
|
|
|
|
2011-03-09 20:25:17 +01:00
|
|
|
cmd "mode floating";
|
2010-11-14 22:35:44 +01:00
|
|
|
|
|
|
|
diag("focused = " . get_focused($tmp));
|
|
|
|
|
2011-03-09 20:25:17 +01:00
|
|
|
cmd "kill";
|
2010-11-14 22:35:44 +01:00
|
|
|
|
|
|
|
diag("focused = " . get_focused($tmp));
|
|
|
|
# TODO: this test result is actually not right. the focus reverts to where the mouse pointer is.
|
|
|
|
cmp_ok(get_focused($tmp), '==', $second_id, 'Focus reverted to second floating container');
|
|
|
|
|
2011-03-09 20:25:17 +01:00
|
|
|
cmd "kill";
|
2010-11-14 22:35:44 +01:00
|
|
|
@content = @{get_ws_content($tmp)};
|
|
|
|
cmp_ok($content[0]->{focused}, '==', 1, 'Focus reverted to tiling container');
|
2011-03-09 20:25:17 +01:00
|
|
|
|
|
|
|
done_testing;
|