summaryrefslogtreecommitdiff
path: root/src/Fl_Clock.cxx
diff options
context:
space:
mode:
authorMatthias Melcher <git@matthiasm.com>2019-12-31 18:33:01 +0100
committerMatthias Melcher <git@matthiasm.com>2019-12-31 18:33:01 +0100
commitdb6fa8bf86407a0d1a1de180fff55702e1f75d6f (patch)
tree2d28dd5fe902cdbed35fd7ba6165eac7ebe3baa3 /src/Fl_Clock.cxx
parentdf9eb443f0efce88b2d572b564b03908b8f53bf2 (diff)
parenta624d9be2d3fe24e64fdbadc5079f9a8c65a5f46 (diff)
Merge remote-tracking branch 'refs/remotes/origin/master'
Diffstat (limited to 'src/Fl_Clock.cxx')
-rw-r--r--src/Fl_Clock.cxx11
1 files changed, 8 insertions, 3 deletions
diff --git a/src/Fl_Clock.cxx b/src/Fl_Clock.cxx
index ca7237212..4d7f21e47 100644
--- a/src/Fl_Clock.cxx
+++ b/src/Fl_Clock.cxx
@@ -212,11 +212,16 @@ static void tick(void *v) {
time_t sec;
int usec;
Fl::system_driver()->gettime(&sec, &usec);
+ double delta = (1000000 - usec)/1000000.; // time till next second
+ // if current time is just before full second, show that full second
+ // and wait one more second (STR 3516)
+ if (delta < 0.1) {
+ delta += 1.0;
+ sec++;
+ }
((Fl_Clock*)v)->value((ulong)sec);
- // schedule timer event slightly later than the next second (+25 ms)
- // to prevent multiple timer events if triggered too early (STR 3516)
- Fl::add_timeout((1025000 - usec)/1000000., tick, v);
+ Fl::add_timeout(delta, tick, v);
}
int Fl_Clock::handle(int event) {