simpler to use FbTk/Timer api

This commit is contained in:
Mathias Gumz 2010-09-09 12:47:38 +02:00
parent 82d0de9ef4
commit e685117941
3 changed files with 8 additions and 5 deletions

View file

@ -78,14 +78,11 @@ void AttentionNoticeHandler::addAttention(Focusable &client) {
if (**timeout_res == 0)
return;
Timer *timer = new Timer();
// setup timer
timeval timeout;
timeout.tv_sec = 0;
timeout.tv_usec = **timeout_res * 1000;
RefCount<Command<void> > cmd(new ToggleFrameFocusCmd(client));
Timer *timer = new Timer();
timer->setCommand(cmd);
timer->setTimeout(timeout);
timer->setTimeout(0, **timeout_res * 1000);
timer->fireOnce(false); // will repeat until window has focus
timer->start();

View file

@ -85,6 +85,11 @@ void Timer::setTimeout(const timeval &t) {
m_timeout.tv_usec = t.tv_usec;
}
void Timer::setTimeout(unsigned int secs, unsigned int usecs) {
m_timeout.tv_sec = secs;
m_timeout.tv_usec = usecs;
}
void Timer::setCommand(RefCount<Command<void> > &cmd) {
m_handler = cmd;
}

View file

@ -64,6 +64,7 @@ public:
void setTimeout(time_t val);
/// set timeout
void setTimeout(const timeval &val);
void setTimeout(unsigned int secs, unsigned int usecs);
void setCommand(RefCount<Command<void> > &cmd);
void setInterval(int val) { m_interval = val; }
/// start timing