From 43b9c45cd89e977a7fb7b4a4e028f7620475d5ce Mon Sep 17 00:00:00 2001 From: Benedikt Heine Date: Sun, 26 Nov 2017 20:44:56 +0100 Subject: [PATCH 1/5] Clearify structures in dunst:run --- src/dunst.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/dunst.c b/src/dunst.c index 5d55467..4b3e3f1 100644 --- a/src/dunst.c +++ b/src/dunst.c @@ -60,7 +60,7 @@ gboolean run(void *data) timeout_cnt--; } - if (queues_length_displayed() > 0 && !xctx.visible) { + if (!xctx.visible && queues_length_displayed() > 0) { x_win_show(); } @@ -86,8 +86,12 @@ gboolean run(void *data) } } - /* always return false to delete timers */ - return false; + /* If the execution got triggered by g_timeout_add, + * we have to remove the timeout (which is actually a + * recurring interval), as we have set a new one + * by ourselves. + */ + return G_SOURCE_REMOVE; } gboolean pause_signal(gpointer data) From 1fc96e96916d1ddd2835d6991152f66df72f5149 Mon Sep 17 00:00:00 2001 From: Benedikt Heine Date: Sun, 26 Nov 2017 21:04:29 +0100 Subject: [PATCH 2/5] Call XFlush after redrawing the window The commit 7f335b7 introduced, that specific notifications did not time out properly. Although these had been internally closed already, X11 still displayed them. --- src/x11/x.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/x11/x.c b/src/x11/x.c index 9a6c23a..795be15 100644 --- a/src/x11/x.c +++ b/src/x11/x.c @@ -701,6 +701,8 @@ void x_win_draw(void) cairo_paint(cairo_ctx.context); cairo_show_page(cairo_ctx.context); + XFlush(xctx.dpy); + cairo_destroy(c); cairo_surface_destroy(image_surface); r_free_layouts(layouts); From 2a823eb3814d121f79ab3d524b3885dcfd3a52e2 Mon Sep 17 00:00:00 2001 From: Benedikt Heine Date: Mon, 27 Nov 2017 02:23:27 +0100 Subject: [PATCH 3/5] Check if next_timeout is in past When having a long running notification and an additional two shorter notifications arrive. The short notification, which times out later, does not timeout correctly and gets flushed only, when the long running notification is flushed or a Focus* XEvent is sent. --- src/dunst.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/dunst.c b/src/dunst.c index 4b3e3f1..05ede85 100644 --- a/src/dunst.c +++ b/src/dunst.c @@ -78,7 +78,7 @@ gboolean run(void *data) gint64 timeout_at = now + sleep; if (sleep >= 0) { - if (timeout_cnt == 0 || timeout_at < next_timeout) { + if (timeout_cnt == 0 || next_timeout < now || timeout_at < next_timeout) { g_timeout_add(sleep/1000, run, mainloop); next_timeout = timeout_at; timeout_cnt++; From b7b8362175db111456c776eef6f905c25d76f2b6 Mon Sep 17 00:00:00 2001 From: Benedikt Heine Date: Mon, 27 Nov 2017 02:25:59 +0100 Subject: [PATCH 4/5] Remove timeout_cnt The structure is not needed, as next_timeout gets invalidated via current time and not the amount of all timeouts. --- src/dunst.c | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/src/dunst.c b/src/dunst.c index 05ede85..933f7f8 100644 --- a/src/dunst.c +++ b/src/dunst.c @@ -53,13 +53,8 @@ gboolean run(void *data) queues_check_timeouts(x_is_idle()); queues_update(); - static int timeout_cnt = 0; static gint64 next_timeout = 0; - if (data && timeout_cnt > 0) { - timeout_cnt--; - } - if (!xctx.visible && queues_length_displayed() > 0) { x_win_show(); } @@ -78,10 +73,9 @@ gboolean run(void *data) gint64 timeout_at = now + sleep; if (sleep >= 0) { - if (timeout_cnt == 0 || next_timeout < now || timeout_at < next_timeout) { - g_timeout_add(sleep/1000, run, mainloop); + if (next_timeout < now || timeout_at < next_timeout) { + g_timeout_add(sleep/1000, run, NULL); next_timeout = timeout_at; - timeout_cnt++; } } } From 1c53ae7f9c8ae844a2ba84f73e13b38f982c82f2 Mon Sep 17 00:00:00 2001 From: Benedikt Heine Date: Sun, 26 Nov 2017 21:48:39 +0100 Subject: [PATCH 5/5] Clean up dunst.h --- src/dunst.h | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/dunst.h b/src/dunst.h index 657cfdd..99aeaef 100644 --- a/src/dunst.h +++ b/src/dunst.h @@ -19,18 +19,15 @@ extern GSList *rules; extern const char *color_strings[3][3]; -/* return id of notification */ gboolean run(void *data); void wake_up(void); int dunst_main(int argc, char *argv[]); -void check_timeouts(void); void usage(int exit_status); void print_version(void); char *extract_urls(const char *str); void context_menu(void); -void wake_up(void); void pause_signal_handler(int sig); #endif