[PATCH] new timers for ob3
ManMower
manmower at is.fuckingabitch.com
Mon Jan 13 20:14:11 EST 2003
The attached patch replaces the current timer implementation in ob3
these timers are somewhat simpler. there is only one (static) timer
queue, and timers have no explicit start/stop controls.
a = new otk::Timer(callback, timeout, data);
starts a timer that is immediately scheduled in its constructor and fires
every timout milliseconds.
delete a;
stops a running timer.
This code may be used under any license the openbox maintainer desires.
-------------- next part --------------
diff -ur openbox/otk/Makefile.am openbox-newtimers/otk/Makefile.am
--- openbox/otk/Makefile.am 2003-01-13 12:56:07.000000000 -0600
+++ openbox-newtimers/otk/Makefile.am 2003-01-13 13:25:30.000000000 -0600
@@ -10,7 +10,7 @@
libotk_la_SOURCES= color.cc display.cc font.cc gccache.cc image.cc \
property.cc imagecontrol.cc rect.cc screeninfo.cc \
- texture.cc timer.cc timerqueuemanager.cc style.cc \
+ texture.cc timer.cc style.cc \
configuration.cc util.cc widget.cc focuswidget.cc \
button.cc eventhandler.cc eventdispatcher.cc ustring.cc \
label.cc focuslabel.cc application.cc appwidget.cc
@@ -34,18 +34,17 @@
# local dependencies
application.o: application.cc application.hh eventdispatcher.hh \
- eventhandler.hh display.hh configuration.hh timerqueuemanager.hh \
- timerqueue.hh timer.hh image.hh color.hh screeninfo.hh rect.hh \
+ eventhandler.hh display.hh configuration.hh \
+ timer.hh image.hh color.hh screeninfo.hh rect.hh \
point.hh style.hh font.hh texture.hh util.hh widget.hh
appwidget.o: appwidget.cc appwidget.hh widget.hh rect.hh point.hh \
texture.hh color.hh util.hh style.hh font.hh image.hh screeninfo.hh \
timer.hh configuration.hh eventdispatcher.hh eventhandler.hh \
- application.hh display.hh timerqueuemanager.hh timerqueue.hh
+ application.hh display.hh
button.o: button.cc button.hh focuslabel.hh focuswidget.hh widget.hh \
rect.hh point.hh texture.hh color.hh util.hh style.hh font.hh \
image.hh screeninfo.hh timer.hh configuration.hh eventdispatcher.hh \
- eventhandler.hh application.hh display.hh timerqueuemanager.hh \
- timerqueue.hh
+ eventhandler.hh application.hh display.hh
color.o: color.cc color.hh display.hh screeninfo.hh rect.hh point.hh
configuration.o: configuration.cc configuration.hh util.hh
eventdispatcher.o: eventdispatcher.cc eventdispatcher.hh \
@@ -54,13 +53,11 @@
focuslabel.o: focuslabel.cc focuslabel.hh focuswidget.hh widget.hh \
rect.hh point.hh texture.hh color.hh util.hh style.hh font.hh \
image.hh screeninfo.hh timer.hh configuration.hh eventdispatcher.hh \
- eventhandler.hh application.hh display.hh timerqueuemanager.hh \
- timerqueue.hh
+ eventhandler.hh application.hh display.hh
focuswidget.o: focuswidget.cc focuswidget.hh widget.hh rect.hh \
point.hh texture.hh color.hh util.hh style.hh font.hh image.hh \
screeninfo.hh timer.hh configuration.hh eventdispatcher.hh \
- eventhandler.hh application.hh display.hh timerqueuemanager.hh \
- timerqueue.hh
+ eventhandler.hh application.hh display.hh
font.o: font.cc font.hh util.hh display.hh color.hh screeninfo.hh \
rect.hh point.hh
gccache.o: gccache.cc gccache.hh display.hh color.hh assassin.hh \
@@ -72,10 +69,10 @@
label.o: label.cc label.hh widget.hh rect.hh point.hh texture.hh \
color.hh util.hh style.hh font.hh image.hh screeninfo.hh timer.hh \
configuration.hh eventdispatcher.hh eventhandler.hh application.hh \
- display.hh timerqueuemanager.hh timerqueue.hh
+ display.hh
otk_test.o: otk_test.cc application.hh eventdispatcher.hh \
- eventhandler.hh display.hh configuration.hh timerqueuemanager.hh \
- timerqueue.hh timer.hh image.hh color.hh screeninfo.hh rect.hh \
+ eventhandler.hh display.hh configuration.hh \
+ timer.hh image.hh color.hh screeninfo.hh rect.hh \
point.hh style.hh font.hh texture.hh util.hh focuswidget.hh widget.hh \
appwidget.hh button.hh focuslabel.hh
property.o: property.cc property.hh screeninfo.hh rect.hh point.hh \
@@ -88,11 +85,9 @@
configuration.hh
texture.o: texture.cc texture.hh color.hh util.hh display.hh image.hh \
screeninfo.hh rect.hh point.hh timer.hh
-timer.o: timer.cc timer.hh timerqueuemanager.hh timerqueue.hh
-timerqueuemanager.o: timerqueuemanager.cc timerqueuemanager.hh \
- timerqueue.hh timer.hh display.hh
+timer.o: timer.cc timer.hh
util.o: util.cc util.hh
widget.o: widget.cc widget.hh rect.hh point.hh texture.hh color.hh \
util.hh style.hh font.hh image.hh screeninfo.hh timer.hh \
configuration.hh eventdispatcher.hh eventhandler.hh application.hh \
- display.hh timerqueuemanager.hh timerqueue.hh assassin.hh
+ display.hh assassin.hh
diff -ur openbox/otk/application.cc openbox-newtimers/otk/application.cc
--- openbox/otk/application.cc 2003-01-13 12:56:07.000000000 -0600
+++ openbox-newtimers/otk/application.cc 2003-01-13 16:51:57.000000000 -0600
@@ -29,8 +29,8 @@
const ScreenInfo *s_info = _display.screenInfo(DefaultScreen(*_display));
- _timer_manager = new TimerQueueManager();
- _img_ctrl = new ImageControl(_timer_manager, s_info, True, 4, 5, 200);
+ Timer::initialize();
+ _img_ctrl = new ImageControl(s_info, True, 4, 5, 200);
_style_conf = new Configuration(False);
_style = new Style(_img_ctrl);
@@ -39,9 +39,9 @@
Application::~Application()
{
+ Timer::destroy();
delete _style_conf;
delete _img_ctrl;
- delete _timer_manager;
delete _style;
}
@@ -68,7 +68,7 @@
while (_appwidget_count > 0) {
dispatchEvents();
- _timer_manager->fire(); // fire pending events
+ Timer::dispatchTimers(); // fire pending events
}
}
diff -ur openbox/otk/application.hh openbox-newtimers/otk/application.hh
--- openbox/otk/application.hh 2003-01-13 12:56:07.000000000 -0600
+++ openbox-newtimers/otk/application.hh 2003-01-13 13:50:23.000000000 -0600
@@ -5,7 +5,6 @@
#include "eventdispatcher.hh"
#include "display.hh"
#include "configuration.hh"
-#include "timerqueuemanager.hh"
#include "image.hh"
#include "style.hh"
@@ -33,7 +32,6 @@
void loadStyle(void);
Display _display;
- TimerQueueManager *_timer_manager;
ImageControl *_img_ctrl;
Configuration *_style_conf;
Style *_style;
diff -ur openbox/otk/image.hh openbox-newtimers/otk/image.hh
--- openbox/otk/image.hh 2003-01-11 13:17:13.000000000 -0600
+++ openbox-newtimers/otk/image.hh 2003-01-13 13:29:25.000000000 -0600
@@ -77,8 +77,7 @@
};
#endif
- ImageControl(otk::TimerQueueManager *timermanager,
- const otk::ScreenInfo *scrn,
+ ImageControl( const otk::ScreenInfo *scrn,
bool _dither= False, int _cpc = 4,
unsigned long cache_timeout = 300000l,
unsigned long cmax = 200l);
diff -ur openbox/otk/imagecontrol.cc openbox-newtimers/otk/imagecontrol.cc
--- openbox/otk/imagecontrol.cc 2003-01-13 12:56:07.000000000 -0600
+++ openbox-newtimers/otk/imagecontrol.cc 2003-01-13 13:43:34.000000000 -0600
@@ -41,8 +41,7 @@
ImageControl *ctrl = 0;
-ImageControl::ImageControl(TimerQueueManager *timermanager,
- const ScreenInfo *scrn,
+ImageControl::ImageControl( const ScreenInfo *scrn,
bool _dither, int _cpc,
unsigned long cache_timeout,
unsigned long cmax) {
@@ -54,9 +53,7 @@
cache_max = cmax;
if (cache_timeout) {
- timer = new Timer(timermanager, (TimeoutHandler)timeout, this);
- timer->setTimeout(cache_timeout);
- timer->start();
+ timer = new Timer((Timer::TimeoutHandler)timeout, cache_timeout, this);
} else {
timer = (Timer *) 0;
}
@@ -350,10 +347,8 @@
for (; it != end; ++it)
XFreePixmap(**display, it->pixmap);
}
- if (timer) {
- timer->stop();
+ if (timer)
delete timer;
- }
}
diff -ur openbox/otk/otk.hh openbox-newtimers/otk/otk.hh
--- openbox/otk/otk.hh 2003-01-13 12:56:07.000000000 -0600
+++ openbox-newtimers/otk/otk.hh 2003-01-13 13:29:34.000000000 -0600
@@ -26,8 +26,6 @@
#include "style.hh"
#include "texture.hh"
#include "timer.hh"
-#include "timerqueue.hh"
-#include "timerqueuemanager.hh"
#include "util.hh"
#include "ustring.hh"
#include "widget.hh"
diff -ur openbox/otk/otk.i openbox-newtimers/otk/otk.i
--- openbox/otk/otk.i 2003-01-13 12:56:07.000000000 -0600
+++ openbox-newtimers/otk/otk.i 2003-01-13 13:29:48.000000000 -0600
@@ -76,8 +76,6 @@
%include "style.hh"
%include "texture.hh"
%include "timer.hh"
-%include "timerqueue.hh"
-%include "timerqueuemanager.hh"
%include "util.hh"
%include "widget.hh"
diff -ur openbox/otk/timer.cc openbox-newtimers/otk/timer.cc
--- openbox/otk/timer.cc 2003-01-11 13:17:13.000000000 -0600
+++ openbox-newtimers/otk/timer.cc 2003-01-13 18:42:49.000000000 -0600
@@ -4,122 +4,129 @@
# include "../config.h"
#endif // HAVE_CONFIG_H
+#include "display.hh"
#include "timer.hh"
-#include "timerqueuemanager.hh"
+#include <vector>
namespace otk {
-static timeval normalizeTimeval(const timeval &tm)
-{
- timeval ret = tm;
-
- while (ret.tv_usec < 0) {
- if (ret.tv_sec > 0) {
- --ret.tv_sec;
- ret.tv_usec += 1000000;
- } else {
- ret.tv_usec = 0;
- }
- }
-
- if (ret.tv_usec >= 1000000) {
- ret.tv_sec += ret.tv_usec / 1000000;
- ret.tv_usec %= 1000000;
- }
-
- if (ret.tv_sec < 0) ret.tv_sec = 0;
-
- return ret;
-}
-
-
-Timer::Timer(TimerQueueManager *m, TimeoutHandler h, TimeoutData d)
-{
- _manager = m;
- _handler = h;
- _data = d;
-
- _recur = _timing = false;
-}
-
-
-Timer::~Timer(void)
-{
- if (_timing) stop();
-}
-
+timeval Timer::_nearest_timeout, Timer::_now;
+Timer::TimerQ Timer::_q;
-void Timer::setTimeout(long t)
+void Timer::timevalAdd(timeval &a, long msec)
{
- _timeout.tv_sec = t / 1000;
- _timeout.tv_usec = t % 1000;
- _timeout.tv_usec *= 1000;
+ a.tv_sec += msec / 1000;
+ a.tv_usec += (msec % 1000) * 1000;
+ a.tv_sec += a.tv_usec / 1000000;
+ a.tv_usec %= 1000000;
}
-
-void Timer::setTimeout(const timeval &t)
+bool Timer::nearestTimeout(struct timeval &tm)
{
- _timeout.tv_sec = t.tv_sec;
- _timeout.tv_usec = t.tv_usec;
-}
+ if (_q.empty())
+ return false;
+ tm.tv_sec = _nearest_timeout.tv_sec - _now.tv_sec;
+ tm.tv_usec = _nearest_timeout.tv_usec - _now.tv_usec;
+ while (tm.tv_usec < 0) {
+ tm.tv_usec += 1000000;
+ tm.tv_sec--;
+ }
+ tm.tv_sec += tm.tv_usec / 1000000;
+ tm.tv_usec %= 1000000;
+ if (tm.tv_sec < 0)
+ tm.tv_sec = 0;
+
+ return true;
+}
+
+void Timer::dispatchTimers(bool wait)
+{
+ fd_set selset;
+ int fd;
+ timeval next;
+ Timer *curr;
+
+ gettimeofday(&_now, NULL);
+ _nearest_timeout = _now;
+ _nearest_timeout.tv_sec += 10000;
+
+ while (!_q.empty()) {
+ curr = _q.top();
+ /* since we overload the destructor to keep from removing from the middle of
+ the priority queue, set _del_me, we have to do our real delete in here.
+ */
+ if (curr->_del_me) {
+ _q.pop();
+ realDelete(curr);
+ continue;
+ }
-void Timer::start(void)
-{
- gettimeofday(&_start, 0);
+ // the queue is sorted, so if this timer shouldn't fire, none are ready
+ _nearest_timeout = curr->_timeout;
+ if (!timercmp(&_now, &_nearest_timeout, >))
+ break;
+
+ /* we set the last fired time to delay msec after the previous firing, then
+ re-insert. timers maintain their order and may trigger more than once if
+ they've waited more than one delay's worth of time.
+ */
+ _q.pop();
+ timevalAdd(curr->_last, curr->_delay);
+ curr->_action(curr->_data);
+ timevalAdd(curr->_timeout, curr->_delay);
+ _q.push(curr);
+ }
- if (! _timing) {
- _timing = true;
- _manager->addTimer(this);
+ if (wait) {
+ // wait for the nearest trigger, or for X to do something interesting
+ fd = ConnectionNumber(**display);
+ FD_ZERO(&selset);
+ FD_SET(fd, &selset);
+ if (nearestTimeout(next))
+ select(fd + 1, &selset, NULL, NULL, &next);
+ else
+ select(fd + 1, &selset, NULL, NULL, NULL);
}
}
-
-void Timer::stop(void)
+Timer::Timer(Timer::TimeoutHandler action, long delay, void *data)
+ : _action(action),
+ _delay(delay),
+ _data(data),
+ _del_me(false),
+ _last(_now),
+ _timeout(_now)
{
- if (_timing) {
- _timing = false;
-
- _manager->removeTimer(this);
- }
+ timevalAdd(_timeout, delay);
+ _q.push(this);
}
-
-void Timer::fire(void)
+void Timer::operator delete(void *self)
{
- if (_handler)
- _handler(_data);
+ Timer *t;
+ t = (Timer *)self;
+ t->_del_me = true;
}
-
-timeval Timer::remainingTime(const timeval &tm) const
+void Timer::realDelete(Timer *me)
{
- timeval ret = endTime();
-
- ret.tv_sec -= tm.tv_sec;
- ret.tv_usec -= tm.tv_usec;
-
- return normalizeTimeval(ret);
+ ::delete me;
}
-
-timeval Timer::endTime(void) const
+void Timer::initialize(void)
{
- timeval ret;
-
- ret.tv_sec = _start.tv_sec + _timeout.tv_sec;
- ret.tv_usec = _start.tv_usec + _timeout.tv_usec;
-
- return normalizeTimeval(ret);
+ gettimeofday(&_now, NULL);
+ _nearest_timeout.tv_sec = 100000;
+ _nearest_timeout.tv_usec = 0;
}
-
-bool Timer::shouldFire(const timeval &tm) const
+void Timer::destroy(void)
{
- timeval end = endTime();
-
- return ! ((tm.tv_sec < end.tv_sec) ||
- (tm.tv_sec == end.tv_sec && tm.tv_usec < end.tv_usec));
+ while(!_q.empty()) {
+ realDelete(_q.top());
+ _q.pop();
+ }
}
}
diff -ur openbox/otk/timer.hh openbox-newtimers/otk/timer.hh
--- openbox/otk/timer.hh 2003-01-11 13:17:13.000000000 -0600
+++ openbox-newtimers/otk/timer.hh 2003-01-13 18:07:26.000000000 -0600
@@ -2,131 +2,89 @@
#ifndef __timer_hh
#define __timer_hh
-extern "C" {
-#ifdef TIME_WITH_SYS_TIME
-# include <sys/time.h>
-# include <time.h>
-#else // !TIME_WITH_SYS_TIME
-# ifdef HAVE_SYS_TIME_H
-# include <sys/time.h>
-# else // !HAVE_SYS_TIME_H
-# include <time.h>
-# endif // HAVE_SYS_TIME_H
-#endif // TIME_WITH_SYS_TIME
-}
-
-namespace otk {
+/*! @file timer.hh
+ @brief The Timer class implements timed callbacks.
+*/
-class TimerQueueManager;
+#include <sys/time.h>
+#include <unistd.h>
+#include <queue>
-//! The data passed to the TimeoutHandler function.
-/*!
- Note: this is a very useful place to put an object instance, and set the
- event handler to a static function in the same class.
-*/
-typedef void *TimeoutData;
-//! The type of function which can be set as the callback for a Timer firing
-typedef void (*TimeoutHandler)(TimeoutData);
+namespace otk {
-//! A Timer class which will fire a function when its time elapses
class Timer {
+public:
+ //!data type of Timer callback
+ typedef void (*TimeoutHandler)(void *data);
+
private:
- //! The manager which to add ourself to and remove ourself after we are done
- TimerQueueManager *_manager;
- //! The function to call when the time elapses
- TimeoutHandler _handler;
- //! The data which gets passed along to the TimeoutHandler
- TimeoutData _data;
- //! Determines if the timer is currently started
- bool _timing;
- //! When this is true, the timer will reset itself to fire again every time
- bool _recur;
-
- //! The time at which the timer started
- timeval _start;
- //! The time at which the timer is going to fire
- timeval _timeout;
-
- //! Disallows copying of Timer objects
- Timer(const Timer&);
- //! Disallows copying of Timer objects
- Timer& operator=(const Timer&);
+ //! Compares two timeval structs
+ struct TimerCompare {
+ //! Compares two timeval structs
+ inline bool operator()(const Timer *a, const Timer *b) const {
+ return timercmp(&a->_timeout, &b->_timeout, >);
+ }
+ };
+
+ typedef
+ std::priority_queue<Timer*, std::vector<Timer*>, TimerCompare> TimerQ;
+
+ //! callback for timer expiry
+ TimeoutHandler _action;
+ //! milliseconds between timer firings
+ long _delay;
+ //! data sent to callback
+ void *_data;
+ //! We overload the destructor to just set this
+ bool _del_me;
+ //! the time the last fire should've been at
+ struct timeval _last;
+ //! when this timer will next trigger
+ struct timeval _timeout;
+
+ //! queue of pending timers
+ static TimerQ _q;
+ //! time next timer will expire
+ static timeval _nearest_timeout;
+ //! time at start of current processing loop
+ static timeval _now;
+
+ //! really delete something (not just flag for later)
+ //! @param self Timer to be deleted
+ static void realDelete(Timer *self);
+
+ //! adds a millisecond delay to a timeval structure
+ /*! @param a timeval to increment
+ @param msec number of milliseconds to increment by
+ */
+ static void timevalAdd(timeval &a, long msec);
public:
- //! Constructs a new Timer object
+ //! Constructs a new running timer and queues it
/*!
- @param m The TimerQueueManager with which to associate. The manager
- specified will be resposible for making this timer fire.
- @param h The function to call when the timer fires
- @param d The data to pass along to the function call when the timer fires
+ @param cb The function to be called on fire
+ @param delay Time in millisecond between firings
+ @param data Data to be passed to the callback on fire
*/
- Timer(TimerQueueManager *m, TimeoutHandler h, TimeoutData d);
- //! Destroys the Timer object
- virtual ~Timer();
-
- //! Fires the timer, calling its TimeoutHandler
- void fire();
-
- //! Returns if the Timer is started and timing
- inline bool timing() const { return _timing; }
- //! Returns if the Timer is going to repeat
- inline bool recurring() const { return _recur; }
-
- //! Gets the amount of time the Timer should last before firing
- inline const timeval &timeout() const { return _timeout; }
- //! Gets the time at which the Timer started
- inline const timeval &startTime() const { return _start; }
-
- //! Gets the amount of time left before the Timer fires
- timeval remainingTime(const timeval &tm) const;
- //! Returns if the Timer is past its timeout time, and should fire
- bool shouldFire(const timeval &tm) const;
+ Timer(TimeoutHandler cb, long delay, void *data);
- //! Gets the time at which the Timer will fire
- timeval endTime() const;
+ //! Overloaded delete so we can leave deleted objects in queue for later reap
+ //! @param self pointer to current instance of Timer
+ void operator delete(void *self);
- //! Sets the Timer to repeat or not
- /*!
- @param b If true, the timer is set to repeat; otherwise, it will fire only
- once
- */
- inline void setRecurring(bool b) { _recur = b; }
+ //! dispatches all elligible timers then optionally waits for X events
+ //! @param wait whether to wait for X events after processing timers
+ static void dispatchTimers(bool wait = true);
- //! Sets the amount of time for the Timer to last in milliseconds
- /*!
- @param t The number of milliseconds the timer should last
- */
- void setTimeout(long t);
- //! Sets the amount of time the Timer should last before firing
- /*!
- @param t The amount of time the timer should last
- */
- void setTimeout(const timeval &t);
+ //! returns a relative timeval (to pass select) of the next timer
+ //! @param tm returns time until next timer
+ static bool nearestTimeout(struct timeval &tm);
- //! Causes the timer to begin
- /*!
- The timer fires after the time in Timer::getTimeout has passed since this
- function was called.
- Calling this function while the timer is already started will cause it to
- restart its countdown.
- */
- void start(); // manager acquires timer
- //! Causes the timer to stop
- /*!
- The timer will no longer fire once this function has been called.
- Calling this function more than once does not have any effect.
- */
- void stop(); // manager releases timer
+ //! initializes internal data before use
+ static void initialize(void);
- //! Determines if this Timer will fire before a second Timer object
- /*!
- @param other The second Timer with which to compare
- @return true if this Timer will fire before 'other'; otherwise, false
- */
- bool operator<(const Timer& other) const
- { return shouldFire(other.endTime()); }
+ //! deletes all waiting timers
+ static void destroy(void);
};
-
}
-
-#endif // __timer_hh
+#endif // __timer.hh
Only in openbox/otk: timerqueue.hh
Only in openbox/otk: timerqueuemanager.cc
Only in openbox/otk: timerqueuemanager.hh
diff -ur openbox/src/bindings.cc openbox-newtimers/src/bindings.cc
--- openbox/src/bindings.cc 2003-01-13 12:56:07.000000000 -0600
+++ openbox-newtimers/src/bindings.cc 2003-01-13 14:43:18.000000000 -0600
@@ -144,12 +144,9 @@
Bindings::Bindings()
: _curpos(&_keytree),
- _resetkey(0,0),
- _timer(openbox->timerManager(),
- (otk::TimeoutHandler)resetChains, this)
+ _resetkey(0,0)
{
- _timer.setTimeout(5000); // chains reset after 5 seconds
-
+ _timer = NULL;
// setResetKey("C-g"); // set the default reset key
}
@@ -379,7 +376,10 @@
while (p) {
if (p->binding.key == key && p->binding.modifiers == modifiers) {
if (p->chain) {
- _timer.start(); // start/restart the timer
+ if (_timer)
+ delete _timer;
+ _timer = new otk::Timer((otk::Timer::TimeoutHandler)resetChains,
+ 5000,this); // 5 second timeout
// grab the server here to make sure no key pressed go missed
otk::display->grab();
grabKeys(false);
@@ -403,7 +403,8 @@
void Bindings::resetChains(Bindings *self)
{
- self->_timer.stop();
+ if (self->_timer)
+ delete self->_timer;
// grab the server here to make sure no key pressed go missed
otk::display->grab();
self->grabKeys(false);
diff -ur openbox/src/bindings.hh openbox-newtimers/src/bindings.hh
--- openbox/src/bindings.hh 2003-01-11 13:42:42.000000000 -0600
+++ openbox-newtimers/src/bindings.hh 2003-01-13 14:34:16.000000000 -0600
@@ -67,7 +67,7 @@
Binding _resetkey; // the key which resets the key chain status
- otk::Timer _timer;
+ otk::Timer *_timer;
KeyBindingTree *find(KeyBindingTree *search, bool *conflict) const;
KeyBindingTree *buildtree(const StringVect &keylist,
diff -ur openbox/src/openbox.cc openbox-newtimers/src/openbox.cc
--- openbox/src/openbox.cc 2003-01-13 12:56:07.000000000 -0600
+++ openbox-newtimers/src/openbox.cc 2003-01-13 16:52:58.000000000 -0600
@@ -113,6 +113,7 @@
sigaction(SIGINT, &action, (struct sigaction *) 0);
sigaction(SIGHUP, &action, (struct sigaction *) 0);
+ otk::Timer::initialize();
_property = new otk::Property();
_actions = new Actions();
_bindings = new Bindings();
@@ -194,6 +195,8 @@
// all im gunna do is the same.
//otk::display->destroy();
+ otk::Timer::destroy();
+
if (_restart) {
if (!_restart_prog.empty()) {
const std::string &dstr =
@@ -320,7 +323,7 @@
XFlush(**otk::display); // flush here before we go wait for timers
// don't wait if we're to shutdown
if (_shutdown) break;
- _timermanager.fire(!_sync); // wait if not in sync mode
+ otk::Timer::dispatchTimers(!_sync); // wait if not in sync mode
}
}
diff -ur openbox/src/openbox.hh openbox-newtimers/src/openbox.hh
--- openbox/src/openbox.hh 2003-01-13 12:56:07.000000000 -0600
+++ openbox-newtimers/src/openbox.hh 2003-01-13 14:27:00.000000000 -0600
@@ -16,7 +16,6 @@
#include "otk/display.hh"
#include "otk/screeninfo.hh"
-#include "otk/timerqueuemanager.hh"
#include "otk/property.hh"
#include "otk/configuration.hh"
#include "otk/eventdispatcher.hh"
@@ -109,13 +108,6 @@
//! A list of all the managed screens
ScreenList _screens;
- //! Manages all timers for the application
- /*!
- Use of the otk::TimerQueueManager::fire funtion in this object ensures
- that all timers fire when their times elapse.
- */
- otk::TimerQueueManager _timermanager;
-
//! Cached atoms on the display
/*!
This is a pointer because the Property class uses otk::Display::display
@@ -185,13 +177,6 @@
//! Returns the state of the window manager (starting, exiting, etc)
inline RunState state() const { return _state; }
- //! Returns the otk::TimerQueueManager for the application
- /*!
- All otk::Timer objects used in the application should be made to use this
- otk::TimerQueueManager.
- */
- inline otk::TimerQueueManager *timerManager() { return &_timermanager; }
-
//! Returns the otk::Property instance for the window manager
inline const otk::Property *property() const { return _property; }
diff -ur openbox/src/openbox.i openbox-newtimers/src/openbox.i
--- openbox/src/openbox.i 2003-01-13 13:02:44.000000000 -0600
+++ openbox-newtimers/src/openbox.i 2003-01-13 18:47:48.000000000 -0600
@@ -122,6 +122,7 @@
%include "../otk/rect.hh"
%include "../otk/screeninfo.hh"
%include "../otk/strut.hh"
+%include "../otk/timer.hh"
%include "../otk/eventhandler.hh"
%include "../otk/eventdispatcher.hh"
diff -ur openbox/src/screen.cc openbox-newtimers/src/screen.cc
--- openbox/src/screen.cc 2003-01-13 12:56:09.000000000 -0600
+++ openbox-newtimers/src/screen.cc 2003-01-13 14:30:10.000000000 -0600
@@ -75,8 +75,7 @@
openbox->cursors().session);
// initialize the shit that is used for all drawing on the screen
- _image_control = new otk::ImageControl(openbox->timerManager(),
- _info, true);
+ _image_control = new otk::ImageControl(_info, true);
_image_control->installRootColormap();
_root_cmap_installed = True;
More information about the openbox
mailing list