X-Git-Url: https://git.stderr.nl/gitweb?p=projects%2Fchimara%2Fchimara.git;a=blobdiff_plain;f=libchimara%2Fevent.c;fp=libchimara%2Fevent.c;h=dd348a960325836ff8c2174f3a710bf0575ce752;hp=7c916c073b5b8e4eef94b41dd387389f876c653c;hb=9477ab61dc1c188a2ae54ada14ff5fc5669f615f;hpb=f0df98735cb5f3ff524be5689d45bb0ab4a27a74 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; }