diff options
author | fluxgen <fluxgen> | 2003-08-11 15:58:34 (GMT) |
---|---|---|
committer | fluxgen <fluxgen> | 2003-08-11 15:58:34 (GMT) |
commit | af9349661477a4bf15c48df94f498f3955cc7c09 (patch) | |
tree | 6c8cde9c981b0238ea91492cb320fad040f6fb31 /src/FbTk/Timer.cc | |
parent | 586f78c56e9c4fd8b13788695bf7030f16d410a9 (diff) | |
download | fluxbox-af9349661477a4bf15c48df94f498f3955cc7c09.zip fluxbox-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.cc | 16 |
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 | ||
43 | Timer::TimerList Timer::m_timerlist; | 45 | Timer::TimerList Timer::m_timerlist; |
44 | 46 | ||
45 | Timer::Timer(TimeoutHandler *h): | 47 | Timer::Timer():m_timing(false), m_once(false) { |
46 | m_handler(h), | 48 | |
49 | } | ||
50 | |||
51 | Timer::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 | ||
76 | void Timer::setCommand(RefCount<Command> &cmd) { | ||
77 | m_handler = cmd; | ||
78 | } | ||
70 | 79 | ||
71 | void Timer::start() { | 80 | void Timer::start() { |
72 | gettimeofday(&m_start, 0); | 81 | gettimeofday(&m_start, 0); |
@@ -85,7 +94,8 @@ void Timer::stop() { | |||
85 | 94 | ||
86 | 95 | ||
87 | void Timer::fireTimeout() { | 96 | void Timer::fireTimeout() { |
88 | if (m_handler) m_handler->timeout(); | 97 | if (*m_handler) |
98 | m_handler->execute(); | ||
89 | } | 99 | } |
90 | 100 | ||
91 | void Timer::updateTimers(int fd) { | 101 | void Timer::updateTimers(int fd) { |