mirror of
https://github.com/Llewellynvdm/conky.git
synced 2024-11-17 10:35:10 +00:00
Merge pull request #209 from aandergr/master
keep next_update_time modulo update_interval zero
This commit is contained in:
commit
f95366b649
@ -123,7 +123,7 @@ double get_time(void)
|
||||
{
|
||||
struct timespec tv;
|
||||
|
||||
clock_gettime(CLOCK_MONOTONIC, &tv);
|
||||
clock_gettime(CLOCK_REALTIME, &tv);
|
||||
return tv.tv_sec + (tv.tv_nsec * 1e-9);
|
||||
}
|
||||
|
||||
|
11
src/conky.cc
11
src/conky.cc
@ -953,12 +953,11 @@ static void generate_text(void)
|
||||
}
|
||||
|
||||
double ui = active_update_interval();
|
||||
double time = get_time();
|
||||
next_update_time += ui;
|
||||
if (next_update_time < get_time()) {
|
||||
next_update_time = get_time() + ui;
|
||||
} else if (next_update_time > get_time() + ui) {
|
||||
next_update_time = get_time() + ui;
|
||||
}
|
||||
if (next_update_time < time ||
|
||||
next_update_time > time + ui)
|
||||
next_update_time = time - fmod(time, ui) + ui;
|
||||
last_update_time = current_update_time;
|
||||
total_updates++;
|
||||
}
|
||||
@ -2055,7 +2054,7 @@ static void main_loop(void)
|
||||
#endif
|
||||
|
||||
last_update_time = 0.0;
|
||||
next_update_time = get_time();
|
||||
next_update_time = get_time() - fmod(get_time(), active_update_interval());
|
||||
info.looped = 0;
|
||||
while (terminate == 0
|
||||
&& (total_run_times.get(*state) == 0 || info.looped < total_run_times.get(*state))) {
|
||||
|
Loading…
Reference in New Issue
Block a user