X-Git-Url: https://git.dogcows.com/gitweb?a=blobdiff_plain;f=openbox%2Fmainloop.c;h=b59564a2075f192eb05e4e0bc05a8d05e7de892d;hb=d77c8f62f2f908cfe1d09686a35dce1ccaf65aec;hp=2e7c190be27de20405c2dc5b993d501e7f445c87;hpb=f6ba1f27b9790f56bda1e5831069e2dd7e2c96a2;p=chaz%2Fopenbox diff --git a/openbox/mainloop.c b/openbox/mainloop.c index 2e7c190b..b59564a2 100644 --- a/openbox/mainloop.c +++ b/openbox/mainloop.c @@ -1,6 +1,7 @@ /* -*- indent-tabs-mode: nil; tab-width: 4; c-basic-offset: 4; -*- mainloop.c for the Openbox window manager + Copyright (c) 2004 Mikael Magnusson Copyright (c) 2003 Ben Jansens This program is free software; you can redistribute it and/or modify @@ -293,7 +294,7 @@ void ob_main_loop_run(ObMainLoop *loop) for (i = 0; i < NUM_SIGNALS; ++i) { while (loop->signals_fired[i]) { for (it = loop->signal_handlers[i]; - it; it = g_slist_next(it)) { + it; it = g_slist_next(it)) { ObMainLoopSignalHandlerType *h = it->data; h->func(i, h->data); } @@ -313,9 +314,9 @@ void ob_main_loop_run(ObMainLoop *loop) } } while (XPending(loop->display)); } else if (loop->action_queue) { - /* only fire off one action at a time, then go back for more - X events, since the action might cause some X events (like - FocusIn :) */ + /* only fire off one action at a time, then go back for more + X events, since the action might cause some X events (like + FocusIn :) */ do { act = loop->action_queue->data; @@ -324,7 +325,7 @@ void ob_main_loop_run(ObMainLoop *loop) { loop->action_queue = g_slist_delete_link(loop->action_queue, - loop->action_queue); + loop->action_queue); action_unref(act); act = NULL; } @@ -553,9 +554,9 @@ void ob_main_loop_fd_remove(ObMainLoop *loop, #define NEAREST_TIMEOUT(loop) \ (((ObMainLoopTimer*)(loop)->timers->data)->timeout) -static long timecompare(GTimeVal *a, GTimeVal *b) +static glong timecompare(GTimeVal *a, GTimeVal *b) { - long r; + glong r; if ((r = b->tv_sec - a->tv_sec)) return r; return b->tv_usec - a->tv_usec; @@ -607,16 +608,18 @@ void ob_main_loop_timeout_remove(ObMainLoop *loop, } } -void ob_main_loop_timeout_remove_data(ObMainLoop *loop, - GSourceFunc handler, - gpointer data) +void ob_main_loop_timeout_remove_data(ObMainLoop *loop, GSourceFunc handler, + gpointer data, gboolean cancel_dest) { GSList *it; for (it = loop->timers; it; it = g_slist_next(it)) { ObMainLoopTimer *t = it->data; - if (t->func == handler && t->data == data) + if (t->func == handler && t->data == data) { t->del_me = TRUE; + if (cancel_dest) + t->destroy = NULL; + } } } @@ -662,10 +665,12 @@ static void timer_dispatch(ObMainLoop *loop, GTimeVal **wait) if (curr->del_me) { /* delete the top */ loop->timers = g_slist_delete_link(loop->timers, it); + if (curr->destroy) + curr->destroy(curr->data); g_free(curr); continue; } - + /* the queue is sorted, so if this timer shouldn't fire, none are ready */ if (timecompare(&NEAREST_TIMEOUT(loop), &loop->now) < 0)