2010-11-14 21:43:31 +01:00
|
|
|
#!perl
|
|
|
|
# vim:ts=4:sw=4:expandtab
|
2012-09-10 14:09:01 +02:00
|
|
|
#
|
|
|
|
# Please read the following documents before working on tests:
|
2017-09-24 10:19:50 +02:00
|
|
|
# • https://build.i3wm.org/docs/testsuite.html
|
2012-09-10 14:09:01 +02:00
|
|
|
# (or docs/testsuite)
|
|
|
|
#
|
2017-09-24 10:19:50 +02:00
|
|
|
# • https://build.i3wm.org/docs/lib-i3test.html
|
2012-09-10 14:09:01 +02:00
|
|
|
# (alternatively: perldoc ./testcases/lib/i3test.pm)
|
|
|
|
#
|
2017-09-24 10:19:50 +02:00
|
|
|
# • https://build.i3wm.org/docs/ipc.html
|
2012-09-10 14:09:01 +02:00
|
|
|
# (or docs/ipc)
|
|
|
|
#
|
|
|
|
# • http://onyxneon.com/books/modern_perl/modern_perl_a4.pdf
|
|
|
|
# (unless you are already familiar with Perl)
|
2010-11-14 21:43:31 +01:00
|
|
|
|
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-11-22 00:47:32 +01:00
|
|
|
my $first = open_window;
|
|
|
|
my $second = open_window;
|
2011-09-23 21:37:45 +02:00
|
|
|
|
2011-05-13 19:27:18 +02:00
|
|
|
is($x->input_focus, $second->id, 'second window focused');
|
2010-11-14 21:43:31 +01:00
|
|
|
|
2011-07-01 00:37:30 +02:00
|
|
|
cmd 'floating enable';
|
|
|
|
cmd 'floating disable';
|
2010-11-14 21:43:31 +01:00
|
|
|
|
2011-05-13 19:27:18 +02:00
|
|
|
is($x->input_focus, $second->id, 'second window still focused after mode toggle');
|
2010-11-14 22:35:44 +01:00
|
|
|
|
|
|
|
#############################################################################
|
2011-05-13 19:27:18 +02:00
|
|
|
# 2: see if focus stays on the current floating window if killing another
|
|
|
|
# floating window
|
|
|
|
#############################################################################
|
|
|
|
|
|
|
|
$tmp = fresh_workspace;
|
|
|
|
|
2011-11-22 00:47:32 +01:00
|
|
|
$first = open_window; # window 2
|
|
|
|
$second = open_window; # window 3
|
|
|
|
my $third = open_window; # window 4
|
2011-09-23 21:37:45 +02:00
|
|
|
|
2011-05-13 19:27:18 +02:00
|
|
|
is($x->input_focus, $third->id, 'last container focused');
|
|
|
|
|
2011-07-01 00:37:30 +02:00
|
|
|
cmd 'floating enable';
|
2011-05-13 19:27:18 +02:00
|
|
|
|
|
|
|
cmd '[id="' . $second->id . '"] focus';
|
|
|
|
|
|
|
|
is($x->input_focus, $second->id, 'second con focused');
|
|
|
|
|
2011-07-01 00:37:30 +02:00
|
|
|
cmd 'floating enable';
|
2011-05-13 19:27:18 +02:00
|
|
|
|
|
|
|
# now kill the third one (it's floating). focus should stay unchanged
|
|
|
|
cmd '[id="' . $third->id . '"] kill';
|
|
|
|
|
2011-11-21 23:44:20 +01:00
|
|
|
wait_for_unmap($third);
|
2011-05-13 19:27:18 +02:00
|
|
|
|
|
|
|
is($x->input_focus, $second->id, 'second con still focused after killing third');
|
|
|
|
|
|
|
|
|
|
|
|
#############################################################################
|
|
|
|
# 3: see if the focus gets reverted correctly when closing floating clients
|
2010-11-14 22:35:44 +01:00
|
|
|
# (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-11-22 00:47:32 +01:00
|
|
|
$first = open_window({ background_color => '#ff0000' }); # window 5
|
|
|
|
$second = open_window({ background_color => '#00ff00' }); # window 6
|
|
|
|
$third = open_window({ background_color => '#0000ff' }); # window 7
|
2011-09-23 21:37:45 +02:00
|
|
|
|
2011-05-13 19:27:18 +02:00
|
|
|
is($x->input_focus, $third->id, 'last container focused');
|
2010-11-14 22:35:44 +01:00
|
|
|
|
2011-07-01 00:37:30 +02:00
|
|
|
cmd 'floating enable';
|
2010-11-14 22:35:44 +01:00
|
|
|
|
2011-05-13 19:27:18 +02:00
|
|
|
cmd '[id="' . $second->id . '"] focus';
|
2010-11-14 22:35:44 +01:00
|
|
|
|
2011-05-13 19:27:18 +02:00
|
|
|
is($x->input_focus, $second->id, 'second con focused');
|
2010-11-14 22:35:44 +01:00
|
|
|
|
2011-07-01 00:37:30 +02:00
|
|
|
cmd 'floating enable';
|
2010-11-14 22:35:44 +01:00
|
|
|
|
2011-05-13 19:27:18 +02:00
|
|
|
# now kill the second one. focus should fall back to the third one, which is
|
|
|
|
# also floating
|
|
|
|
cmd 'kill';
|
2011-11-21 23:44:20 +01:00
|
|
|
wait_for_unmap($second);
|
2010-11-14 22:35:44 +01:00
|
|
|
|
2011-05-13 19:27:18 +02:00
|
|
|
is($x->input_focus, $third->id, 'third con focused');
|
2010-11-14 22:35:44 +01:00
|
|
|
|
2011-05-13 19:27:18 +02:00
|
|
|
cmd 'kill';
|
2011-11-21 23:44:20 +01:00
|
|
|
wait_for_unmap($third);
|
2010-11-14 22:35:44 +01:00
|
|
|
|
2011-05-13 19:27:18 +02:00
|
|
|
is($x->input_focus, $first->id, 'first con focused after killing all floating cons');
|
2011-03-09 20:25:17 +01:00
|
|
|
|
2011-07-01 01:10:43 +02:00
|
|
|
#############################################################################
|
|
|
|
# 4: same test as 3, but with another split con
|
|
|
|
#############################################################################
|
|
|
|
|
|
|
|
$tmp = fresh_workspace;
|
|
|
|
|
2011-11-22 00:47:32 +01:00
|
|
|
$first = open_window({ background_color => '#ff0000' }); # window 5
|
2011-07-01 01:10:43 +02:00
|
|
|
cmd 'split v';
|
|
|
|
cmd 'layout stacked';
|
2011-11-22 00:47:32 +01:00
|
|
|
$second = open_window({ background_color => '#00ff00' }); # window 6
|
|
|
|
$third = open_window({ background_color => '#0000ff' }); # window 7
|
2011-07-01 01:10:43 +02:00
|
|
|
is($x->input_focus, $third->id, 'last container focused');
|
|
|
|
|
|
|
|
cmd '[id="' . $second->id . '"] focus';
|
|
|
|
cmd 'floating enable';
|
2017-09-25 13:00:43 +02:00
|
|
|
cmd '[id="' . $third->id . '"] floating enable';
|
2011-07-01 01:10:43 +02:00
|
|
|
|
2011-11-22 01:13:37 +01:00
|
|
|
sync_with_i3;
|
2017-09-25 13:00:43 +02:00
|
|
|
is($x->input_focus, $second->id, 'second con focused');
|
2011-07-01 01:10:43 +02:00
|
|
|
|
|
|
|
# now kill the second one. focus should fall back to the third one, which is
|
|
|
|
# also floating
|
|
|
|
cmd 'kill';
|
2011-11-21 23:44:20 +01:00
|
|
|
wait_for_unmap($second);
|
2011-07-01 01:10:43 +02:00
|
|
|
|
2011-09-23 21:37:45 +02:00
|
|
|
is($x->input_focus, $third->id, 'third con focused');
|
2011-07-01 01:10:43 +02:00
|
|
|
|
|
|
|
cmd 'kill';
|
2011-11-21 23:44:20 +01:00
|
|
|
wait_for_unmap($third);
|
2011-07-01 01:10:43 +02:00
|
|
|
|
|
|
|
is($x->input_focus, $first->id, 'first con focused after killing all floating cons');
|
|
|
|
|
2011-07-04 17:09:52 +02:00
|
|
|
#############################################################################
|
|
|
|
# 5: see if the 'focus tiling' and 'focus floating' commands work
|
|
|
|
#############################################################################
|
|
|
|
|
|
|
|
$tmp = fresh_workspace;
|
|
|
|
|
2011-11-22 00:47:32 +01:00
|
|
|
$first = open_window({ background_color => '#ff0000' }); # window 8
|
|
|
|
$second = open_window({ background_color => '#00ff00' }); # window 9
|
2011-07-04 17:09:52 +02:00
|
|
|
|
|
|
|
is($x->input_focus, $second->id, 'second container focused');
|
|
|
|
|
|
|
|
cmd 'floating enable';
|
|
|
|
|
|
|
|
is($x->input_focus, $second->id, 'second container focused');
|
|
|
|
|
|
|
|
cmd 'focus tiling';
|
|
|
|
|
|
|
|
is($x->input_focus, $first->id, 'first (tiling) container focused');
|
|
|
|
|
|
|
|
cmd 'focus floating';
|
|
|
|
|
|
|
|
is($x->input_focus, $second->id, 'second (floating) container focused');
|
|
|
|
|
|
|
|
cmd 'focus floating';
|
|
|
|
|
|
|
|
is($x->input_focus, $second->id, 'second (floating) container still focused');
|
|
|
|
|
|
|
|
cmd 'focus mode_toggle';
|
|
|
|
|
|
|
|
is($x->input_focus, $first->id, 'first (tiling) container focused');
|
|
|
|
|
|
|
|
cmd 'focus mode_toggle';
|
|
|
|
|
|
|
|
is($x->input_focus, $second->id, 'second (floating) container focused');
|
|
|
|
|
2011-09-17 20:29:23 +02:00
|
|
|
#############################################################################
|
|
|
|
# 6: see if switching floating focus using the focus left/right command works
|
|
|
|
#############################################################################
|
|
|
|
|
|
|
|
$tmp = fresh_workspace;
|
|
|
|
|
2011-11-22 01:00:54 +01:00
|
|
|
$first = open_floating_window({ background_color => '#ff0000' });# window 10
|
|
|
|
$second = open_floating_window({ background_color => '#00ff00' }); # window 11
|
|
|
|
$third = open_floating_window({ background_color => '#0000ff' }); # window 12
|
2011-09-17 20:29:23 +02:00
|
|
|
|
|
|
|
is($x->input_focus, $third->id, 'third container focused');
|
|
|
|
|
|
|
|
cmd 'focus left';
|
|
|
|
|
|
|
|
is($x->input_focus, $second->id, 'second container focused');
|
|
|
|
|
|
|
|
cmd 'focus left';
|
|
|
|
|
|
|
|
is($x->input_focus, $first->id, 'first container focused');
|
|
|
|
|
|
|
|
cmd 'focus left';
|
|
|
|
|
|
|
|
is($x->input_focus, $third->id, 'focus wrapped to third container');
|
|
|
|
|
|
|
|
cmd 'focus right';
|
|
|
|
|
|
|
|
is($x->input_focus, $first->id, 'focus wrapped to first container');
|
|
|
|
|
|
|
|
cmd 'focus right';
|
|
|
|
|
|
|
|
is($x->input_focus, $second->id, 'focus on second container');
|
2011-07-04 17:09:52 +02:00
|
|
|
|
2012-10-16 17:50:39 +02:00
|
|
|
#############################################################################
|
|
|
|
# 7: verify that focusing the parent of a window inside a floating con goes
|
|
|
|
# up to the grandparent (workspace) and that focusing child from the ws
|
|
|
|
# goes back down to the child of the floating con
|
|
|
|
#############################################################################
|
|
|
|
|
|
|
|
$tmp = fresh_workspace;
|
|
|
|
|
|
|
|
my $tiled = open_window;
|
|
|
|
my $floating = open_floating_window;
|
|
|
|
is($x->input_focus, $floating->id, 'floating window focused');
|
|
|
|
|
|
|
|
cmd 'focus parent';
|
|
|
|
|
|
|
|
is(get_ws($tmp)->{focused}, 1, 'workspace is focused');
|
|
|
|
cmd 'focus child';
|
|
|
|
|
|
|
|
is($x->input_focus, $floating->id, 'floating window focused');
|
|
|
|
|
2017-09-22 21:00:06 +02:00
|
|
|
#############################################################################
|
|
|
|
# 8: verify that focusing a floating window raises it to the top.
|
|
|
|
# This test can't verify that the floating container is visually on top, just
|
|
|
|
# that it is placed on the tail of the floating_head.
|
|
|
|
# See issue: 2572
|
|
|
|
#############################################################################
|
|
|
|
|
|
|
|
$tmp = fresh_workspace;
|
|
|
|
|
|
|
|
$first = open_floating_window;
|
|
|
|
$second = open_floating_window;
|
|
|
|
|
|
|
|
is($x->input_focus, $second->id, 'second floating window focused');
|
|
|
|
my $ws = get_ws($tmp);
|
|
|
|
is($ws->{floating_nodes}->[1]->{nodes}->[0]->{window}, $second->id, 'second on top');
|
|
|
|
is($ws->{floating_nodes}->[0]->{nodes}->[0]->{window}, $first->id, 'first behind');
|
|
|
|
|
|
|
|
cmd '[id=' . $first->id . '] focus';
|
|
|
|
|
|
|
|
is($x->input_focus, $first->id, 'first floating window focused');
|
|
|
|
$ws = get_ws($tmp);
|
|
|
|
is($ws->{floating_nodes}->[1]->{nodes}->[0]->{window}, $first->id, 'first on top');
|
|
|
|
is($ws->{floating_nodes}->[0]->{nodes}->[0]->{window}, $second->id, 'second behind');
|
|
|
|
|
2017-09-15 01:29:08 +02:00
|
|
|
#############################################################################
|
|
|
|
# 9: verify that disabling / enabling floating for a window from a different
|
|
|
|
# workspace maintains the correct focus order.
|
|
|
|
#############################################################################
|
|
|
|
|
|
|
|
sub open_window_helper {
|
|
|
|
my $floating = shift if @_;
|
|
|
|
if ($floating){
|
|
|
|
return open_floating_window;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
return open_window;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
for my $floating (0, 1){
|
|
|
|
$tmp = fresh_workspace;
|
|
|
|
$first = open_window;
|
|
|
|
$second = open_window_helper($floating);
|
|
|
|
is($x->input_focus, $second->id, "second window focused");
|
|
|
|
|
|
|
|
fresh_workspace;
|
|
|
|
cmd "[id=" . $second->id . "] floating toggle";
|
|
|
|
cmd "workspace $tmp";
|
|
|
|
sync_with_i3;
|
|
|
|
|
|
|
|
my $workspace = get_ws($tmp);
|
|
|
|
is($workspace->{floating_nodes}->[0]->{nodes}->[0]->{window}, $second->id, 'second window on first workspace, floating') unless $floating;
|
|
|
|
is($workspace->{nodes}->[1]->{window}, $second->id, 'second window on first workspace, right') unless !$floating;
|
|
|
|
is($x->input_focus, $second->id, 'second window still focused');
|
|
|
|
}
|
|
|
|
|
|
|
|
#############################################################################
|
|
|
|
# 10: verify that toggling floating for an unfocused window on another
|
|
|
|
# workspace doesn't make it focused.
|
|
|
|
#############################################################################
|
|
|
|
|
|
|
|
for my $floating (0, 1){
|
|
|
|
$tmp = fresh_workspace;
|
|
|
|
$first = open_window_helper($floating);
|
|
|
|
$second = open_window;
|
|
|
|
is($x->input_focus, $second->id, 'second (tiling) window focused');
|
|
|
|
|
|
|
|
fresh_workspace;
|
|
|
|
cmd "[id=" . $first->id . "] floating toggle";
|
|
|
|
cmd "workspace $tmp";
|
|
|
|
sync_with_i3;
|
|
|
|
|
|
|
|
my $workspace = get_ws($tmp);
|
|
|
|
is($workspace->{floating_nodes}->[0]->{nodes}->[0]->{window}, $first->id, 'first window on first workspace, floating') unless $floating;
|
|
|
|
is($workspace->{nodes}->[1]->{window}, $first->id, 'first window on first workspace, right') unless !$floating;
|
|
|
|
is($x->input_focus, $second->id, 'second window still focused');
|
|
|
|
}
|
|
|
|
|
|
|
|
#############################################################################
|
|
|
|
# 11: verify that toggling floating for a focused window on another workspace
|
|
|
|
# which has another, unfocused floating window maintains the focus of the
|
|
|
|
# first window.
|
|
|
|
#############################################################################
|
|
|
|
for my $floating (0, 1){
|
|
|
|
$tmp = fresh_workspace;
|
|
|
|
$first = open_window;
|
|
|
|
$second = open_floating_window;
|
|
|
|
is($x->input_focus, $second->id, 'second (floating) window focused');
|
|
|
|
$third = open_window_helper($floating);
|
|
|
|
is($x->input_focus, $third->id, "third (floating = $floating) window focused");
|
|
|
|
|
|
|
|
fresh_workspace;
|
|
|
|
cmd "[id=" . $third->id . "] floating toggle";
|
|
|
|
cmd "workspace $tmp";
|
|
|
|
sync_with_i3;
|
|
|
|
|
|
|
|
my $workspace = get_ws($tmp);
|
|
|
|
is($workspace->{floating_nodes}->[0]->{nodes}->[0]->{window}, $third->id, 'third window on first workspace, floating') unless $floating;
|
|
|
|
is($workspace->{nodes}->[1]->{window}, $third->id, 'third window on first workspace, right') unless !$floating;
|
|
|
|
is($x->input_focus, $third->id, 'third window still focused');
|
|
|
|
}
|
|
|
|
|
|
|
|
#############################################################################
|
|
|
|
# 12: verify that toggling floating for an unfocused window on another
|
|
|
|
# workspace which has another, focused floating window doesn't change focus.
|
|
|
|
#############################################################################
|
|
|
|
|
|
|
|
for my $floating (0, 1){
|
|
|
|
$tmp = fresh_workspace;
|
|
|
|
$first = open_window;
|
|
|
|
$second = open_window_helper($floating);
|
|
|
|
is($x->input_focus, $second->id, "second (floating = $floating) window focused");
|
|
|
|
$third = open_floating_window;
|
|
|
|
is($x->input_focus, $third->id, 'third (floating) window focused');
|
|
|
|
|
|
|
|
fresh_workspace;
|
|
|
|
cmd "[id=" . $second->id . "] floating toggle";
|
|
|
|
cmd "workspace $tmp";
|
|
|
|
sync_with_i3;
|
|
|
|
|
|
|
|
my $workspace = get_ws($tmp);
|
|
|
|
is($workspace->{floating_nodes}->[0]->{nodes}->[0]->{window}, $second->id, 'second window on first workspace, floating') unless $floating;
|
|
|
|
is($workspace->{nodes}->[1]->{window}, $second->id, 'second window on first workspace, right') unless !$floating;
|
|
|
|
is($x->input_focus, $third->id, 'third window still focused');
|
|
|
|
}
|
|
|
|
|
|
|
|
#############################################################################
|
|
|
|
# 13: For layout [H1 [A V1[ B F ] ] ] verify that toggling F's floating
|
|
|
|
# mode maintains its focus.
|
|
|
|
#############################################################################
|
|
|
|
|
|
|
|
for my $floating (0, 1){
|
|
|
|
$tmp = fresh_workspace;
|
|
|
|
$first = open_window;
|
|
|
|
$second = open_window;
|
|
|
|
cmd "split v";
|
|
|
|
sync_with_i3;
|
|
|
|
is($x->input_focus, $second->id, "second (floating = $floating) window focused");
|
|
|
|
$third = open_window_helper($floating);
|
|
|
|
is($x->input_focus, $third->id, 'third (floating) window focused');
|
|
|
|
|
|
|
|
fresh_workspace;
|
|
|
|
cmd "[id=" . $third->id . "] floating toggle";
|
|
|
|
cmd "workspace $tmp";
|
|
|
|
sync_with_i3;
|
|
|
|
|
|
|
|
my $workspace = get_ws($tmp);
|
|
|
|
is($workspace->{floating_nodes}->[0]->{nodes}->[0]->{window}, $third->id, 'third window on first workspace, floating') unless $floating;
|
|
|
|
is($workspace->{nodes}->[1]->{nodes}->[1]->{window}, $third->id, 'third window on first workspace') unless !$floating;
|
|
|
|
is($x->input_focus, $third->id, 'third window still focused');
|
|
|
|
}
|
|
|
|
|
|
|
|
#############################################################################
|
|
|
|
# 14: For layout [H1 [A V1[ H2 [B H2 [ C V2 [ F D ] ] ] ] ] ] verify that
|
|
|
|
# toggling F's floating mode maintains its focus.
|
|
|
|
#############################################################################
|
|
|
|
|
|
|
|
sub kill_and_confirm_focus {
|
|
|
|
my $focus = shift;
|
|
|
|
my $msg = shift;
|
|
|
|
cmd "kill";
|
|
|
|
sync_with_i3;
|
|
|
|
is($x->input_focus, $focus, $msg);
|
|
|
|
}
|
|
|
|
|
|
|
|
$tmp = fresh_workspace;
|
|
|
|
my $A = open_window;
|
|
|
|
my $B = open_window;
|
|
|
|
cmd "split v";
|
|
|
|
my $C = open_window;
|
|
|
|
cmd "split h";
|
|
|
|
my $F = open_window;
|
|
|
|
cmd "split v";
|
|
|
|
my $D = open_window;
|
|
|
|
is($x->input_focus, $D->id, "D is focused");
|
|
|
|
|
|
|
|
sync_with_i3;
|
|
|
|
my $workspace = get_ws($tmp);
|
|
|
|
is($workspace->{nodes}->[1]->{nodes}->[1]->{nodes}->[1]->{nodes}->[0]->{window}, $F->id, 'F opened in its expected position');
|
|
|
|
|
|
|
|
fresh_workspace;
|
|
|
|
cmd "[id=" . $F->id . "] floating enable";
|
|
|
|
cmd "workspace $tmp";
|
|
|
|
sync_with_i3;
|
|
|
|
|
|
|
|
$workspace = get_ws($tmp);
|
|
|
|
is($workspace->{floating_nodes}->[0]->{nodes}->[0]->{window}, $F->id, 'F on first workspace, floating');
|
|
|
|
is($workspace->{nodes}->[1]->{nodes}->[1]->{nodes}->[1]->{nodes}->[0]->{window}, $D->id, 'D where F used to be');
|
|
|
|
is($x->input_focus, $D->id, 'D still focused');
|
|
|
|
|
|
|
|
fresh_workspace;
|
|
|
|
cmd "[id=" . $F->id . "] floating disable";
|
|
|
|
cmd "workspace $tmp";
|
|
|
|
sync_with_i3;
|
|
|
|
|
|
|
|
$workspace = get_ws($tmp);
|
|
|
|
is($workspace->{nodes}->[1]->{nodes}->[1]->{nodes}->[1]->{nodes}->[1]->{window}, $F->id, 'F where D used to be');
|
|
|
|
is($x->input_focus, $D->id, 'D still focused');
|
|
|
|
|
|
|
|
kill_and_confirm_focus($F->id, 'F focused after D is killed');
|
|
|
|
kill_and_confirm_focus($C->id, 'C focused after F is killed');
|
|
|
|
kill_and_confirm_focus($B->id, 'B focused after C is killed');
|
|
|
|
kill_and_confirm_focus($A->id, 'A focused after B is killed');
|
|
|
|
|
2011-03-09 20:25:17 +01:00
|
|
|
done_testing;
|