Delay incoming notifications when fullscreens set

This commit is contained in:
Benedikt Heine 2017-08-14 02:16:14 +02:00
parent bda8c1dbb2
commit f89ce8e16f
3 changed files with 28 additions and 10 deletions

View File

@ -48,8 +48,10 @@ void wake_up(void)
static gboolean run(void *data)
{
queues_check_timeouts(x_is_idle());
queues_update();
bool fullscreen = have_fullscreen_window();
queues_check_timeouts(x_is_idle(), fullscreen);
queues_update(fullscreen);
static gint64 next_timeout = 0;

View File

@ -284,12 +284,14 @@ void queues_history_push_all(void)
}
/* see queues.h */
void queues_check_timeouts(bool idle)
void queues_check_timeouts(bool idle, bool fullscreen)
{
/* nothing to do */
if (displayed->length == 0)
return;
bool is_idle = fullscreen ? false : idle;
GList *iter = g_queue_peek_head_link(displayed);
while (iter) {
notification *n = iter->data;
@ -302,7 +304,7 @@ void queues_check_timeouts(bool idle)
iter = iter->next;
/* don't timeout when user is idle */
if (idle && !n->transient) {
if (is_idle && !n->transient) {
n->start = g_get_monotonic_time();
continue;
}
@ -320,7 +322,7 @@ void queues_check_timeouts(bool idle)
}
/* see queues.h */
void queues_update(void)
void queues_update(bool fullscreen)
{
if (pause_displayed) {
while (displayed->length > 0) {
@ -331,25 +333,34 @@ void queues_update(void)
}
/* move notifications from queue to displayed */
while (waiting->length > 0) {
GList *iter = g_queue_peek_head_link(waiting);
while (iter) {
notification *n = iter->data;
GList *nextiter = iter->next;
if (displayed_limit > 0 && displayed->length >= displayed_limit) {
/* the list is full */
break;
}
notification *n = g_queue_pop_head(waiting);
if (!n)
return;
if (fullscreen && n->fullscreen == FS_DELAY) {
iter = nextiter;
continue;
}
n->start = g_get_monotonic_time();
if (!n->redisplayed && n->script) {
notification_run_script(n);
}
g_queue_delete_link(waiting, iter);
g_queue_insert_sorted(displayed, n, notification_cmp_data, NULL);
iter = nextiter;
}
}

View File

@ -125,8 +125,10 @@ void queues_history_push_all(void);
*
* @param idle the program's idle status. Important to calculate the
* timeout for transient notifications
* @param fullscreen the desktop's fullscreen status. Important to
* calculate the timeout for transient notifications
*/
void queues_check_timeouts(bool idle);
void queues_check_timeouts(bool idle, bool fullscreen);
/**
* Move inserted notifications from waiting queue to displayed queue
@ -135,8 +137,11 @@ void queues_check_timeouts(bool idle);
*
* @post Call wake_up() to synchronize the queues with the UI
* (which closes old and shows new notifications on screen)
*
* @param fullscreen the desktop's fullscreen status. Important to
* move notifications to the right queue
*/
void queues_update(void);
void queues_update(bool fullscreen);
/**
* Calculate the distance to the next event, when an element in the