From e2329b48567184fd68f77f3716612696b052eaf9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Th=C3=A9ophile=20Bastian?= Date: Sun, 14 Jan 2024 18:57:03 +0100 Subject: [PATCH] Run(): clear previous timer id if needed Fixes #1196 --- src/dunst.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/dunst.c b/src/dunst.c index ec8d0b506..88b2cbb30 100644 --- a/src/dunst.c +++ b/src/dunst.c @@ -101,6 +101,8 @@ static gboolean run(void *data) draw(); output->win_show(win); + bool timeout_set = true; + gint64 timeout_at = queues_get_next_datachange(now); if (timeout_at != -1) { // Previous computations may have taken time, update `now` @@ -117,12 +119,19 @@ static gboolean run(void *data) if (next_timeout != 0) { g_source_remove(next_timeout_id); } + timeout_set = true; next_timeout_id = g_timeout_add(sleep/1000, run, NULL); next_timeout = timeout_at; } } } + if(!timeout_set) { + // If no new timeout was set this time, clear up te timer id + next_timeout = 0; + next_timeout_id = 0; + } + /* 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