Implement the window::urgent event
The window::urgent event is emitted when a container becomes urgent or loses its urgent status.
This commit is contained in:
parent
a9c094b731
commit
682fb0a291
1
docs/ipc
1
docs/ipc
|
@ -723,6 +723,7 @@ This event consists of a single serialized map containing a property
|
||||||
* +fullscreen_mode+ - the window has entered or exited fullscreen mode
|
* +fullscreen_mode+ - the window has entered or exited fullscreen mode
|
||||||
* +move+ - the window has changed its position in the tree
|
* +move+ - the window has changed its position in the tree
|
||||||
* +floating+ - the window has transitioned to or from floating
|
* +floating+ - the window has transitioned to or from floating
|
||||||
|
* +urgent+ - the window has become urgent or lost its urgent status
|
||||||
|
|
||||||
Additionally a +container (object)+ field will be present, which consists
|
Additionally a +container (object)+ field will be present, which consists
|
||||||
of the window's parent container. Be aware that for the "new" event, the
|
of the window's parent container. Be aware that for the "new" event, the
|
||||||
|
|
|
@ -231,6 +231,7 @@ void con_focus(Con *con) {
|
||||||
con->urgent = false;
|
con->urgent = false;
|
||||||
con_update_parents_urgency(con);
|
con_update_parents_urgency(con);
|
||||||
workspace_update_urgent_flag(con_get_workspace(con));
|
workspace_update_urgent_flag(con_get_workspace(con));
|
||||||
|
ipc_send_window_event("urgent", con);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1599,14 +1600,16 @@ void con_set_urgency(Con *con, bool urgent) {
|
||||||
|
|
||||||
con_update_parents_urgency(con);
|
con_update_parents_urgency(con);
|
||||||
|
|
||||||
if (con->urgent == urgent)
|
|
||||||
LOG("Urgency flag changed to %d\n", con->urgent);
|
|
||||||
|
|
||||||
Con *ws;
|
Con *ws;
|
||||||
/* Set the urgency flag on the workspace, if a workspace could be found
|
/* Set the urgency flag on the workspace, if a workspace could be found
|
||||||
* (for dock clients, that is not the case). */
|
* (for dock clients, that is not the case). */
|
||||||
if ((ws = con_get_workspace(con)) != NULL)
|
if ((ws = con_get_workspace(con)) != NULL)
|
||||||
workspace_update_urgent_flag(ws);
|
workspace_update_urgent_flag(ws);
|
||||||
|
|
||||||
|
if (con->urgent == urgent) {
|
||||||
|
LOG("Urgency flag changed to %d\n", con->urgent);
|
||||||
|
ipc_send_window_event("urgent", con);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
|
@ -320,11 +320,14 @@ static void workspace_reassign_sticky(Con *con) {
|
||||||
static void workspace_defer_update_urgent_hint_cb(EV_P_ ev_timer *w, int revents) {
|
static void workspace_defer_update_urgent_hint_cb(EV_P_ ev_timer *w, int revents) {
|
||||||
Con *con = w->data;
|
Con *con = w->data;
|
||||||
|
|
||||||
DLOG("Resetting urgency flag of con %p by timer\n", con);
|
if (con->urgent) {
|
||||||
con->urgent = false;
|
DLOG("Resetting urgency flag of con %p by timer\n", con);
|
||||||
con_update_parents_urgency(con);
|
con->urgent = false;
|
||||||
workspace_update_urgent_flag(con_get_workspace(con));
|
con_update_parents_urgency(con);
|
||||||
tree_render();
|
workspace_update_urgent_flag(con_get_workspace(con));
|
||||||
|
ipc_send_window_event("urgent", con);
|
||||||
|
tree_render();
|
||||||
|
}
|
||||||
|
|
||||||
ev_timer_stop(main_loop, con->urgency_timer);
|
ev_timer_stop(main_loop, con->urgency_timer);
|
||||||
FREE(con->urgency_timer);
|
FREE(con->urgency_timer);
|
||||||
|
@ -380,6 +383,7 @@ static void _workspace_show(Con *workspace) {
|
||||||
* focus and thereby immediately destroy it */
|
* focus and thereby immediately destroy it */
|
||||||
if (next->urgent && (int)(config.workspace_urgency_timer * 1000) > 0) {
|
if (next->urgent && (int)(config.workspace_urgency_timer * 1000) > 0) {
|
||||||
/* focus for now… */
|
/* focus for now… */
|
||||||
|
next->urgent = false;
|
||||||
con_focus(next);
|
con_focus(next);
|
||||||
|
|
||||||
/* … but immediately reset urgency flags; they will be set to false by
|
/* … but immediately reset urgency flags; they will be set to false by
|
||||||
|
|
|
@ -0,0 +1,68 @@
|
||||||
|
#!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)
|
||||||
|
#
|
||||||
|
# Test that the window::urgent event works correctly. The window::urgent event
|
||||||
|
# should be emitted when a window becomes urgent or loses its urgent status.
|
||||||
|
#
|
||||||
|
use i3test;
|
||||||
|
|
||||||
|
my $config = <<EOT;
|
||||||
|
# i3 config file (v4)
|
||||||
|
font -misc-fixed-medium-r-normal--13-120-75-75-C-70-iso10646-1
|
||||||
|
|
||||||
|
force_display_urgency_hint 0ms
|
||||||
|
EOT
|
||||||
|
|
||||||
|
my $i3 = i3(get_socket_path());
|
||||||
|
$i3->connect()->recv;
|
||||||
|
|
||||||
|
my $cv;
|
||||||
|
$i3->subscribe({
|
||||||
|
window => sub {
|
||||||
|
my ($event) = @_;
|
||||||
|
$cv->send($event) if $event->{change} eq 'urgent';
|
||||||
|
}
|
||||||
|
})->recv;
|
||||||
|
|
||||||
|
my $t;
|
||||||
|
$t = AnyEvent->timer(
|
||||||
|
after => 0.5,
|
||||||
|
cb => sub {
|
||||||
|
$cv->send(0);
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
$cv = AnyEvent->condvar;
|
||||||
|
fresh_workspace;
|
||||||
|
my $win = open_window;
|
||||||
|
my $dummy_win = open_window;
|
||||||
|
|
||||||
|
$win->add_hint('urgency');
|
||||||
|
my $event = $cv->recv;
|
||||||
|
|
||||||
|
isnt($event, 0, 'an urgent con should emit the window::urgent event');
|
||||||
|
is($event->{container}->{window}, $win->{id}, 'the event should contain information about the window');
|
||||||
|
is($event->{container}->{urgent}, 1, 'the container should be urgent');
|
||||||
|
|
||||||
|
$cv = AnyEvent->condvar;
|
||||||
|
$win->delete_hint('urgency');
|
||||||
|
my $event = $cv->recv;
|
||||||
|
|
||||||
|
isnt($event, 0, 'an urgent con should emit the window::urgent event');
|
||||||
|
is($event->{container}->{window}, $win->{id}, 'the event should contain information about the window');
|
||||||
|
is($event->{container}->{urgent}, 0, 'the container should not be urgent');
|
||||||
|
|
||||||
|
done_testing;
|
Loading…
Reference in New Issue