diff --git a/clutter/clutter-event.c b/clutter/clutter-event.c index a74338ecd..2f9cf178a 100644 --- a/clutter/clutter-event.c +++ b/clutter/clutter-event.c @@ -765,6 +765,29 @@ clutter_get_current_event_time (void) return CLUTTER_CURRENT_TIME; } +/** + * clutter_get_current_event: + * + * If an event is currently being processed, return that event. + * This function is intended to be used to access event state + * that might not be exposed by higher-level widgets. For + * example, to get the key modifier state from a Button 'clicked' + * event. + * + * Return value: (transfer none): The current ClutterEvent, or %NULL if none + * + * Since: 1.2 + */ +G_CONST_RETURN ClutterEvent * +clutter_get_current_event (void) +{ + ClutterMainContext *context = _clutter_context_get_default (); + + g_return_val_if_fail (context != NULL, NULL); + + return context->current_event; +} + /** * clutter_input_device_get_device_type: * @device: a #ClutterInputDevice diff --git a/clutter/clutter-event.h b/clutter/clutter-event.h index 9ce23455b..03d91549c 100644 --- a/clutter/clutter-event.h +++ b/clutter/clutter-event.h @@ -507,6 +507,7 @@ ClutterScrollDirection clutter_event_get_scroll_direction (ClutterEvent *e guint32 clutter_keysym_to_unicode (guint keyval); guint32 clutter_get_current_event_time (void); +G_CONST_RETURN ClutterEvent *clutter_get_current_event (void); ClutterInputDeviceType clutter_input_device_get_device_type (ClutterInputDevice *device); gint clutter_input_device_get_device_id (ClutterInputDevice *device); diff --git a/clutter/clutter-main.c b/clutter/clutter-main.c index 642085774..3b0f3997e 100644 --- a/clutter/clutter-main.c +++ b/clutter/clutter-main.c @@ -2166,36 +2166,13 @@ clutter_do_event (ClutterEvent *event) _clutter_stage_queue_event (event->any.stage, event); } -/** - * _clutter_process_event - * @event: a #ClutterEvent. - * - * Does the actual work of processing an event that was queued earlier - * out of clutter_do_event(). - */ -void -_clutter_process_event (ClutterEvent *event) +static void +_clutter_process_event_details (ClutterActor *stage, + ClutterMainContext *context, + ClutterEvent *event) { - /* FIXME: This should probably be clutter_cook_event() - it would - * take a raw event from the backend and 'cook' it so its more tasty. - * - */ - ClutterMainContext *context; - ClutterBackend *backend; - ClutterActor *stage; ClutterInputDevice *device = NULL; - context = _clutter_context_get_default (); - backend = context->backend; - stage = CLUTTER_ACTOR(event->any.stage); - - if (!stage) - return; - - CLUTTER_TIMESTAMP (EVENT, "Event received"); - - context->last_event_time = clutter_event_get_time (event); - switch (event->type) { case CLUTTER_NOTHING: @@ -2393,6 +2370,37 @@ _clutter_process_event (ClutterEvent *event) } } +/** + * _clutter_process_event + * @event: a #ClutterEvent. + * + * Does the actual work of processing an event that was queued earlier + * out of clutter_do_event(). + */ +void +_clutter_process_event (ClutterEvent *event) +{ + ClutterMainContext *context; + ClutterBackend *backend; + ClutterActor *stage; + + context = _clutter_context_get_default (); + backend = context->backend; + stage = CLUTTER_ACTOR(event->any.stage); + + if (!stage) + return; + + CLUTTER_TIMESTAMP (EVENT, "Event received"); + + context->last_event_time = clutter_event_get_time (event); + + context->current_event = event; + _clutter_process_event_details (stage, context, event); + context->current_event = NULL; +} + + /** * clutter_get_actor_by_gid * @id: a #ClutterActor ID. diff --git a/clutter/clutter-private.h b/clutter/clutter-private.h index db9a6d2d0..651fbea16 100644 --- a/clutter/clutter-private.h +++ b/clutter/clutter-private.h @@ -128,6 +128,7 @@ struct _ClutterMainContext GSList *input_devices; /* For extra input devices, i.e MultiTouch */ + ClutterEvent *current_event; guint32 last_event_time; gulong redraw_count; diff --git a/doc/reference/clutter/clutter-sections.txt b/doc/reference/clutter/clutter-sections.txt index e7dafd772..c2c432bce 100644 --- a/doc/reference/clutter/clutter-sections.txt +++ b/doc/reference/clutter/clutter-sections.txt @@ -977,6 +977,7 @@ clutter_input_device_get_device_type clutter_get_current_event_time +clutter_get_current_event CLUTTER_TYPE_EVENT