aboutsummaryrefslogtreecommitdiff
path: root/src/FbTk/Timer.cc
diff options
context:
space:
mode:
authorfluxgen <fluxgen>2003-08-11 15:58:34 (GMT)
committerfluxgen <fluxgen>2003-08-11 15:58:34 (GMT)
commitaf9349661477a4bf15c48df94f498f3955cc7c09 (patch)
tree6c8cde9c981b0238ea91492cb320fad040f6fb31 /src/FbTk/Timer.cc
parent586f78c56e9c4fd8b13788695bf7030f16d410a9 (diff)
downloadfluxbox_pavel-af9349661477a4bf15c48df94f498f3955cc7c09.zip
fluxbox_pavel-af9349661477a4bf15c48df94f498f3955cc7c09.tar.bz2
executing a command on timeout instead of calling a TimeoutHandler
Diffstat (limited to 'src/FbTk/Timer.cc')
-rw-r--r--src/FbTk/Timer.cc16
1 files changed, 13 insertions, 3 deletions
diff --git a/src/FbTk/Timer.cc b/src/FbTk/Timer.cc
index 4305658..1597fa3 100644
--- a/src/FbTk/Timer.cc
+++ b/src/FbTk/Timer.cc
@@ -24,6 +24,8 @@
24 24
25#include "Timer.hh" 25#include "Timer.hh"
26 26
27#include "Command.hh"
28
27//use GNU extensions 29//use GNU extensions
28#ifndef _GNU_SOURCE 30#ifndef _GNU_SOURCE
29#define _GNU_SOURCE 31#define _GNU_SOURCE
@@ -42,8 +44,12 @@ namespace FbTk {
42 44
43Timer::TimerList Timer::m_timerlist; 45Timer::TimerList Timer::m_timerlist;
44 46
45Timer::Timer(TimeoutHandler *h): 47Timer::Timer():m_timing(false), m_once(false) {
46 m_handler(h), 48
49}
50
51Timer::Timer(RefCount<Command> &handler):
52 m_handler(handler),
47 m_timing(false), 53 m_timing(false),
48 m_once(false) { 54 m_once(false) {
49} 55}
@@ -67,6 +73,9 @@ void Timer::setTimeout(timeval t) {
67 m_timeout.tv_usec = t.tv_usec; 73 m_timeout.tv_usec = t.tv_usec;
68} 74}
69 75
76void Timer::setCommand(RefCount<Command> &cmd) {
77 m_handler = cmd;
78}
70 79
71void Timer::start() { 80void Timer::start() {
72 gettimeofday(&m_start, 0); 81 gettimeofday(&m_start, 0);
@@ -85,7 +94,8 @@ void Timer::stop() {
85 94
86 95
87void Timer::fireTimeout() { 96void Timer::fireTimeout() {
88 if (m_handler) m_handler->timeout(); 97 if (*m_handler)
98 m_handler->execute();
89} 99}
90 100
91void Timer::updateTimers(int fd) { 101void Timer::updateTimers(int fd) {