diff --git a/src/dunst.c b/src/dunst.c index 5d55467..933f7f8 100644 --- a/src/dunst.c +++ b/src/dunst.c @@ -53,14 +53,9 @@ 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 (queues_length_displayed() > 0 && !xctx.visible) { + if (!xctx.visible && queues_length_displayed() > 0) { x_win_show(); } @@ -78,16 +73,19 @@ gboolean run(void *data) gint64 timeout_at = now + sleep; if (sleep >= 0) { - if (timeout_cnt == 0 || 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++; } } } - /* 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) 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 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);