[mutter/wip/carlosg/no-event-source: 1/3] clutter: Add clutter_stage_get_event_actor() API call
- From: Carlos Garnacho <carlosg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [mutter/wip/carlosg/no-event-source: 1/3] clutter: Add clutter_stage_get_event_actor() API call
- Date: Wed, 2 Mar 2022 12:22:17 +0000 (UTC)
commit ed233278cd332955d8194c386cee0f63553fe88e
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 | 67 +++++++++++++++++++++++++++++++++++++++++
clutter/clutter/clutter-stage.h | 3 ++
meson.build | 1 -
3 files changed, 70 insertions(+), 1 deletion(-)
---
diff --git a/clutter/clutter/clutter-stage.c b/clutter/clutter/clutter-stage.c
index 6503f973b3..09a56e8a72 100644
--- a/clutter/clutter/clutter-stage.c
+++ b/clutter/clutter/clutter-stage.c
@@ -3921,3 +3921,70 @@ 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 current focus actor for an event. This is
+ * the key focus for key events and other events directed
+ * to the key focus, or the actor directly under the
+ * coordinates of a device or touch sequence.
+ *
+ * The actor is looked up at the time of calling this function,
+ * and may differ from the actor that the stage originally
+ * delivered the event 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]