X-Git-Url: https://git.stderr.nl/gitweb?a=blobdiff_plain;f=libchimara%2Fevent.c;h=dd348a960325836ff8c2174f3a710bf0575ce752;hb=fabdd6909a49dcf126b066bc37475b81754b58a7;hp=7c916c073b5b8e4eef94b41dd387389f876c653c;hpb=e4a75256e901a89729c48fcc2f9229cd0cfe9124;p=projects%2Fchimara%2Fchimara.git diff --git a/libchimara/event.c b/libchimara/event.c index 7c916c0..dd348a9 100644 --- a/libchimara/event.c +++ b/libchimara/event.c @@ -23,17 +23,15 @@ event_throw(ChimaraGlk *glk, glui32 type, winid_t win, glui32 val1, glui32 val2) if(!priv->event_queue) return; - GTimeVal timeout; - g_get_current_time(&timeout); - g_time_val_add(&timeout, EVENT_TIMEOUT_MICROSECONDS); + gint64 timeout = g_get_monotonic_time() + EVENT_TIMEOUT_MICROSECONDS; g_mutex_lock(&priv->event_lock); /* Wait for room in the event queue */ while( g_queue_get_length(priv->event_queue) >= EVENT_QUEUE_MAX_LENGTH ) - if( !g_cond_timed_wait(&priv->event_queue_not_full, &priv->event_lock, &timeout) ) + if( !g_cond_wait_until(&priv->event_queue_not_full, &priv->event_lock, timeout) ) { - /* Drop the event after 3 seconds */ + /* Drop the event if the event queue is still not emptying */ g_mutex_unlock(&priv->event_lock); return; }