diff --git a/clutter/clutter/clutter-event.c b/clutter/clutter/clutter-event.c index 9c53579a4..bcda1bb7b 100644 --- a/clutter/clutter/clutter-event.c +++ b/clutter/clutter/clutter-event.c @@ -510,6 +510,27 @@ clutter_event_get_position (const ClutterEvent *event, } +/** + * clutter_event_get_source: + * @event: a #ClutterEvent + * + * Retrieves the source #ClutterActor the event originated from, or + * NULL if the event has no source. + * + * Return value: (transfer none): a #ClutterActor + */ +ClutterActor * +clutter_event_get_source (const ClutterEvent *event) +{ + g_return_val_if_fail (event != NULL, NULL); + + if (event->type == CLUTTER_ENTER || + event->type == CLUTTER_LEAVE) + return event->crossing.source; + + return NULL; +} + /** * clutter_event_get_flags: * @event: a #ClutterEvent diff --git a/clutter/clutter/clutter-event.h b/clutter/clutter/clutter-event.h index 282b9a68b..2f5b2a207 100644 --- a/clutter/clutter/clutter-event.h +++ b/clutter/clutter/clutter-event.h @@ -170,6 +170,8 @@ ClutterInputDevice * clutter_event_get_source_device (const ClutterEv CLUTTER_EXPORT ClutterInputDeviceTool *clutter_event_get_device_tool (const ClutterEvent *event); +CLUTTER_DEPRECATED +ClutterActor * clutter_event_get_source (const ClutterEvent *event); CLUTTER_EXPORT ClutterInputDeviceType clutter_event_get_device_type (const ClutterEvent *event); CLUTTER_EXPORT