[mutter/wip/carlosg/no-event-source: 12/14] clutter: Add clutter_stage_get_event_actor() API call




commit b9d051607f29d13a2891131feefe8a31d74fa909
Author: Carlos Garnacho <carlosg gnome org>
Date:   Tue Mar 1 23:13:02 2022 +0100

    clutter: Add clutter_stage_get_event_actor() API call
    
    This is a small helper to retrieve the actor that is currently
    beneath the device/sequence, meant to replace clutter_event_get_source().

 clutter/clutter/clutter-stage.c | 27 +++++++++++++++++++++++++++
 clutter/clutter/clutter-stage.h |  3 +++
 2 files changed, 30 insertions(+)
---
diff --git a/clutter/clutter/clutter-stage.c b/clutter/clutter/clutter-stage.c
index 6503f973b3..ad1c3aff59 100644
--- a/clutter/clutter/clutter-stage.c
+++ b/clutter/clutter/clutter-stage.c
@@ -3921,3 +3921,30 @@ clutter_stage_get_grab_actor (ClutterStage *stage)
   /* Return active grab */
   return priv->topmost_grab->actor;
 }
+
+/**
+ * clutter_stage_get_event_actor:
+ * @stage: a #ClutterStage
+ * @event: an event received on the stage
+ *
+ * Retrieves the actor that the device or
+ * touch sequence that generated the event
+ * are currently pointing to.
+ *
+ * Return value: (transfer none): a pointer to the #ClutterActor or %NULL
+ **/
+ClutterActor *
+clutter_stage_get_event_actor (ClutterStage *stage,
+                               ClutterEvent *event)
+{
+  ClutterInputDevice *device;
+  ClutterEventSequence *sequence;
+
+  g_return_val_if_fail (CLUTTER_IS_STAGE (stage), NULL);
+  g_return_val_if_fail (event != NULL, NULL);
+
+  device = clutter_event_get_device (event);
+  sequence = clutter_event_get_event_sequence (event);
+
+  return clutter_stage_get_device_actor (stage, device, sequence);
+}
diff --git a/clutter/clutter/clutter-stage.h b/clutter/clutter/clutter-stage.h
index 6c1f5ff961..84868da03f 100644
--- a/clutter/clutter/clutter-stage.h
+++ b/clutter/clutter/clutter-stage.h
@@ -250,6 +250,9 @@ CLUTTER_EXPORT
 ClutterActor * clutter_stage_get_device_actor (ClutterStage         *stage,
                                                ClutterInputDevice   *device,
                                                ClutterEventSequence *sequence);
+CLUTTER_EXPORT
+ClutterActor * clutter_stage_get_event_actor (ClutterStage *stage,
+                                              ClutterEvent *event);
 
 CLUTTER_EXPORT
 ClutterGrab * clutter_stage_grab (ClutterStage *stage,


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]