00ee86de79
This patch fixes ticket #1168 to extend the window IPC event mechanism to send IPC events for window focus and title changes. The newly added window events use the same format as the already established "new" event. Specifically this patch: * Moves the ipc_send_window_event() function from src/manage.c into src/ipc.c and adds an argument for the change property of the event * Updates src/manage.c to use the new function signature. To ensure that the "new" event does not send the same event data as the "focus" event, setting focus now happens after the "new" event has been sent * Adds IPC focus event notification to src/x.c. To workaround a problem during window close when accessing the window name, a function has been added to query whether a window is actually attached to its parent. To avoid obsolete focus notification, a new field has been added to keep track of the focus without any interference by the click handling * Adds IPC title event notification to src/handlers.c. To avoid obsolete title notification, a function has been added to determine whether a window title has actually changed * Updates the IPC documentation to include the new events * Updates testcases/t/205-ipc-windows.t to include the "focus" event in order to ensure the correct event sequence * Adds two new unit tests, b/testcases/t/219-ipc-window-focus.t and b/testcases/t/220-ipc-window-title.t to ensure proper "focus" and "title" events
62 lines
1.3 KiB
Perl
62 lines
1.3 KiB
Perl
#!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;
|
|
|
|
SKIP: {
|
|
|
|
skip "AnyEvent::I3 too old (need >= 0.15)", 1 if $AnyEvent::I3::VERSION < 0.15;
|
|
|
|
my $i3 = i3(get_socket_path());
|
|
$i3->connect()->recv;
|
|
|
|
################################
|
|
# Window event
|
|
################################
|
|
|
|
# Events
|
|
|
|
my $new = AnyEvent->condvar;
|
|
my $focus = AnyEvent->condvar;
|
|
$i3->subscribe({
|
|
window => sub {
|
|
my ($event) = @_;
|
|
if ($event->{change} eq 'new') {
|
|
$new->send($event);
|
|
} elsif ($event->{change} eq 'focus') {
|
|
$focus->send($event);
|
|
}
|
|
}
|
|
})->recv;
|
|
|
|
open_window;
|
|
|
|
my $t;
|
|
$t = AnyEvent->timer(
|
|
after => 0.5,
|
|
cb => sub {
|
|
$new->send(0);
|
|
$focus->send(0);
|
|
}
|
|
);
|
|
|
|
is($new->recv->{container}->{focused}, 0, 'Window "new" event received');
|
|
is($focus->recv->{container}->{focused}, 1, 'Window "focus" event received');
|
|
|
|
}
|
|
|
|
done_testing;
|