From 4fce0b974b923ec1c272456c5360bb5c35428b8e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonas=20Dre=C3=9Fler?= Date: Wed, 3 Aug 2022 19:24:45 +0200 Subject: [PATCH] clutter: Add source field to crossing events The source field was removed from ClutterEvent with commit b644ea1bcebfef2fb3ed4b6b7de602000cece33b because the preferred way of getting the event actor is now to use the device/sequence actor from the stage directly. With crossing events it's not that easy though, as crossing events explicitly have a source and related actor that doesn't have to be the same actor as the device actor. Since we kept around the "related" field there anyway, let's also introduce a "source" field in ClutterCrossingEvent and return that actor when get_source() is called on a crossing event. Part-of: --- clutter/clutter/clutter-event.c | 4 ++++ clutter/clutter/clutter-event.h | 1 + clutter/clutter/clutter-stage.c | 1 + 3 files changed, 6 insertions(+) diff --git a/clutter/clutter/clutter-event.c b/clutter/clutter/clutter-event.c index 6d2c19ff2..667fe8c96 100644 --- a/clutter/clutter/clutter-event.c +++ b/clutter/clutter/clutter-event.c @@ -509,6 +509,10 @@ 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 clutter_stage_get_event_actor (clutter_event_get_stage (event), event); } diff --git a/clutter/clutter/clutter-event.h b/clutter/clutter/clutter-event.h index 1220ef21d..132f96820 100644 --- a/clutter/clutter/clutter-event.h +++ b/clutter/clutter/clutter-event.h @@ -242,6 +242,7 @@ struct _ClutterCrossingEvent gfloat y; ClutterInputDevice *device; ClutterEventSequence *sequence; + ClutterActor *source; ClutterActor *related; }; diff --git a/clutter/clutter/clutter-stage.c b/clutter/clutter/clutter-stage.c index 714883d3a..56919c827 100644 --- a/clutter/clutter/clutter-stage.c +++ b/clutter/clutter/clutter-stage.c @@ -3400,6 +3400,7 @@ create_crossing_event (ClutterStage *stage, event->crossing.stage = stage; event->crossing.x = coords.x; event->crossing.y = coords.y; + event->crossing.source = source; event->crossing.related = related; event->crossing.sequence = sequence; clutter_event_set_device (event, device);