diff options
author | Pavel Labath <pavelo@centrum.sk> | 2011-07-09 22:10:48 (GMT) |
---|---|---|
committer | Pavel Labath <pavelo@centrum.sk> | 2011-07-10 12:16:35 (GMT) |
commit | 5c83dee70a1e089b23a5c901455f61e99e30f0dd (patch) | |
tree | c501ce4f1980d5c099872632bb6e045fb51f462c /src | |
parent | 2f075e186901ddff068f13da22a09cca68bd54d9 (diff) | |
download | fluxbox_pavel-5c83dee70a1e089b23a5c901455f61e99e30f0dd.zip fluxbox_pavel-5c83dee70a1e089b23a5c901455f61e99e30f0dd.tar.bz2 |
FbTk::Timer accepts Slots instead of Commands as the former are more general
Diffstat (limited to 'src')
-rw-r--r-- | src/FbTk/Timer.cc | 8 | ||||
-rw-r--r-- | src/FbTk/Timer.hh | 8 |
2 files changed, 8 insertions, 8 deletions
diff --git a/src/FbTk/Timer.cc b/src/FbTk/Timer.cc index cb9ac59..13bfc05 100644 --- a/src/FbTk/Timer.cc +++ b/src/FbTk/Timer.cc | |||
@@ -59,7 +59,7 @@ Timer::Timer():m_timing(false), m_once(false), m_interval(0) { | |||
59 | 59 | ||
60 | } | 60 | } |
61 | 61 | ||
62 | Timer::Timer(RefCount<Command<void> > &handler): | 62 | Timer::Timer(const RefCount<Slot<void> > &handler): |
63 | m_handler(handler), | 63 | m_handler(handler), |
64 | m_timing(false), | 64 | m_timing(false), |
65 | m_once(false), | 65 | m_once(false), |
@@ -90,7 +90,7 @@ void Timer::setTimeout(unsigned int secs, unsigned int usecs) { | |||
90 | m_timeout.tv_usec = usecs; | 90 | m_timeout.tv_usec = usecs; |
91 | } | 91 | } |
92 | 92 | ||
93 | void Timer::setCommand(RefCount<Command<void> > &cmd) { | 93 | void Timer::setCommand(const RefCount<Slot<void> > &cmd) { |
94 | m_handler = cmd; | 94 | m_handler = cmd; |
95 | } | 95 | } |
96 | 96 | ||
@@ -122,7 +122,7 @@ void Timer::makeEndTime(timeval &tm) const { | |||
122 | 122 | ||
123 | void Timer::fireTimeout() { | 123 | void Timer::fireTimeout() { |
124 | if (m_handler) | 124 | if (m_handler) |
125 | m_handler->execute(); | 125 | (*m_handler)(); |
126 | } | 126 | } |
127 | 127 | ||
128 | void Timer::updateTimers(int fd) { | 128 | void Timer::updateTimers(int fd) { |
@@ -284,7 +284,7 @@ Command<void> *DelayedCmd::parse(const std::string &command, | |||
284 | 284 | ||
285 | REGISTER_COMMAND_PARSER(delay, DelayedCmd::parse, void); | 285 | REGISTER_COMMAND_PARSER(delay, DelayedCmd::parse, void); |
286 | 286 | ||
287 | DelayedCmd::DelayedCmd(RefCount<Command<void> > &cmd, unsigned int timeout) { | 287 | DelayedCmd::DelayedCmd(const RefCount<Slot<void> > &cmd, unsigned int timeout) { |
288 | timeval to; // defaults to 200ms | 288 | timeval to; // defaults to 200ms |
289 | to.tv_sec = timeout/1000000; | 289 | to.tv_sec = timeout/1000000; |
290 | to.tv_usec = timeout % 1000000; | 290 | to.tv_usec = timeout % 1000000; |
diff --git a/src/FbTk/Timer.hh b/src/FbTk/Timer.hh index e61d77f..4b5a10e 100644 --- a/src/FbTk/Timer.hh +++ b/src/FbTk/Timer.hh | |||
@@ -56,7 +56,7 @@ namespace FbTk { | |||
56 | class Timer { | 56 | class Timer { |
57 | public: | 57 | public: |
58 | Timer(); | 58 | Timer(); |
59 | explicit Timer(RefCount<Command<void> > &handler); | 59 | explicit Timer(const RefCount<Slot<void> > &handler); |
60 | virtual ~Timer(); | 60 | virtual ~Timer(); |
61 | 61 | ||
62 | void fireOnce(bool once) { m_once = once; } | 62 | void fireOnce(bool once) { m_once = once; } |
@@ -65,7 +65,7 @@ public: | |||
65 | /// set timeout | 65 | /// set timeout |
66 | void setTimeout(const timeval &val); | 66 | void setTimeout(const timeval &val); |
67 | void setTimeout(unsigned int secs, unsigned int usecs); | 67 | void setTimeout(unsigned int secs, unsigned int usecs); |
68 | void setCommand(RefCount<Command<void> > &cmd); | 68 | void setCommand(const RefCount<Slot<void> > &cmd); |
69 | void setInterval(int val) { m_interval = val; } | 69 | void setInterval(int val) { m_interval = val; } |
70 | /// start timing | 70 | /// start timing |
71 | void start(); | 71 | void start(); |
@@ -96,7 +96,7 @@ private: | |||
96 | typedef std::list<Timer *> TimerList; | 96 | typedef std::list<Timer *> TimerList; |
97 | static TimerList m_timerlist; ///< list of all timers, sorted by next trigger time (start + timeout) | 97 | static TimerList m_timerlist; ///< list of all timers, sorted by next trigger time (start + timeout) |
98 | 98 | ||
99 | RefCount<Command<void> > m_handler; ///< what to do on a timeout | 99 | RefCount<Slot<void> > m_handler; ///< what to do on a timeout |
100 | 100 | ||
101 | bool m_timing; ///< clock running? | 101 | bool m_timing; ///< clock running? |
102 | bool m_once; ///< do timeout only once? | 102 | bool m_once; ///< do timeout only once? |
@@ -110,7 +110,7 @@ private: | |||
110 | /// executes a command after a specified timeout | 110 | /// executes a command after a specified timeout |
111 | class DelayedCmd: public Command<void> { | 111 | class DelayedCmd: public Command<void> { |
112 | public: | 112 | public: |
113 | DelayedCmd(RefCount<Command<void> > &cmd, unsigned int timeout = 200000); | 113 | DelayedCmd(const RefCount<Slot<void> > &cmd, unsigned int timeout = 200000); |
114 | void execute(); | 114 | void execute(); |
115 | static Command<void> *parse(const std::string &command, | 115 | static Command<void> *parse(const std::string &command, |
116 | const std::string &args, bool trusted); | 116 | const std::string &args, bool trusted); |