aboutsummaryrefslogtreecommitdiff
path: root/src/Timer.hh
diff options
context:
space:
mode:
authorfluxgen <fluxgen>2002-03-19 00:09:59 (GMT)
committerfluxgen <fluxgen>2002-03-19 00:09:59 (GMT)
commit9291eb0911bcb029cb0d3b527f45ffbb95b5d402 (patch)
tree292914f1259f09627f630214e2438df54983e101 /src/Timer.hh
parent6c1f079fbd223946863ad445f8ffffbddf65f169 (diff)
downloadfluxbox-9291eb0911bcb029cb0d3b527f45ffbb95b5d402.zip
fluxbox-9291eb0911bcb029cb0d3b527f45ffbb95b5d402.tar.bz2
moved the update timer routines from BaseDisplay to BTimer and fixed indentation
Diffstat (limited to 'src/Timer.hh')
-rw-r--r--src/Timer.hh84
1 files changed, 43 insertions, 41 deletions
diff --git a/src/Timer.hh b/src/Timer.hh
index bf40c3c..91d03b7 100644
--- a/src/Timer.hh
+++ b/src/Timer.hh
@@ -1,3 +1,6 @@
1// Timer.hh for fluxbox
2// Copyright (c) 2002 Henrik Kinnunen (fluxgen@linuxmail.org)
3//
1// Timer.hh for Blackbox - An X11 Window Manager 4// Timer.hh for Blackbox - An X11 Window Manager
2// Copyright (c) 1997 - 2000 Brad Hughes (bhughes@tcac.net) 5// Copyright (c) 1997 - 2000 Brad Hughes (bhughes@tcac.net)
3// 6//
@@ -13,73 +16,72 @@
13// 16//
14// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 19// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
17// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 21// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
19// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 22// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
20// DEALINGS IN THE SOFTWARE. 23// DEALINGS IN THE SOFTWARE.
21 24
22#ifndef TIMER_HH 25#ifndef TIMER_HH
23#define TIMER_HH 26#define TIMER_HH
24 27
25#ifdef HAVE_CONFIG_H 28#ifdef HAVE_CONFIG_H
26#include "../config.h" 29#include "../config.h"
27#endif //HAVE_CONFIG_H 30#endif //HAVE_CONFIG_H
28 31
29#ifdef TIME_WITH_SYS_TIME 32#ifdef TIME_WITH_SYS_TIME
30# include <sys/time.h> 33# include <sys/time.h>
31# include <time.h> 34# include <time.h>
32#else // !TIME_WITH_SYS_TIME 35#else // !TIME_WITH_SYS_TIME
33# ifdef HAVE_SYS_TIME_H 36# ifdef HAVE_SYS_TIME_H
34#include <sys/time.h> 37#include <sys/time.h>
35# else // !HAVE_SYS_TIME_H 38# else // !HAVE_SYS_TIME_H
36# include <time.h> 39# include <time.h>
37# endif // HAVE_SYS_TIME_H 40# endif // HAVE_SYS_TIME_H
38#endif // TIME_WITH_SYS_TIME 41#endif // TIME_WITH_SYS_TIME
39 42
40// forward declaration 43#include <list>
41class BTimer;
42class TimeoutHandler;
43
44#include "BaseDisplay.hh"
45
46 44
47class TimeoutHandler { 45class TimeoutHandler {
48public: 46public:
49 virtual void timeout(void) = 0; 47 virtual void timeout(void) = 0;
50}; 48};
51 49
52 50
53class BTimer { 51class BTimer {
54 friend class BaseDisplay; 52public:
55private: 53 explicit BTimer(TimeoutHandler *);
56 BaseDisplay *display; 54 virtual ~BTimer(void);
57 TimeoutHandler *handler;
58 int timing, once;
59
60 timeval _start, _timeout;
61
62
63protected:
64 void fireTimeout(void);
65 55
56 inline const int isTiming(void) const { return m_timing; }
57 inline const int doOnce(void) const { return m_once; }
66 58
67public: 59 inline const timeval &getTimeout(void) const { return m_timeout; }
68 BTimer(BaseDisplay *, TimeoutHandler *); 60 inline const timeval &getStartTime(void) const { return m_start; }
69 virtual ~BTimer(void);
70 61
71 inline const int &isTiming(void) const { return timing; } 62 inline void fireOnce(bool once) { m_once = once; }
72 inline const int &doOnce(void) const { return once; }
73 63
74 inline const timeval &getTimeout(void) const { return _timeout; } 64 void setTimeout(long);
75 inline const timeval &getStartTime(void) const { return _start; } 65 void setTimeout(timeval);
66 void start(void);
67 void stop(void);
68 static void updateTimers(int fd);
69protected:
70 void fireTimeout(void);
76 71
77 inline void fireOnce(int o) { once = o; } 72private:
73 static void addTimer(BTimer *timer);
74 static void removeTimer(BTimer *timer);
75
76 typedef std::list<BTimer *> TimerList;
77 static TimerList m_timerlist;
78
79 TimeoutHandler *m_handler;
80
81 bool m_timing, m_once;
82
83 timeval m_start, m_timeout;
78 84
79 void setTimeout(long);
80 void setTimeout(timeval);
81 void start(void);
82 void stop(void);
83}; 85};
84 86
85 87