Include workspace con in workspace event

Send the affected workspace in the "current" property for each workspace
event for any type of workspace event that affects a particular
workspace.

fixes #1411
This commit is contained in:
Tony Crisci
2014-12-19 23:43:47 -05:00
committed by Michael Stapelberg
parent 04fa40d3e5
commit 823b46a544
9 changed files with 90 additions and 41 deletions

View File

@ -23,7 +23,7 @@ $i3->connect()->recv;
# Workspaces requests and events
################################
my $focused = get_ws(focused_ws());
my $old_ws = get_ws(focused_ws());
# Events
@ -36,15 +36,11 @@ $i3->subscribe({
workspace => sub {
my ($event) = @_;
if ($event->{change} eq 'init') {
$init->send(1);
$init->send($event);
} elsif ($event->{change} eq 'focus') {
# Check that we have the old and new workspace
$focus->send(
$event->{current}->{name} == '2' &&
$event->{old}->{name} == $focused->{name}
);
$focus->send($event);
} elsif ($event->{change} eq 'empty') {
$empty->send(1);
$empty->send($event);
}
}
})->recv;
@ -61,8 +57,20 @@ $t = AnyEvent->timer(
}
);
ok($init->recv, 'Workspace "init" event received');
ok($focus->recv, 'Workspace "focus" event received');
ok($empty->recv, 'Workspace "empty" event received');
my $init_event = $init->recv;
my $focus_event = $focus->recv;
my $empty_event = $empty->recv;
my $current_ws = get_ws(focused_ws());
ok($init_event, 'workspace "init" event received');
is($init_event->{current}->{id}, $current_ws->{id}, 'the "current" property should contain the initted workspace con');
ok($focus_event, 'workspace "focus" event received');
is($focus_event->{current}->{id}, $current_ws->{id}, 'the "current" property should contain the focused workspace con');
is($focus_event->{old}->{id}, $old_ws->{id}, 'the "old" property should contain the workspace con that was focused last');
ok($empty_event, 'workspace "empty" event received');
is($empty_event->{current}->{id}, $old_ws->{id}, 'the "current" property should contain the emptied workspace con');
done_testing;

View File

@ -50,6 +50,7 @@ subtest 'Workspace empty event upon switch', sub {
my $event = $cond->recv;
is($event->{change}, 'empty', '"Empty" event received upon workspace switch');
is($event->{current}->{name}, $ws1, '"current" property should be set to the workspace con');
};
################################################################################
@ -116,6 +117,7 @@ subtest 'Workspace empty event upon window close', sub {
my $event = $cond->recv;
is($event->{change}, 'empty', '"Empty" event received upon window close');
is($event->{current}->{name}, $ws1, '"current" property should be set to the workspace con');
};
}