Skip to content

Commit

Permalink
Run(): clear previous timer id if needed
Browse files Browse the repository at this point in the history
  • Loading branch information
tobast committed Jan 14, 2024
1 parent d314806 commit e2329b4
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/dunst.c
Original file line number Diff line number Diff line change
Expand Up @@ -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`
Expand All @@ -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
Expand Down

0 comments on commit e2329b4

Please sign in to comment.