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




commit 39f267c73ccc094fe185dae7752020e8b9f03793
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 | 62 +++++++++++++++++++++++++++++++++++++++++
 clutter/clutter/clutter-stage.h |  3 ++
 meson.build                     |  1 -
 3 files changed, 65 insertions(+), 1 deletion(-)
---
diff --git a/clutter/clutter/clutter-stage.c b/clutter/clutter/clutter-stage.c
index 6503f973b3..6de84f93cb 100644
--- a/clutter/clutter/clutter-stage.c
+++ b/clutter/clutter/clutter-stage.c
@@ -3921,3 +3921,65 @@ 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,
+                               const ClutterEvent *event)
+{
+  ClutterInputDevice *device;
+  ClutterEventSequence *sequence;
+
+  g_return_val_if_fail (CLUTTER_IS_STAGE (stage), NULL);
+  g_return_val_if_fail (event != NULL, NULL);
+
+  switch (event->type)
+    {
+    case CLUTTER_KEY_PRESS:
+    case CLUTTER_KEY_RELEASE:
+    case CLUTTER_PAD_BUTTON_PRESS:
+    case CLUTTER_PAD_BUTTON_RELEASE:
+    case CLUTTER_PAD_RING:
+    case CLUTTER_PAD_STRIP:
+    case CLUTTER_IM_COMMIT:
+    case CLUTTER_IM_DELETE:
+    case CLUTTER_IM_PREEDIT:
+      return clutter_stage_get_key_focus (stage);
+    case CLUTTER_MOTION:
+    case CLUTTER_ENTER:
+    case CLUTTER_LEAVE:
+    case CLUTTER_BUTTON_PRESS:
+    case CLUTTER_BUTTON_RELEASE:
+    case CLUTTER_SCROLL:
+    case CLUTTER_TOUCH_BEGIN:
+    case CLUTTER_TOUCH_UPDATE:
+    case CLUTTER_TOUCH_END:
+    case CLUTTER_TOUCH_CANCEL:
+    case CLUTTER_TOUCHPAD_PINCH:
+    case CLUTTER_TOUCHPAD_SWIPE:
+    case CLUTTER_TOUCHPAD_HOLD:
+    case CLUTTER_PROXIMITY_IN:
+    case CLUTTER_PROXIMITY_OUT:
+      device = clutter_event_get_device (event);
+      sequence = clutter_event_get_event_sequence (event);
+
+      return clutter_stage_get_device_actor (stage, device, sequence);
+    case CLUTTER_DEVICE_ADDED:
+    case CLUTTER_DEVICE_REMOVED:
+    case CLUTTER_NOTHING:
+    case CLUTTER_EVENT_LAST:
+      g_warn_if_reached ();
+    }
+
+  return NULL;
+}
diff --git a/clutter/clutter/clutter-stage.h b/clutter/clutter/clutter-stage.h
index 6c1f5ff961..5412c4d729 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,
+                                              const ClutterEvent *event);
 
 CLUTTER_EXPORT
 ClutterGrab * clutter_stage_grab (ClutterStage *stage,
diff --git a/meson.build b/meson.build
index b6522f93d3..547f940884 100644
--- a/meson.build
+++ b/meson.build
@@ -333,7 +333,6 @@ if have_tests
     ],
     exe_wrapper: [
       default_test_wrappers,
-      find_program('catchsegv'),
       find_program('xvfb-run'), '-a', '-s', '+iglx -noreset',
     ],
     timeout_multiplier: 10,


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