Bug 1440 - Add clutter_get_current_event_time()

The clutter_get_current_event_time() is a global function for
retrieving the timestamp of the current event being propagated
by Clutter. Such function avoids the need to propagate the
timestamp from within user code.
This commit is contained in:
Emmanuele Bassi 2009-02-14 11:38:16 +00:00
parent 0ac6d6637e
commit 9da564b391
4 changed files with 28 additions and 0 deletions

View File

@ -529,3 +529,25 @@ clutter_events_pending (void)
return g_queue_is_empty (context->events_queue) == FALSE;
}
/**
* clutter_get_current_event_time:
*
* Retrieves the timestamp of the last event, if there is an
* event or if the event has a timestamp.
*
* Return value: the event timestamp, or %CLUTTER_CURRENT_TIME
*
* Since: 1.0
*/
guint32
clutter_get_current_event_time (void)
{
ClutterMainContext *context = clutter_context_get_default ();
g_return_val_if_fail (context != NULL, FALSE);
if (context->last_event_time != 0)
return context->last_event_time;
return CLUTTER_CURRENT_TIME;
}

View File

@ -466,6 +466,8 @@ guint32 clutter_keysym_to_unicode (guint keyval);
ClutterStage* clutter_event_get_stage (ClutterEvent *event);
guint32 clutter_get_current_event_time (void);
G_END_DECLS
#endif /* __CLUTTER_EVENT_H__ */

View File

@ -1957,6 +1957,8 @@ clutter_do_event (ClutterEvent *event)
CLUTTER_TIMESTAMP (EVENT, "Event received");
context->last_event_time = clutter_event_get_time (event);
switch (event->type)
{
case CLUTTER_NOTHING:

View File

@ -131,6 +131,8 @@ struct _ClutterMainContext
GSList *input_devices; /* For extra input devices, i.e
MultiTouch */
guint32 last_event_time;
};
#define CLUTTER_CONTEXT() (clutter_context_get_default ())