2013-01-11 19:58:32 +01:00
|
|
|
#!perl
|
|
|
|
# vim:ts=4:sw=4:expandtab
|
|
|
|
#
|
|
|
|
# Please read the following documents before working on tests:
|
|
|
|
# • http://build.i3wm.org/docs/testsuite.html
|
|
|
|
# (or docs/testsuite)
|
|
|
|
#
|
|
|
|
# • http://build.i3wm.org/docs/lib-i3test.html
|
|
|
|
# (alternatively: perldoc ./testcases/lib/i3test.pm)
|
|
|
|
#
|
|
|
|
# • http://build.i3wm.org/docs/ipc.html
|
|
|
|
# (or docs/ipc)
|
|
|
|
#
|
|
|
|
# • http://onyxneon.com/books/modern_perl/modern_perl_a4.pdf
|
|
|
|
# (unless you are already familiar with Perl)
|
|
|
|
|
|
|
|
use i3test;
|
|
|
|
|
2013-02-18 10:59:32 +01:00
|
|
|
SKIP: {
|
|
|
|
|
|
|
|
skip "AnyEvent::I3 too old (need >= 0.15)", 1 if $AnyEvent::I3::VERSION < 0.15;
|
|
|
|
|
2013-01-11 19:58:32 +01:00
|
|
|
my $i3 = i3(get_socket_path());
|
|
|
|
$i3->connect()->recv;
|
|
|
|
|
|
|
|
################################
|
|
|
|
# Window event
|
|
|
|
################################
|
|
|
|
|
|
|
|
# Events
|
|
|
|
|
|
|
|
my $new = AnyEvent->condvar;
|
2014-02-22 11:52:01 +01:00
|
|
|
my $focus = AnyEvent->condvar;
|
2013-01-11 19:58:32 +01:00
|
|
|
$i3->subscribe({
|
|
|
|
window => sub {
|
|
|
|
my ($event) = @_;
|
2014-02-22 11:52:01 +01:00
|
|
|
if ($event->{change} eq 'new') {
|
|
|
|
$new->send($event);
|
|
|
|
} elsif ($event->{change} eq 'focus') {
|
|
|
|
$focus->send($event);
|
|
|
|
}
|
2013-01-11 19:58:32 +01:00
|
|
|
}
|
|
|
|
})->recv;
|
|
|
|
|
|
|
|
open_window;
|
|
|
|
|
|
|
|
my $t;
|
2014-02-22 11:52:01 +01:00
|
|
|
$t = AnyEvent->timer(
|
|
|
|
after => 0.5,
|
|
|
|
cb => sub {
|
|
|
|
$new->send(0);
|
|
|
|
$focus->send(0);
|
|
|
|
}
|
|
|
|
);
|
2013-01-11 19:58:32 +01:00
|
|
|
|
2014-02-22 11:52:01 +01:00
|
|
|
is($new->recv->{container}->{focused}, 0, 'Window "new" event received');
|
|
|
|
is($focus->recv->{container}->{focused}, 1, 'Window "focus" event received');
|
2013-01-11 19:58:32 +01:00
|
|
|
|
2013-02-18 10:59:32 +01:00
|
|
|
}
|
|
|
|
|
2013-01-11 19:58:32 +01:00
|
|
|
done_testing;
|