2010-11-14 15:43:31 -05:00
|
|
|
#!perl
|
|
|
|
# vim:ts=4:sw=4:expandtab
|
|
|
|
|
2011-03-09 14:25:17 -05:00
|
|
|
use i3test;
|
2011-05-13 13:27:18 -04:00
|
|
|
use X11::XCB qw(:all);
|
|
|
|
use X11::XCB::Connection;
|
|
|
|
|
|
|
|
my $x = X11::XCB::Connection->new;
|
2010-11-14 15:43:31 -05:00
|
|
|
|
2011-03-09 14:25:17 -05:00
|
|
|
my $tmp = fresh_workspace;
|
2010-11-14 15:43:31 -05:00
|
|
|
|
2010-11-14 16:35:44 -05:00
|
|
|
#############################################################################
|
|
|
|
# 1: see if focus stays the same when toggling tiling/floating mode
|
|
|
|
#############################################################################
|
|
|
|
|
2011-09-24 10:11:37 -04:00
|
|
|
my $first = open_window($x);
|
|
|
|
my $second = open_window($x);
|
2011-09-23 15:37:45 -04:00
|
|
|
|
2011-05-13 13:27:18 -04:00
|
|
|
is($x->input_focus, $second->id, 'second window focused');
|
2010-11-14 15:43:31 -05:00
|
|
|
|
2011-06-30 18:37:30 -04:00
|
|
|
cmd 'floating enable';
|
|
|
|
cmd 'floating disable';
|
2010-11-14 15:43:31 -05:00
|
|
|
|
2011-05-13 13:27:18 -04:00
|
|
|
is($x->input_focus, $second->id, 'second window still focused after mode toggle');
|
2010-11-14 16:35:44 -05:00
|
|
|
|
|
|
|
#############################################################################
|
2011-05-13 13:27:18 -04:00
|
|
|
# 2: see if focus stays on the current floating window if killing another
|
|
|
|
# floating window
|
|
|
|
#############################################################################
|
|
|
|
|
|
|
|
$tmp = fresh_workspace;
|
|
|
|
|
2011-09-24 10:11:37 -04:00
|
|
|
$first = open_window($x); # window 2
|
|
|
|
$second = open_window($x); # window 3
|
|
|
|
my $third = open_window($x); # window 4
|
2011-09-23 15:37:45 -04:00
|
|
|
|
2011-05-13 13:27:18 -04:00
|
|
|
is($x->input_focus, $third->id, 'last container focused');
|
|
|
|
|
2011-06-30 18:37:30 -04:00
|
|
|
cmd 'floating enable';
|
2011-05-13 13:27:18 -04:00
|
|
|
|
|
|
|
cmd '[id="' . $second->id . '"] focus';
|
|
|
|
|
2011-09-23 15:37:45 -04:00
|
|
|
sync_with_i3($x);
|
|
|
|
|
2011-05-13 13:27:18 -04:00
|
|
|
is($x->input_focus, $second->id, 'second con focused');
|
|
|
|
|
2011-06-30 18:37:30 -04:00
|
|
|
cmd 'floating enable';
|
2011-05-13 13:27:18 -04:00
|
|
|
|
|
|
|
# now kill the third one (it's floating). focus should stay unchanged
|
|
|
|
cmd '[id="' . $third->id . '"] kill';
|
|
|
|
|
2011-09-23 15:37:45 -04:00
|
|
|
# TODO: wait for unmapnotify
|
|
|
|
sync_with_i3($x);
|
2011-05-13 13:27:18 -04: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 16:35:44 -05:00
|
|
|
# (first to the next floating client, then to the last focused tiling client)
|
|
|
|
#############################################################################
|
|
|
|
|
2011-03-09 14:25:17 -05:00
|
|
|
$tmp = fresh_workspace;
|
2010-11-14 16:35:44 -05:00
|
|
|
|
2011-10-11 08:13:42 -04:00
|
|
|
$first = open_window($x, { background_color => '#ff0000' }); # window 5
|
|
|
|
$second = open_window($x, { background_color => '#00ff00' }); # window 6
|
|
|
|
my $third = open_window($x, { background_color => '#0000ff' }); # window 7
|
2011-09-23 15:37:45 -04:00
|
|
|
|
2011-05-13 13:27:18 -04:00
|
|
|
is($x->input_focus, $third->id, 'last container focused');
|
2010-11-14 16:35:44 -05:00
|
|
|
|
2011-06-30 18:37:30 -04:00
|
|
|
cmd 'floating enable';
|
2010-11-14 16:35:44 -05:00
|
|
|
|
2011-05-13 13:27:18 -04:00
|
|
|
cmd '[id="' . $second->id . '"] focus';
|
2010-11-14 16:35:44 -05:00
|
|
|
|
2011-09-23 15:37:45 -04:00
|
|
|
sync_with_i3($x);
|
|
|
|
|
2011-05-13 13:27:18 -04:00
|
|
|
is($x->input_focus, $second->id, 'second con focused');
|
2010-11-14 16:35:44 -05:00
|
|
|
|
2011-06-30 18:37:30 -04:00
|
|
|
cmd 'floating enable';
|
2010-11-14 16:35:44 -05:00
|
|
|
|
2011-05-13 13:27:18 -04:00
|
|
|
# now kill the second one. focus should fall back to the third one, which is
|
|
|
|
# also floating
|
|
|
|
cmd 'kill';
|
2010-11-14 16:35:44 -05:00
|
|
|
|
2011-09-23 15:37:45 -04:00
|
|
|
# TODO: wait for unmapnotify
|
|
|
|
sync_with_i3($x);
|
2010-11-14 16:35:44 -05:00
|
|
|
|
2011-05-13 13:27:18 -04:00
|
|
|
is($x->input_focus, $third->id, 'third con focused');
|
2010-11-14 16:35:44 -05:00
|
|
|
|
2011-05-13 13:27:18 -04:00
|
|
|
cmd 'kill';
|
2011-09-23 15:37:45 -04:00
|
|
|
# TODO: wait for unmapnotify
|
|
|
|
sync_with_i3($x);
|
2010-11-14 16:35:44 -05:00
|
|
|
|
2011-05-13 13:27:18 -04:00
|
|
|
is($x->input_focus, $first->id, 'first con focused after killing all floating cons');
|
2011-03-09 14:25:17 -05:00
|
|
|
|
2011-06-30 19:10:43 -04:00
|
|
|
#############################################################################
|
|
|
|
# 4: same test as 3, but with another split con
|
|
|
|
#############################################################################
|
|
|
|
|
|
|
|
$tmp = fresh_workspace;
|
|
|
|
|
2011-09-24 10:11:37 -04:00
|
|
|
$first = open_window($x, { background_color => '#ff0000' }); # window 5
|
2011-06-30 19:10:43 -04:00
|
|
|
cmd 'split v';
|
|
|
|
cmd 'layout stacked';
|
2011-09-24 10:11:37 -04:00
|
|
|
$second = open_window($x, { background_color => '#00ff00' }); # window 6
|
|
|
|
$third = open_window($x, { background_color => '#0000ff' }); # window 7
|
2011-09-23 15:37:45 -04:00
|
|
|
|
2011-06-30 19:10:43 -04:00
|
|
|
is($x->input_focus, $third->id, 'last container focused');
|
|
|
|
|
|
|
|
cmd 'floating enable';
|
|
|
|
|
|
|
|
cmd '[id="' . $second->id . '"] focus';
|
|
|
|
|
2011-09-23 15:37:45 -04:00
|
|
|
sync_with_i3($x);
|
|
|
|
|
2011-06-30 19:10:43 -04:00
|
|
|
is($x->input_focus, $second->id, 'second con focused');
|
|
|
|
|
|
|
|
cmd 'floating enable';
|
|
|
|
|
2011-09-23 15:37:45 -04:00
|
|
|
sync_with_i3($x);
|
2011-06-30 19:10:43 -04:00
|
|
|
|
|
|
|
# now kill the second one. focus should fall back to the third one, which is
|
|
|
|
# also floating
|
|
|
|
cmd 'kill';
|
|
|
|
|
2011-09-23 15:37:45 -04:00
|
|
|
# TODO: wait for unmapnotify
|
|
|
|
sync_with_i3($x);
|
2011-06-30 19:10:43 -04:00
|
|
|
|
2011-09-23 15:37:45 -04:00
|
|
|
is($x->input_focus, $third->id, 'third con focused');
|
2011-06-30 19:10:43 -04:00
|
|
|
|
|
|
|
cmd 'kill';
|
2011-09-23 15:37:45 -04:00
|
|
|
# TODO: wait for unmapnotify
|
|
|
|
sync_with_i3($x);
|
2011-06-30 19:10:43 -04:00
|
|
|
|
|
|
|
is($x->input_focus, $first->id, 'first con focused after killing all floating cons');
|
|
|
|
|
2011-07-04 11:09:52 -04:00
|
|
|
#############################################################################
|
|
|
|
# 5: see if the 'focus tiling' and 'focus floating' commands work
|
|
|
|
#############################################################################
|
|
|
|
|
|
|
|
$tmp = fresh_workspace;
|
|
|
|
|
2011-09-24 10:11:37 -04:00
|
|
|
$first = open_window($x, { background_color => '#ff0000' }); # window 8
|
|
|
|
$second = open_window($x, { background_color => '#00ff00' }); # window 9
|
2011-07-04 11:09:52 -04:00
|
|
|
|
2011-09-23 15:37:45 -04:00
|
|
|
sync_with_i3($x);
|
|
|
|
|
2011-07-04 11:09:52 -04: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';
|
|
|
|
|
2011-09-23 15:37:45 -04:00
|
|
|
sync_with_i3($x);
|
2011-07-04 11:09:52 -04:00
|
|
|
|
|
|
|
is($x->input_focus, $first->id, 'first (tiling) container focused');
|
|
|
|
|
|
|
|
cmd 'focus floating';
|
|
|
|
|
2011-09-23 15:37:45 -04:00
|
|
|
sync_with_i3($x);
|
2011-07-04 11:09:52 -04:00
|
|
|
|
|
|
|
is($x->input_focus, $second->id, 'second (floating) container focused');
|
|
|
|
|
|
|
|
cmd 'focus floating';
|
|
|
|
|
2011-09-23 15:37:45 -04:00
|
|
|
sync_with_i3($x);
|
2011-07-04 11:09:52 -04:00
|
|
|
|
|
|
|
is($x->input_focus, $second->id, 'second (floating) container still focused');
|
|
|
|
|
|
|
|
cmd 'focus mode_toggle';
|
|
|
|
|
2011-09-23 15:37:45 -04:00
|
|
|
sync_with_i3($x);
|
2011-07-04 11:09:52 -04:00
|
|
|
|
|
|
|
is($x->input_focus, $first->id, 'first (tiling) container focused');
|
|
|
|
|
|
|
|
cmd 'focus mode_toggle';
|
|
|
|
|
2011-09-23 15:37:45 -04:00
|
|
|
sync_with_i3($x);
|
2011-07-04 11:09:52 -04:00
|
|
|
|
|
|
|
is($x->input_focus, $second->id, 'second (floating) container focused');
|
|
|
|
|
2011-09-17 14:29:23 -04:00
|
|
|
#############################################################################
|
|
|
|
# 6: see if switching floating focus using the focus left/right command works
|
|
|
|
#############################################################################
|
|
|
|
|
|
|
|
$tmp = fresh_workspace;
|
|
|
|
|
2011-09-24 10:11:37 -04:00
|
|
|
$first = open_floating_window($x, { background_color => '#ff0000' });# window 10
|
|
|
|
$second = open_floating_window($x, { background_color => '#00ff00' }); # window 11
|
|
|
|
$third = open_floating_window($x, { background_color => '#0000ff' }); # window 12
|
2011-09-17 14:29:23 -04:00
|
|
|
|
2011-09-23 15:37:45 -04:00
|
|
|
sync_with_i3($x);
|
|
|
|
|
2011-09-17 14:29:23 -04:00
|
|
|
is($x->input_focus, $third->id, 'third container focused');
|
|
|
|
|
|
|
|
cmd 'focus left';
|
|
|
|
|
2011-09-23 15:37:45 -04:00
|
|
|
sync_with_i3($x);
|
2011-09-17 14:29:23 -04:00
|
|
|
|
|
|
|
is($x->input_focus, $second->id, 'second container focused');
|
|
|
|
|
|
|
|
cmd 'focus left';
|
|
|
|
|
2011-09-23 15:37:45 -04:00
|
|
|
sync_with_i3($x);
|
2011-09-17 14:29:23 -04:00
|
|
|
|
|
|
|
is($x->input_focus, $first->id, 'first container focused');
|
|
|
|
|
|
|
|
cmd 'focus left';
|
|
|
|
|
2011-09-23 15:37:45 -04:00
|
|
|
sync_with_i3($x);
|
2011-09-17 14:29:23 -04:00
|
|
|
|
|
|
|
is($x->input_focus, $third->id, 'focus wrapped to third container');
|
|
|
|
|
|
|
|
cmd 'focus right';
|
|
|
|
|
2011-09-23 15:37:45 -04:00
|
|
|
sync_with_i3($x);
|
2011-09-17 14:29:23 -04:00
|
|
|
|
|
|
|
is($x->input_focus, $first->id, 'focus wrapped to first container');
|
|
|
|
|
|
|
|
cmd 'focus right';
|
|
|
|
|
2011-09-23 15:37:45 -04:00
|
|
|
sync_with_i3($x);
|
2011-09-17 14:29:23 -04:00
|
|
|
|
|
|
|
is($x->input_focus, $second->id, 'focus on second container');
|
2011-07-04 11:09:52 -04:00
|
|
|
|
2011-03-09 14:25:17 -05:00
|
|
|
done_testing;
|