1 // Timer.hh for Blackbox - An X11 Window Manager
2 // Copyright (c) 1997 - 1999 Brad Hughes (bhughes@tcac.net)
4 // Permission is hereby granted, free of charge, to any person obtaining a
5 // copy of this software and associated documentation files (the "Software"),
6 // to deal in the Software without restriction, including without limitation
7 // the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 // and/or sell copies of the Software, and to permit persons to whom the
9 // Software is furnished to do so, subject to the following conditions:
11 // The above copyright notice and this permission notice shall be included in
12 // all copies or substantial portions of the Software.
14 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 // 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
18 // 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
20 // DEALINGS IN THE SOFTWARE.
25 #ifdef TIME_WITH_SYS_TIME
26 # include <sys/time.h>
28 #else // !TIME_WITH_SYS_TIME
29 # ifdef HAVE_SYS_TIME_H
30 # include <sys/time.h>
31 # else // !HAVE_SYS_TIME_H
33 # endif // HAVE_SYS_TIME_H
34 #endif // TIME_WITH_SYS_TIME
36 // forward declaration
40 #include "BaseDisplay.hh"
43 class TimeoutHandler
{
45 virtual void timeout(void) = 0;
53 TimeoutHandler
*handler
;
56 timeval _start
, _timeout
;
60 void fireTimeout(void);
64 BTimer(BaseDisplay
*, TimeoutHandler
*);
65 virtual ~BTimer(void);
67 inline int &isTiming(void) { return timing
; }
68 inline int &doOnce(void) { return once
; }
70 inline const timeval
&getTimeout(void) const { return _timeout
; }
71 inline const timeval
&getStartTime(void) const { return _start
; }
73 inline void fireOnce(int o
) { once
= o
; }
75 void setTimeout(long);
76 void setTimeout(timeval
);