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.
Mathias Gumz akira at fluxbox dot org
3 files changed,
14 insertions(+),
6 deletions(-)
M
src/ClockTool.cc
→
src/ClockTool.cc
@@ -52,10 +52,19 @@ const char SWITCHES_12_24H[] = "lIrkHT";
const char SWITCHES_24_12H[] = "kHTlIr"; const char SWITCH_AM_PM[] = "pP"; -uint64_t calcNextTimeout() { +int showSeconds(const std::string& fmt) { + + return FbTk::StringUtil::findCharFromAlphabetAfterTrigger( + fmt, '%', SWITCHES_SECONDS, sizeof(SWITCHES_SECONDS), 0) != std::string::npos; +} + +uint64_t calcNextTimeout(const std::string& fmt) { uint64_t now = FbTk::FbTime::system(); uint64_t unit = FbTk::FbTime::IN_SECONDS; + if (!showSeconds(fmt)) { // microseconds till next full minute + unit *= 60L; + } return FbTk::FbTime::remainingNext(now, unit); }@@ -289,8 +298,7 @@ themeReconfigured();
} restart_timer: - m_timer.setTimeout(calcNextTimeout()); - m_timer.start(); + m_timer.setTimeout(calcNextTimeout(*m_timeformat), true); } // Just change things that affect the size
M
src/FbTk/Timer.cc
→
src/FbTk/Timer.cc
@@ -91,7 +91,7 @@ stop();
} -void Timer::setTimeout(uint64_t timeout) { +void Timer::setTimeout(uint64_t timeout, bool force_start) { bool was_timing = isTiming(); if (was_timing) {@@ -99,7 +99,7 @@ stop();
} m_timeout = timeout; - if (was_timing) { + if (force_start || was_timing) { start(); } }
M
src/FbTk/Timer.hh
→
src/FbTk/Timer.hh
@@ -43,7 +43,7 @@ explicit Timer(const RefCount<Slot<void> > &handler);
~Timer(); void fireOnce(bool once) { m_once = once; } - void setTimeout(uint64_t timeout); + void setTimeout(uint64_t timeout, bool force_start = false); void setCommand(const RefCount<Slot<void> > &cmd); template<typename Functor>