new timer infrastructure. takes a function pointer for the timeout, with a void* parameter (useful for holding a class instance!)
This commit is contained in:
parent
ad80ef0f66
commit
9259ec5732
15 changed files with 127 additions and 117 deletions
|
@ -1,6 +1,6 @@
|
||||||
# Makefile.am for Openbox
|
# Makefile.am for Openbox
|
||||||
|
|
||||||
SUBDIRS = intl po m4 data doc otk src util
|
SUBDIRS = intl po m4 data doc otk src
|
||||||
MAINTAINERCLEANFILES = aclocal.m4 config.h.in configure Makefile.in stamp-h.in
|
MAINTAINERCLEANFILES = aclocal.m4 config.h.in configure Makefile.in stamp-h.in
|
||||||
|
|
||||||
uninstall-local:
|
uninstall-local:
|
||||||
|
|
|
@ -5,7 +5,7 @@ INCLUDES= -I../src
|
||||||
noinst_LIBRARIES=libotk.a
|
noinst_LIBRARIES=libotk.a
|
||||||
|
|
||||||
libotk_a_SOURCES= color.cc display.cc font.cc gccache.cc image.cc \
|
libotk_a_SOURCES= color.cc display.cc font.cc gccache.cc image.cc \
|
||||||
imagecontrol.cc rect.cc screeninfo.cc texture.cc
|
imagecontrol.cc rect.cc screeninfo.cc texture.cc timer.cc
|
||||||
|
|
||||||
MAINTAINERCLEANFILES= Makefile.in
|
MAINTAINERCLEANFILES= Makefile.in
|
||||||
|
|
||||||
|
@ -13,16 +13,7 @@ distclean-local:
|
||||||
rm -f *\~ *.orig *.rej .\#*
|
rm -f *\~ *.orig *.rej .\#*
|
||||||
|
|
||||||
# local dependencies
|
# local dependencies
|
||||||
color.o: color.cc color.hh ../src/basedisplay.hh ../src/timer.hh ../src/util.hh
|
color.o: color.cc color.hh display.hh screeninfo.hh rect.hh
|
||||||
font.o: font.cc font.hh ../src/screen.hh color.hh texture.hh ../src/util.hh image.hh \
|
gccache.o: gccache.cc gccache.hh display.hh color.hh assassin.hh \
|
||||||
../src/timer.hh ../src/basedisplay.hh ../src/workspace.hh ../src/xatom.hh ../src/blackbox.hh \
|
screeninfo.hh rect.hh
|
||||||
../src/configuration.hh gccache.hh
|
rect.o: rect.cc rect.hh
|
||||||
gccache.o: gccache.cc gccache.hh ../src/basedisplay.hh ../src/timer.hh ../src/util.hh \
|
|
||||||
color.hh
|
|
||||||
image.o: image.cc ../src/blackbox.hh ../src/basedisplay.hh ../src/timer.hh ../src/util.hh \
|
|
||||||
../src/configuration.hh ../src/xatom.hh gccache.hh color.hh image.hh texture.hh
|
|
||||||
imagecontrol.o: imagecontrol.cc ../src/blackbox.hh ../src/basedisplay.hh ../src/timer.hh \
|
|
||||||
../src/util.hh ../src/configuration.hh ../src/xatom.hh color.hh image.hh texture.hh
|
|
||||||
texture.o: texture.cc texture.hh color.hh ../src/util.hh ../src/basedisplay.hh \
|
|
||||||
../src/timer.hh image.hh ../src/screen.hh ../src/workspace.hh ../src/xatom.hh \
|
|
||||||
../src/blackbox.hh ../src/configuration.hh
|
|
||||||
|
|
11
otk/image.hh
11
otk/image.hh
|
@ -11,7 +11,7 @@ extern "C" {
|
||||||
|
|
||||||
#include "color.hh"
|
#include "color.hh"
|
||||||
#include "screeninfo.hh"
|
#include "screeninfo.hh"
|
||||||
#include "src/timer.hh"
|
#include "timer.hh"
|
||||||
|
|
||||||
namespace otk {
|
namespace otk {
|
||||||
|
|
||||||
|
@ -66,7 +66,7 @@ public:
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
class BImageControl : public ob::TimeoutHandler {
|
class BImageControl {
|
||||||
public:
|
public:
|
||||||
struct CachedImage {
|
struct CachedImage {
|
||||||
Pixmap pixmap;
|
Pixmap pixmap;
|
||||||
|
@ -75,7 +75,8 @@ public:
|
||||||
unsigned long pixel1, pixel2, texture;
|
unsigned long pixel1, pixel2, texture;
|
||||||
};
|
};
|
||||||
|
|
||||||
BImageControl(const ScreenInfo *scrn,
|
BImageControl(OBTimerQueueManager *timermanager,
|
||||||
|
const ScreenInfo *scrn,
|
||||||
bool _dither= False, int _cpc = 4,
|
bool _dither= False, int _cpc = 4,
|
||||||
unsigned long cache_timeout = 300000l,
|
unsigned long cache_timeout = 300000l,
|
||||||
unsigned long cmax = 200l);
|
unsigned long cmax = 200l);
|
||||||
|
@ -111,12 +112,12 @@ public:
|
||||||
void setDither(bool d) { dither = d; }
|
void setDither(bool d) { dither = d; }
|
||||||
void setColorsPerChannel(int cpc);
|
void setColorsPerChannel(int cpc);
|
||||||
|
|
||||||
virtual void timeout(void);
|
static void timeout(BImageControl *t);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool dither;
|
bool dither;
|
||||||
const ScreenInfo *screeninfo;
|
const ScreenInfo *screeninfo;
|
||||||
ob::OBTimer *timer;
|
OBTimer *timer;
|
||||||
|
|
||||||
Colormap colormap;
|
Colormap colormap;
|
||||||
|
|
||||||
|
|
|
@ -41,7 +41,8 @@ static unsigned long bsqrt(unsigned long x) {
|
||||||
|
|
||||||
BImageControl *ctrl = 0;
|
BImageControl *ctrl = 0;
|
||||||
|
|
||||||
BImageControl::BImageControl(const ScreenInfo *scrn,
|
BImageControl::BImageControl(OBTimerQueueManager *timermanager,
|
||||||
|
const ScreenInfo *scrn,
|
||||||
bool _dither, int _cpc,
|
bool _dither, int _cpc,
|
||||||
unsigned long cache_timeout,
|
unsigned long cache_timeout,
|
||||||
unsigned long cmax) {
|
unsigned long cmax) {
|
||||||
|
@ -53,12 +54,11 @@ BImageControl::BImageControl(const ScreenInfo *scrn,
|
||||||
|
|
||||||
cache_max = cmax;
|
cache_max = cmax;
|
||||||
if (cache_timeout) {
|
if (cache_timeout) {
|
||||||
// XXX: FIX THIS
|
timer = new OBTimer(timermanager, (OBTimeoutHandler)timeout, this);
|
||||||
timer = 0;/*new BTimer(this);
|
|
||||||
timer->setTimeout(cache_timeout);
|
timer->setTimeout(cache_timeout);
|
||||||
timer->start();*/
|
timer->start();
|
||||||
} else {
|
} else {
|
||||||
timer = (ob::OBTimer *) 0;
|
timer = (OBTimer *) 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
colors = (XColor *) 0;
|
colors = (XColor *) 0;
|
||||||
|
@ -420,7 +420,7 @@ Pixmap BImageControl::renderImage(unsigned int width, unsigned int height,
|
||||||
"forcing cleanout\n");
|
"forcing cleanout\n");
|
||||||
#endif // DEBUG
|
#endif // DEBUG
|
||||||
|
|
||||||
timeout();
|
timeout(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
return pixmap;
|
return pixmap;
|
||||||
|
@ -440,7 +440,7 @@ void BImageControl::removeImage(Pixmap pixmap) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (! timer)
|
if (! timer)
|
||||||
timeout();
|
timeout(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -553,10 +553,10 @@ struct CacheCleaner {
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
void BImageControl::timeout(void) {
|
void BImageControl::timeout(BImageControl *t) {
|
||||||
CacheCleaner cleaner;
|
CacheCleaner cleaner;
|
||||||
std::for_each(cache.begin(), cache.end(), cleaner);
|
std::for_each(t->cache.begin(), t->cache.end(), cleaner);
|
||||||
cache.remove_if(cleaner.ref_check);
|
t->cache.remove_if(cleaner.ref_check);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,67 +4,101 @@
|
||||||
# include "../config.h"
|
# include "../config.h"
|
||||||
#endif // HAVE_CONFIG_H
|
#endif // HAVE_CONFIG_H
|
||||||
|
|
||||||
#include "otk/display.hh"
|
|
||||||
#include "openbox.hh"
|
|
||||||
#include "timer.hh"
|
#include "timer.hh"
|
||||||
|
#include "display.hh"
|
||||||
#include "util.hh"
|
#include "util.hh"
|
||||||
|
|
||||||
namespace ob {
|
namespace otk {
|
||||||
|
|
||||||
OBTimer::OBTimer(TimeoutHandler *h) {
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
OBTimer::OBTimer(OBTimerQueueManager *m, OBTimeoutHandler h, OBTimeoutData d)
|
||||||
|
{
|
||||||
|
manager = m;
|
||||||
handler = h;
|
handler = h;
|
||||||
|
data = d;
|
||||||
|
|
||||||
recur = timing = False;
|
recur = timing = False;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
OBTimer::~OBTimer(void) {
|
OBTimer::~OBTimer(void)
|
||||||
|
{
|
||||||
if (timing) stop();
|
if (timing) stop();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void OBTimer::setTimeout(long t) {
|
void OBTimer::setTimeout(long t)
|
||||||
|
{
|
||||||
_timeout.tv_sec = t / 1000;
|
_timeout.tv_sec = t / 1000;
|
||||||
_timeout.tv_usec = t % 1000;
|
_timeout.tv_usec = t % 1000;
|
||||||
_timeout.tv_usec *= 1000;
|
_timeout.tv_usec *= 1000;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void OBTimer::setTimeout(const timeval &t) {
|
void OBTimer::setTimeout(const timeval &t)
|
||||||
|
{
|
||||||
_timeout.tv_sec = t.tv_sec;
|
_timeout.tv_sec = t.tv_sec;
|
||||||
_timeout.tv_usec = t.tv_usec;
|
_timeout.tv_usec = t.tv_usec;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void OBTimer::start(void) {
|
void OBTimer::start(void)
|
||||||
|
{
|
||||||
gettimeofday(&_start, 0);
|
gettimeofday(&_start, 0);
|
||||||
|
|
||||||
if (! timing) {
|
if (! timing) {
|
||||||
timing = True;
|
timing = True;
|
||||||
Openbox::instance->timerManager()->addTimer(this);
|
manager->addTimer(this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void OBTimer::stop(void) {
|
void OBTimer::stop(void)
|
||||||
|
{
|
||||||
timing = False;
|
timing = False;
|
||||||
|
|
||||||
Openbox::instance->timerManager()->removeTimer(this);
|
manager->removeTimer(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void OBTimer::halt(void) {
|
void OBTimer::halt(void)
|
||||||
|
{
|
||||||
timing = False;
|
timing = False;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void OBTimer::fireTimeout(void) {
|
void OBTimer::fireTimeout(void)
|
||||||
|
{
|
||||||
if (handler)
|
if (handler)
|
||||||
handler->timeout();
|
handler(data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
timeval OBTimer::timeRemaining(const timeval &tm) const {
|
timeval OBTimer::timeRemaining(const timeval &tm) const
|
||||||
|
{
|
||||||
timeval ret = endpoint();
|
timeval ret = endpoint();
|
||||||
|
|
||||||
ret.tv_sec -= tm.tv_sec;
|
ret.tv_sec -= tm.tv_sec;
|
||||||
|
@ -74,7 +108,8 @@ timeval OBTimer::timeRemaining(const timeval &tm) const {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
timeval OBTimer::endpoint(void) const {
|
timeval OBTimer::endpoint(void) const
|
||||||
|
{
|
||||||
timeval ret;
|
timeval ret;
|
||||||
|
|
||||||
ret.tv_sec = _start.tv_sec + _timeout.tv_sec;
|
ret.tv_sec = _start.tv_sec + _timeout.tv_sec;
|
||||||
|
@ -84,7 +119,8 @@ timeval OBTimer::endpoint(void) const {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool OBTimer::shouldFire(const timeval &tm) const {
|
bool OBTimer::shouldFire(const timeval &tm) const
|
||||||
|
{
|
||||||
timeval end = endpoint();
|
timeval end = endpoint();
|
||||||
|
|
||||||
return ! ((tm.tv_sec < end.tv_sec) ||
|
return ! ((tm.tv_sec < end.tv_sec) ||
|
|
@ -19,19 +19,19 @@ extern "C" {
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
namespace ob {
|
namespace otk {
|
||||||
|
|
||||||
// forward declaration
|
// forward declaration
|
||||||
class OBTimerQueueManager;
|
class OBTimerQueueManager;
|
||||||
|
|
||||||
class TimeoutHandler {
|
typedef void *OBTimeoutData;
|
||||||
public:
|
typedef void (*OBTimeoutHandler)(OBTimeoutData);
|
||||||
virtual void timeout(void) = 0;
|
|
||||||
};
|
|
||||||
|
|
||||||
class OBTimer {
|
class OBTimer {
|
||||||
private:
|
private:
|
||||||
TimeoutHandler *handler;
|
OBTimerQueueManager *manager;
|
||||||
|
OBTimeoutHandler handler;
|
||||||
|
OBTimeoutData data;
|
||||||
bool timing, recur;
|
bool timing, recur;
|
||||||
|
|
||||||
timeval _start, _timeout;
|
timeval _start, _timeout;
|
||||||
|
@ -40,29 +40,29 @@ private:
|
||||||
OBTimer& operator=(const OBTimer&);
|
OBTimer& operator=(const OBTimer&);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
OBTimer(TimeoutHandler *h);
|
OBTimer(OBTimerQueueManager *m, OBTimeoutHandler h, OBTimeoutData d);
|
||||||
virtual ~OBTimer(void);
|
virtual ~OBTimer();
|
||||||
|
|
||||||
void fireTimeout(void);
|
void fireTimeout();
|
||||||
|
|
||||||
inline bool isTiming(void) const { return timing; }
|
inline bool isTiming() const { return timing; }
|
||||||
inline bool isRecurring(void) const { return recur; }
|
inline bool isRecurring() const { return recur; }
|
||||||
|
|
||||||
inline const timeval &getTimeout(void) const { return _timeout; }
|
inline const timeval &getTimeout() const { return _timeout; }
|
||||||
inline const timeval &getStartTime(void) const { return _start; }
|
inline const timeval &getStartTime() const { return _start; }
|
||||||
|
|
||||||
timeval timeRemaining(const timeval &tm) const;
|
timeval timeRemaining(const timeval &tm) const;
|
||||||
bool shouldFire(const timeval &tm) const;
|
bool shouldFire(const timeval &tm) const;
|
||||||
timeval endpoint(void) const;
|
timeval endpoint() const;
|
||||||
|
|
||||||
inline void recurring(bool b) { recur = b; }
|
inline void recurring(bool b) { recur = b; }
|
||||||
|
|
||||||
void setTimeout(long t);
|
void setTimeout(long t);
|
||||||
void setTimeout(const timeval &t);
|
void setTimeout(const timeval &t);
|
||||||
|
|
||||||
void start(void); // manager acquires timer
|
void start(); // manager acquires timer
|
||||||
void stop(void); // manager releases timer
|
void stop(); // manager releases timer
|
||||||
void halt(void); // halts the timer
|
void halt(); // halts the timer
|
||||||
|
|
||||||
bool operator<(const OBTimer& other) const
|
bool operator<(const OBTimer& other) const
|
||||||
{ return shouldFire(other.endpoint()); }
|
{ return shouldFire(other.endpoint()); }
|
||||||
|
@ -74,19 +74,19 @@ class _timer_queue: protected std::priority_queue<_Tp, _Sequence, _Compare> {
|
||||||
public:
|
public:
|
||||||
typedef std::priority_queue<_Tp, _Sequence, _Compare> _Base;
|
typedef std::priority_queue<_Tp, _Sequence, _Compare> _Base;
|
||||||
|
|
||||||
_timer_queue(void): _Base() {}
|
_timer_queue(): _Base() {}
|
||||||
~_timer_queue(void) {}
|
~_timer_queue() {}
|
||||||
|
|
||||||
void release(const _Tp& value) {
|
void release(const _Tp& value) {
|
||||||
c.erase(std::remove(c.begin(), c.end(), value), c.end());
|
c.erase(std::remove(c.begin(), c.end(), value), c.end());
|
||||||
// after removing the item we need to make the heap again
|
// after removing the item we need to make the heap again
|
||||||
std::make_heap(c.begin(), c.end(), comp);
|
std::make_heap(c.begin(), c.end(), comp);
|
||||||
}
|
}
|
||||||
bool empty(void) const { return _Base::empty(); }
|
bool empty() const { return _Base::empty(); }
|
||||||
size_t size(void) const { return _Base::size(); }
|
size_t size() const { return _Base::size(); }
|
||||||
void push(const _Tp& value) { _Base::push(value); }
|
void push(const _Tp& value) { _Base::push(value); }
|
||||||
void pop(void) { _Base::pop(); }
|
void pop() { _Base::pop(); }
|
||||||
const _Tp& top(void) const { return _Base::top(); }
|
const _Tp& top() const { return _Base::top(); }
|
||||||
private:
|
private:
|
||||||
// no copying!
|
// no copying!
|
||||||
_timer_queue(const _timer_queue&) {}
|
_timer_queue(const _timer_queue&) {}
|
|
@ -16,7 +16,7 @@ bin_PROGRAMS= openbox
|
||||||
openbox_LDADD=../otk/libotk.a @LIBINTL@
|
openbox_LDADD=../otk/libotk.a @LIBINTL@
|
||||||
|
|
||||||
openbox_SOURCES= configuration.cc screen.cc openbox.cc \
|
openbox_SOURCES= configuration.cc screen.cc openbox.cc \
|
||||||
timer.cc util.cc window.cc workspace.cc xatom.cc blackbox.cc \
|
util.cc window.cc workspace.cc xatom.cc blackbox.cc \
|
||||||
main.cc
|
main.cc
|
||||||
|
|
||||||
MAINTAINERCLEANFILES= Makefile.in
|
MAINTAINERCLEANFILES= Makefile.in
|
||||||
|
|
|
@ -158,7 +158,9 @@ Blackbox::Blackbox(int argc, char **m_argv, char *rc)
|
||||||
|
|
||||||
reconfigure_wait = False;
|
reconfigure_wait = False;
|
||||||
|
|
||||||
timer = new OBTimer(this);
|
timer = new otk::OBTimer(Openbox::instance->timerManager(),
|
||||||
|
(otk::OBTimeoutHandler)timeout,
|
||||||
|
this);
|
||||||
timer->setTimeout(0l);
|
timer->setTimeout(0l);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1151,11 +1153,11 @@ void Blackbox::saveStyleFilename(const string& filename) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void Blackbox::timeout(void) {
|
void Blackbox::timeout(Blackbox *t) {
|
||||||
if (reconfigure_wait)
|
if (t->reconfigure_wait)
|
||||||
real_reconfigure();
|
t->real_reconfigure();
|
||||||
|
|
||||||
reconfigure_wait = False;
|
t->reconfigure_wait = False;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -25,6 +25,7 @@ extern "C" {
|
||||||
#include <map>
|
#include <map>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
|
#include "otk/timer.hh"
|
||||||
#include "openbox.hh"
|
#include "openbox.hh"
|
||||||
#include "configuration.hh"
|
#include "configuration.hh"
|
||||||
#include "timer.hh"
|
#include "timer.hh"
|
||||||
|
@ -69,7 +70,7 @@ class Blackbox;
|
||||||
class BlackboxWindow;
|
class BlackboxWindow;
|
||||||
class BWindowGroup;
|
class BWindowGroup;
|
||||||
|
|
||||||
class Blackbox : public Openbox, public TimeoutHandler {
|
class Blackbox : public Openbox {
|
||||||
private:
|
private:
|
||||||
struct BCursor {
|
struct BCursor {
|
||||||
Cursor session, move, ll_angle, lr_angle, ul_angle, ur_angle;
|
Cursor session, move, ll_angle, lr_angle, ul_angle, ur_angle;
|
||||||
|
@ -109,7 +110,7 @@ private:
|
||||||
|
|
||||||
BScreen *active_screen;
|
BScreen *active_screen;
|
||||||
BlackboxWindow *focused_window, *changing_window;
|
BlackboxWindow *focused_window, *changing_window;
|
||||||
OBTimer *timer;
|
otk::OBTimer *timer;
|
||||||
Configuration config;
|
Configuration config;
|
||||||
XAtom *xatom;
|
XAtom *xatom;
|
||||||
|
|
||||||
|
@ -213,7 +214,7 @@ public:
|
||||||
|
|
||||||
virtual bool handleSignal(int sig);
|
virtual bool handleSignal(int sig);
|
||||||
|
|
||||||
virtual void timeout(void);
|
static void timeout(Blackbox *t);
|
||||||
|
|
||||||
enum { B_AmericanDate = 1, B_EuropeanDate };
|
enum { B_AmericanDate = 1, B_EuropeanDate };
|
||||||
};
|
};
|
||||||
|
|
|
@ -10,7 +10,7 @@ extern "C" {
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#include "otk/screeninfo.hh"
|
#include "otk/screeninfo.hh"
|
||||||
#include "timer.hh"
|
#include "otk/timer.hh"
|
||||||
|
|
||||||
namespace ob {
|
namespace ob {
|
||||||
|
|
||||||
|
@ -35,8 +35,8 @@ private:
|
||||||
char *_displayreq; // display requested by the user
|
char *_displayreq; // display requested by the user
|
||||||
char *_argv0; // argv[0], how the program was called
|
char *_argv0; // argv[0], how the program was called
|
||||||
|
|
||||||
OBTimerQueueManager _timermanager; // manages timers, so that they fire when
|
otk::OBTimerQueueManager _timermanager; // manages timers, so that they fire
|
||||||
// their time elapses
|
// when their time elapses
|
||||||
|
|
||||||
RunState _state; // the state of the window manager
|
RunState _state; // the state of the window manager
|
||||||
|
|
||||||
|
@ -62,7 +62,7 @@ public:
|
||||||
//! Returns the state of the window manager (starting, exiting, etc).
|
//! Returns the state of the window manager (starting, exiting, etc).
|
||||||
inline RunState state() const { return _state; }
|
inline RunState state() const { return _state; }
|
||||||
|
|
||||||
inline OBTimerQueueManager *timerManager() { return &_timermanager; }
|
inline otk::OBTimerQueueManager *timerManager() { return &_timermanager; }
|
||||||
|
|
||||||
void eventLoop();
|
void eventLoop();
|
||||||
|
|
||||||
|
|
|
@ -132,7 +132,8 @@ BScreen::BScreen(Blackbox *bb, unsigned int scrn) : ScreenInfo(scrn) {
|
||||||
updateAvailableArea();
|
updateAvailableArea();
|
||||||
|
|
||||||
image_control =
|
image_control =
|
||||||
new otk::BImageControl(this, True, blackbox->getColorsPerChannel(),
|
new otk::BImageControl(Openbox::instance->timerManager(),
|
||||||
|
this, True, blackbox->getColorsPerChannel(),
|
||||||
blackbox->getCacheLife(), blackbox->getCacheMax());
|
blackbox->getCacheLife(), blackbox->getCacheMax());
|
||||||
image_control->installRootColormap();
|
image_control->installRootColormap();
|
||||||
root_colormap_installed = True;
|
root_colormap_installed = True;
|
||||||
|
@ -779,7 +780,7 @@ void BScreen::reconfigure(void) {
|
||||||
bw->reconfigure();
|
bw->reconfigure();
|
||||||
}
|
}
|
||||||
|
|
||||||
image_control->timeout();
|
otk::BImageControl::timeout(image_control);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
23
src/util.cc
23
src/util.cc
|
@ -83,29 +83,6 @@ string textPropertyToString(Display *display, XTextProperty& text_prop) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
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;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
string itostring(unsigned long i) {
|
string itostring(unsigned long i) {
|
||||||
if (i == 0)
|
if (i == 0)
|
||||||
return string("0");
|
return string("0");
|
||||||
|
|
|
@ -39,8 +39,6 @@ void bexec(const std::string& command, const std::string& displaystring);
|
||||||
|
|
||||||
std::string textPropertyToString(Display *display, XTextProperty& text_prop);
|
std::string textPropertyToString(Display *display, XTextProperty& text_prop);
|
||||||
|
|
||||||
timeval normalizeTimeval(const timeval &tm);
|
|
||||||
|
|
||||||
std::string itostring(unsigned long i);
|
std::string itostring(unsigned long i);
|
||||||
std::string itostring(long i);
|
std::string itostring(long i);
|
||||||
inline std::string itostring(unsigned int i)
|
inline std::string itostring(unsigned int i)
|
||||||
|
|
|
@ -135,7 +135,9 @@ BlackboxWindow::BlackboxWindow(Blackbox *b, Window w, BScreen *s) {
|
||||||
|
|
||||||
lastButtonPressTime = 0;
|
lastButtonPressTime = 0;
|
||||||
|
|
||||||
timer = new OBTimer(this);
|
timer = new otk::OBTimer(Openbox::instance->timerManager(),
|
||||||
|
(otk::OBTimeoutHandler)timeout,
|
||||||
|
this);
|
||||||
timer->setTimeout(blackbox->getAutoRaiseDelay());
|
timer->setTimeout(blackbox->getAutoRaiseDelay());
|
||||||
|
|
||||||
// get size, aspect, minimum/maximum size and other hints set by the
|
// get size, aspect, minimum/maximum size and other hints set by the
|
||||||
|
@ -3902,8 +3904,9 @@ void BlackboxWindow::restore(bool remap) {
|
||||||
|
|
||||||
|
|
||||||
// timer for autoraise
|
// timer for autoraise
|
||||||
void BlackboxWindow::timeout(void) {
|
void BlackboxWindow::timeout(BlackboxWindow *t) {
|
||||||
screen->getWorkspace(blackbox_attrib.workspace)->raiseWindow(this);
|
t->screen->getWorkspace(t->blackbox_attrib.workspace)->raiseWindow(t);
|
||||||
|
printf("TIMED OUT YA YAY\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -12,8 +12,8 @@ extern "C" {
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
|
#include "otk/timer.hh"
|
||||||
#include "blackbox.hh"
|
#include "blackbox.hh"
|
||||||
#include "timer.hh"
|
|
||||||
#include "util.hh"
|
#include "util.hh"
|
||||||
|
|
||||||
#define MwmHintsFunctions (1l << 0)
|
#define MwmHintsFunctions (1l << 0)
|
||||||
|
@ -70,7 +70,7 @@ public:
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
class BlackboxWindow : public TimeoutHandler {
|
class BlackboxWindow {
|
||||||
public:
|
public:
|
||||||
enum Function { Func_Resize = (1l << 0),
|
enum Function { Func_Resize = (1l << 0),
|
||||||
Func_Move = (1l << 1),
|
Func_Move = (1l << 1),
|
||||||
|
@ -105,7 +105,7 @@ private:
|
||||||
Blackbox *blackbox;
|
Blackbox *blackbox;
|
||||||
BScreen *screen;
|
BScreen *screen;
|
||||||
XAtom *xatom;
|
XAtom *xatom;
|
||||||
OBTimer *timer;
|
otk::OBTimer *timer;
|
||||||
BlackboxAttributes blackbox_attrib;
|
BlackboxAttributes blackbox_attrib;
|
||||||
|
|
||||||
Time lastButtonPressTime; // used for double clicks, when were we clicked
|
Time lastButtonPressTime; // used for double clicks, when were we clicked
|
||||||
|
@ -405,7 +405,7 @@ public:
|
||||||
void shapeEvent(XShapeEvent * /*unused*/);
|
void shapeEvent(XShapeEvent * /*unused*/);
|
||||||
#endif // SHAPE
|
#endif // SHAPE
|
||||||
|
|
||||||
virtual void timeout(void);
|
static void timeout(BlackboxWindow *t);
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue