From 2aeaeece7d6e8ed30dfd317f695f0791ac3ee4c7 Mon Sep 17 00:00:00 2001 From: Carlos Garnacho Date: Fri, 25 Feb 2022 16:15:43 +0100 Subject: [PATCH] clutter: Rewrite clutter_event_[gs]et_source() It does not make sense that the event "source" (aka the target) is both content and recipient of a message. Not doing so, events become largely independent of the actor that is receiving/handling an event. This is small step toward making events opaque and immutable. Every user of these API calls in our code have ported away from them, but other users may remain in extensions, so make these functions work on top of the alternative API without accessing the soon to be removed event field. Part-of: --- clutter/clutter/clutter-event.c | 7 ++----- clutter/clutter/clutter-event.h | 4 ++-- 2 files changed, 4 insertions(+), 7 deletions(-) diff --git a/clutter/clutter/clutter-event.c b/clutter/clutter/clutter-event.c index 05cd7ba49..b1a5b6252 100644 --- a/clutter/clutter/clutter-event.c +++ b/clutter/clutter/clutter-event.c @@ -541,7 +541,8 @@ clutter_event_get_source (const ClutterEvent *event) { g_return_val_if_fail (event != NULL, NULL); - return event->any.source; + return clutter_stage_get_event_actor (clutter_event_get_stage (event), + event); } /** @@ -557,10 +558,6 @@ void clutter_event_set_source (ClutterEvent *event, ClutterActor *actor) { - g_return_if_fail (event != NULL); - g_return_if_fail (actor == NULL || CLUTTER_IS_ACTOR (actor)); - - event->any.source = actor; } /** diff --git a/clutter/clutter/clutter-event.h b/clutter/clutter/clutter-event.h index 1378d91e0..49b86247b 100644 --- a/clutter/clutter/clutter-event.h +++ b/clutter/clutter/clutter-event.h @@ -716,10 +716,10 @@ void clutter_event_set_device_tool (ClutterEvent CLUTTER_EXPORT ClutterInputDeviceTool *clutter_event_get_device_tool (const ClutterEvent *event); -CLUTTER_EXPORT +CLUTTER_DEPRECATED_FOR(clutter_stage_get_event_actor) void clutter_event_set_source (ClutterEvent *event, ClutterActor *actor); -CLUTTER_EXPORT +CLUTTER_DEPRECATED ClutterActor * clutter_event_get_source (const ClutterEvent *event); CLUTTER_EXPORT void clutter_event_set_stage (ClutterEvent *event,