From 043ff8f98f771e0778a0de2361e2e69e02b3ad20 Mon Sep 17 00:00:00 2001 From: Carlos Garnacho Date: Wed, 2 Aug 2023 17:53:21 +0200 Subject: [PATCH] cally: Avoid access to stage through ClutterEvent Pass the stage explicitly, in order to avoid having to peek to it through the event. Part-of: --- clutter/clutter/cally/cally-util.c | 9 +++++---- clutter/clutter/cally/cally-util.h | 3 ++- clutter/clutter/clutter-main.c | 2 +- 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/clutter/clutter/cally/cally-util.c b/clutter/clutter/cally/cally-util.c index 29e633424..c75a1f52a 100644 --- a/clutter/clutter/cally/cally-util.c +++ b/clutter/clutter/cally/cally-util.c @@ -278,12 +278,12 @@ insert_hf (gpointer key, gpointer value, gpointer data) * char */ static gunichar -check_key_visibility (ClutterEvent *event) +check_key_visibility (ClutterStage *stage) { AtkObject *accessible; ClutterActor *focus; - focus = clutter_stage_get_key_focus (clutter_event_get_stage (event)); + focus = clutter_stage_get_key_focus (stage); accessible = clutter_actor_get_accessible (focus); g_return_val_if_fail (accessible != NULL, 0); @@ -307,7 +307,8 @@ check_key_visibility (ClutterEvent *event) } gboolean -cally_snoop_key_event (ClutterKeyEvent *key) +cally_snoop_key_event (ClutterStage *stage, + ClutterKeyEvent *key) { ClutterEvent *event = (ClutterEvent *) key; AtkKeyEventStruct *key_event = NULL; @@ -323,7 +324,7 @@ cally_snoop_key_event (ClutterKeyEvent *key) GHashTable *new_hash = g_hash_table_new (NULL, NULL); g_hash_table_foreach (key_listener_list, insert_hf, new_hash); - password_char = check_key_visibility (event); + password_char = check_key_visibility (stage); key_event = atk_key_event_from_clutter_event_key (key, password_char); /* func data is inside the hash table */ consumed = g_hash_table_foreach_steal (new_hash, notify_hf, key_event) > 0; diff --git a/clutter/clutter/cally/cally-util.h b/clutter/clutter/cally/cally-util.h index 17abf20c1..2daac50d4 100644 --- a/clutter/clutter/cally/cally-util.h +++ b/clutter/clutter/cally/cally-util.h @@ -65,6 +65,7 @@ GType cally_util_get_type (void) G_GNUC_CONST; void _cally_util_override_atk_util (void); -gboolean cally_snoop_key_event (ClutterKeyEvent *key); +gboolean cally_snoop_key_event (ClutterStage *stage, + ClutterKeyEvent *key); G_END_DECLS diff --git a/clutter/clutter/clutter-main.c b/clutter/clutter/clutter-main.c index b9871b7cf..88cc57161 100644 --- a/clutter/clutter/clutter-main.c +++ b/clutter/clutter/clutter-main.c @@ -687,7 +687,7 @@ emit_event (ClutterStage *stage, { if (event->type == CLUTTER_KEY_PRESS || event->type == CLUTTER_KEY_RELEASE) - cally_snoop_key_event ((ClutterKeyEvent *) event); + cally_snoop_key_event (stage, (ClutterKeyEvent *) event); clutter_stage_emit_event (stage, event); }