From 5b3a46e2ec777ebf8454cd70145e37ff202c3918 Mon Sep 17 00:00:00 2001 From: progandy Date: Mon, 27 May 2013 19:43:30 +0200 Subject: [PATCH 1/3] fix broken window update for history --- dunst.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/dunst.c b/dunst.c index 534a6d2..6d913f7 100644 --- a/dunst.c +++ b/dunst.c @@ -168,9 +168,7 @@ void history_pop(void) n->timeout = settings.sticky_history ? 0 : n->timeout; g_queue_push_head(queue, n); - if (!xctx.visible) { - wake_up(); - } + wake_up(); } void wake_up(void) From 0b3599076bb091173401f7ac042df841e4603b7e Mon Sep 17 00:00:00 2001 From: progandy Date: Tue, 28 May 2013 17:21:24 +0200 Subject: [PATCH 2/3] switch timer to seconds instead of ms --- dunst.c | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/dunst.c b/dunst.c index 6d913f7..e604cd0 100644 --- a/dunst.c +++ b/dunst.c @@ -181,7 +181,7 @@ static int get_sleep_time(void) if (settings.show_age_threshold == 0) { /* we need to update every second */ - return 1000; + return 1; } bool have_ttl = false; @@ -207,7 +207,7 @@ static int get_sleep_time(void) int show_age_timeout = settings.show_age_threshold - max_age; if (show_age_timeout < 1) { - return 1000; + return 1; } if (!have_ttl) { @@ -218,13 +218,9 @@ static int get_sleep_time(void) /* show_age_timeout might be negative */ if (min_timeout < 1) { - return 1000; + return 1; } else { - /* add 501 milliseconds to make sure we wake are in the second - * after the next notification times out. Otherwise we'll wake - * up, but the notification won't get closed until we get woken - * up again (which might be multiple seconds later */ - return min_timeout * 1000 + 501; + return min_timeout; } } @@ -251,13 +247,13 @@ gboolean run(void *data) } if (xctx.visible) { - int now = time(NULL) * 1000; + int now = time(NULL); int sleep = get_sleep_time(); if (sleep > 0) { int timeout_at = now + sleep; if (timeout_cnt == 0 || timeout_at < next_timeout) { - g_timeout_add(sleep, run, mainloop); + g_timeout_add_seconds(sleep, run, mainloop); next_timeout = timeout_at; timeout_cnt++; } From dab943a702067a2d6ec53c66e00aed879f037f5b Mon Sep 17 00:00:00 2001 From: progandy Date: Tue, 28 May 2013 17:22:05 +0200 Subject: [PATCH 3/3] fix unreliable and missed timeouts --- dunst.c | 2 +- notification.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/dunst.c b/dunst.c index e604cd0..f8f0784 100644 --- a/dunst.c +++ b/dunst.c @@ -193,7 +193,7 @@ static int get_sleep_time(void) max_age = MAX(max_age, notification_get_age(n)); int ttl = notification_get_ttl(n); - if (ttl > 0) { + if (ttl >= 0) { if (have_ttl) { min_ttl = MIN(min_ttl, ttl); } else { diff --git a/notification.c b/notification.c index e3d3b47..10cbd11 100644 --- a/notification.c +++ b/notification.c @@ -520,7 +520,7 @@ void notification_update_text_to_render(notification *n) int notification_get_ttl(notification *n) { if (n->timeout == 0) { - return 0; + return -1; } else { return n->timeout - (time(NULL) - n->start); }