X-Git-Url: https://git.dogcows.com/gitweb?a=blobdiff_plain;f=openbox%2Ftimer.c;h=b6a82cd37fe7eba1443f3268265d70d6ffe0d4fc;hb=0a69cfc6d2cf672634e95d5eb2015434dd924abc;hp=0cec366f16a9eefa90158a7b60733c0496657e3f;hpb=b10548f0ddf7ac9deb85372332686c6d8651a1f6;p=chaz%2Fopenbox diff --git a/openbox/timer.c b/openbox/timer.c index 0cec366f..b6a82cd3 100644 --- a/openbox/timer.c +++ b/openbox/timer.c @@ -10,12 +10,21 @@ static GSList *timers; /* nearest timer is at the top */ #define NEAREST_TIMEOUT (((Timer*)timers->data)->timeout) +static long timecompare(GTimeVal *a, GTimeVal *b) +{ + long r; + + if ((r = b->tv_sec - a->tv_sec)) return r; + return b->tv_usec - a->tv_sec; + +} + static void insert_timer(Timer *self) { GSList *it; for (it = timers; it != NULL; it = it->next) { Timer *t = it->data; - if (!timercmp(&self->timeout, &t->timeout, >)) { + if (timecompare(&self->timeout, &t->timeout) <= 0) { timers = g_slist_insert_before(timers, it, self); break; } @@ -99,7 +108,7 @@ void timer_dispatch(GTimeVal **wait) /* the queue is sorted, so if this timer shouldn't fire, none are ready */ - if (!timercmp(&now, &NEAREST_TIMEOUT, >)) + if (timecompare(&now, &NEAREST_TIMEOUT) <= 0) break; /* we set the last fired time to delay msec after the previous firing,