From 6f84fb0a242c96b19fa9f7812505ddecb9b47b0f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonas=20Dre=C3=9Fler?= Date: Mon, 4 Mar 2024 21:52:47 +0100 Subject: [PATCH] clutter/stage: Store a list of all active gestures on the whole stage With the next commit, we'll need a list of all gestures that currently are active globally. Since actors and actions (and therefore also gestures) in Clutter are bound to a stage, it makes sense for this list to exist on the ClutterStage level. The list itself is a simple GPtrArray (to allow for quick searches) that doesn't reference the gestures and is not manipulated by the stage itself. All manipulation of the array is left to ClutterGestures. Part-of: --- clutter/clutter/clutter-stage-private.h | 2 ++ clutter/clutter/clutter-stage.c | 15 +++++++++++++++ 2 files changed, 17 insertions(+) diff --git a/clutter/clutter/clutter-stage-private.h b/clutter/clutter/clutter-stage-private.h index a2a14fa65..3e1208e26 100644 --- a/clutter/clutter/clutter-stage-private.h +++ b/clutter/clutter/clutter-stage-private.h @@ -154,4 +154,6 @@ ClutterGrab * clutter_stage_grab_input_only (ClutterStage *self, void clutter_stage_invalidate_devices (ClutterStage *stage); +GPtrArray * clutter_stage_get_active_gestures_array (ClutterStage *self); + G_END_DECLS diff --git a/clutter/clutter/clutter-stage.c b/clutter/clutter/clutter-stage.c index dae5ca47e..47f61532c 100644 --- a/clutter/clutter/clutter-stage.c +++ b/clutter/clutter/clutter-stage.c @@ -135,6 +135,8 @@ typedef struct _ClutterStagePrivate GHashTable *pointer_devices; GHashTable *touch_sequences; + GPtrArray *all_active_gestures; + guint actor_needs_immediate_relayout : 1; } ClutterStagePrivate; @@ -1263,6 +1265,9 @@ clutter_stage_finalize (GObject *object) g_assert (priv->cur_event_emission_chain->len == 0); g_array_unref (priv->cur_event_emission_chain); + g_assert (priv->all_active_gestures->len == 0); + g_ptr_array_free (priv->all_active_gestures, TRUE); + g_hash_table_destroy (priv->pointer_devices); g_hash_table_destroy (priv->touch_sequences); @@ -1673,6 +1678,8 @@ clutter_stage_init (ClutterStage *self) g_hash_table_new_full (NULL, NULL, NULL, (GDestroyNotify) free_pointer_device_entry); + priv->all_active_gestures = g_ptr_array_sized_new (64); + clutter_actor_set_background_color (CLUTTER_ACTOR (self), &default_stage_color); @@ -4590,3 +4597,11 @@ clutter_stage_pointing_input_foreach (ClutterStage *self, return TRUE; } + +GPtrArray * +clutter_stage_get_active_gestures_array (ClutterStage *self) +{ + ClutterStagePrivate *priv = clutter_stage_get_instance_private (self); + + return priv->all_active_gestures; +}