Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Run(): clear previous timer id if needed #1257

Merged
merged 1 commit into from
Jan 30, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading