aboutsummaryrefslogtreecommitdiff
path: root/src/ClockTool.cc
diff options
context:
space:
mode:
authorMathias Gumz <akira at fluxbox dot org>2013-01-26 08:21:47 (GMT)
committerMathias Gumz <akira at fluxbox dot org>2013-01-26 08:21:47 (GMT)
commit716532dd47d718cb548da5f65b53a8b744ce235f (patch)
tree683de0875820ce361e2c02efc69d3ad103f3f90a /src/ClockTool.cc
parente7bfc639323bf5d4b207323b6e2fd275dcb5d825 (diff)
downloadfluxbox-716532dd47d718cb548da5f65b53a8b744ce235f.zip
fluxbox-716532dd47d718cb548da5f65b53a8b744ce235f.tar.bz2
Calculates timeouts of ClockTool based upon System Clock
Users expect time switches to happen upon system clock times. Calculating the timeout for the next refresh of the shown time via the monotonic clock is wrong: The monotonic clock yields values based upon some arbitrary point in time which might be off a little bit to the system clock, a 'full' minute of the monotonic clock might be in the midst of a system clock minute.
Diffstat (limited to 'src/ClockTool.cc')
-rw-r--r--src/ClockTool.cc9
1 files changed, 5 insertions, 4 deletions
diff --git a/src/ClockTool.cc b/src/ClockTool.cc
index 3591f4f..b4792fe 100644
--- a/src/ClockTool.cc
+++ b/src/ClockTool.cc
@@ -70,12 +70,13 @@ int showSeconds(const std::string& fmt_string) {
70 70
71uint64_t calcNextTimeout(const std::string& fmt_string) { 71uint64_t calcNextTimeout(const std::string& fmt_string) {
72 72
73 if (showSeconds(fmt_string)) { // microseconds till next full second 73 uint64_t now = FbTk::FbTime::system();
74 return FbTk::FbTime::remainingNext(FbTk::FbTime::IN_SECONDS); 74 uint64_t unit = FbTk::FbTime::IN_SECONDS;
75 if (!showSeconds(fmt_string)) { // microseconds till next full minute
76 unit *= 60L;
75 } 77 }
76 78
77 // microseconds until next full minute 79 return FbTk::FbTime::remainingNext(now, unit);
78 return FbTk::FbTime::remainingNext(60L * FbTk::FbTime::IN_SECONDS);
79} 80}
80 81
81 82