From f89ce8e16f8185a1a1695647c08977da7f5fd69c Mon Sep 17 00:00:00 2001 From: Benedikt Heine Date: Mon, 14 Aug 2017 02:16:14 +0200 Subject: [PATCH] Delay incoming notifications when fullscreens set --- src/dunst.c | 6 ++++-- src/queues.c | 23 +++++++++++++++++------ src/queues.h | 9 +++++++-- 3 files changed, 28 insertions(+), 10 deletions(-) diff --git a/src/dunst.c b/src/dunst.c index 53fb2fc..6765af4 100644 --- a/src/dunst.c +++ b/src/dunst.c @@ -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; diff --git a/src/queues.c b/src/queues.c index 78f6c6a..09fed9c 100644 --- a/src/queues.c +++ b/src/queues.c @@ -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; } } diff --git a/src/queues.h b/src/queues.h index 2fa9900..6bb10d7 100644 --- a/src/queues.h +++ b/src/queues.h @@ -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