diff options
author | Mathias Gumz <akira at fluxbox dot org> | 2014-05-12 10:17:00 (GMT) |
---|---|---|
committer | Mathias Gumz <akira at fluxbox dot org> | 2014-05-12 10:17:00 (GMT) |
commit | 948e63eb600e173815a9ddedd2951db56fe51611 (patch) | |
tree | a4a96c0cc8f97d200a13e74c45c4f7dc8b1de550 /src/ClockTool.cc | |
parent | 913244789fac779d8c4ce719d3e9534312feacc2 (diff) | |
download | fluxbox-948e63eb600e173815a9ddedd2951db56fe51611.zip fluxbox-948e63eb600e173815a9ddedd2951db56fe51611.tar.bz2 |
detect minute-based strftime-formats (again)
the lag / skipping of the clock was not caused by faulty timer code
on fluxbox's side but by the behavior and inner workings of time().
since this is fixed now (913244789f) we can now rollback ec7fe513c8
and detect strftime-formats which need intervals of seconds or minutes.
minor: the small change to FbTk::Timer::setTimeout() reduces one
start() / stop() cycle for a running timer.
Diffstat (limited to 'src/ClockTool.cc')
-rw-r--r-- | src/ClockTool.cc | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/src/ClockTool.cc b/src/ClockTool.cc index 514d45d..f11a793 100644 --- a/src/ClockTool.cc +++ b/src/ClockTool.cc | |||
@@ -52,10 +52,19 @@ const char SWITCHES_12_24H[] = "lIrkHT"; | |||
52 | const char SWITCHES_24_12H[] = "kHTlIr"; | 52 | const char SWITCHES_24_12H[] = "kHTlIr"; |
53 | const char SWITCH_AM_PM[] = "pP"; | 53 | const char SWITCH_AM_PM[] = "pP"; |
54 | 54 | ||
55 | uint64_t calcNextTimeout() { | 55 | int showSeconds(const std::string& fmt) { |
56 | |||
57 | return FbTk::StringUtil::findCharFromAlphabetAfterTrigger( | ||
58 | fmt, '%', SWITCHES_SECONDS, sizeof(SWITCHES_SECONDS), 0) != std::string::npos; | ||
59 | } | ||
60 | |||
61 | uint64_t calcNextTimeout(const std::string& fmt) { | ||
56 | 62 | ||
57 | uint64_t now = FbTk::FbTime::system(); | 63 | uint64_t now = FbTk::FbTime::system(); |
58 | uint64_t unit = FbTk::FbTime::IN_SECONDS; | 64 | uint64_t unit = FbTk::FbTime::IN_SECONDS; |
65 | if (!showSeconds(fmt)) { // microseconds till next full minute | ||
66 | unit *= 60L; | ||
67 | } | ||
59 | return FbTk::FbTime::remainingNext(now, unit); | 68 | return FbTk::FbTime::remainingNext(now, unit); |
60 | } | 69 | } |
61 | 70 | ||
@@ -289,8 +298,7 @@ void ClockTool::updateTime() { | |||
289 | } | 298 | } |
290 | 299 | ||
291 | restart_timer: | 300 | restart_timer: |
292 | m_timer.setTimeout(calcNextTimeout()); | 301 | m_timer.setTimeout(calcNextTimeout(*m_timeformat), true); |
293 | m_timer.start(); | ||
294 | } | 302 | } |
295 | 303 | ||
296 | // Just change things that affect the size | 304 | // Just change things that affect the size |