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: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2389>
This commit is contained in:
Jonas Dreßler 2024-03-04 21:52:47 +01:00
parent 63cc4da4f9
commit 6f84fb0a24
2 changed files with 17 additions and 0 deletions

View File

@ -154,4 +154,6 @@ ClutterGrab * clutter_stage_grab_input_only (ClutterStage *self,
void clutter_stage_invalidate_devices (ClutterStage *stage); void clutter_stage_invalidate_devices (ClutterStage *stage);
GPtrArray * clutter_stage_get_active_gestures_array (ClutterStage *self);
G_END_DECLS G_END_DECLS

View File

@ -135,6 +135,8 @@ typedef struct _ClutterStagePrivate
GHashTable *pointer_devices; GHashTable *pointer_devices;
GHashTable *touch_sequences; GHashTable *touch_sequences;
GPtrArray *all_active_gestures;
guint actor_needs_immediate_relayout : 1; guint actor_needs_immediate_relayout : 1;
} ClutterStagePrivate; } ClutterStagePrivate;
@ -1263,6 +1265,9 @@ clutter_stage_finalize (GObject *object)
g_assert (priv->cur_event_emission_chain->len == 0); g_assert (priv->cur_event_emission_chain->len == 0);
g_array_unref (priv->cur_event_emission_chain); 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->pointer_devices);
g_hash_table_destroy (priv->touch_sequences); g_hash_table_destroy (priv->touch_sequences);
@ -1673,6 +1678,8 @@ clutter_stage_init (ClutterStage *self)
g_hash_table_new_full (NULL, NULL, g_hash_table_new_full (NULL, NULL,
NULL, (GDestroyNotify) free_pointer_device_entry); NULL, (GDestroyNotify) free_pointer_device_entry);
priv->all_active_gestures = g_ptr_array_sized_new (64);
clutter_actor_set_background_color (CLUTTER_ACTOR (self), clutter_actor_set_background_color (CLUTTER_ACTOR (self),
&default_stage_color); &default_stage_color);
@ -4590,3 +4597,11 @@ clutter_stage_pointing_input_foreach (ClutterStage *self,
return TRUE; return TRUE;
} }
GPtrArray *
clutter_stage_get_active_gestures_array (ClutterStage *self)
{
ClutterStagePrivate *priv = clutter_stage_get_instance_private (self);
return priv->all_active_gestures;
}