From e6a394ca10aa448b07147ee8a4467e8153437d2e Mon Sep 17 00:00:00 2001 From: Bilal Elmoussaoui Date: Fri, 2 Aug 2024 11:38:05 +0200 Subject: [PATCH] clutter/actor: Emit accessibility states changes directly Instead of making CallyActor listen to notify, adding an extra overhead Helps with merging Cally inside of Clutter Part-of: --- clutter/clutter/cally/cally-actor.c | 49 ----------------------------- clutter/clutter/clutter-actor.c | 36 +++++++++++++++++++++ 2 files changed, 36 insertions(+), 49 deletions(-) diff --git a/clutter/clutter/cally/cally-actor.c b/clutter/clutter/cally/cally-actor.c index a6c2cd633..9b4da97d0 100644 --- a/clutter/clutter/cally/cally-actor.c +++ b/clutter/clutter/cally/cally-actor.c @@ -113,8 +113,6 @@ static gboolean cally_actor_grab_focus (AtkComponent *component); /* Misc functions */ static void cally_actor_notify_clutter (GObject *obj, GParamSpec *pspec); -static void cally_actor_real_notify_clutter (GObject *obj, - GParamSpec *pspec); struct _CallyActorPrivate { @@ -204,8 +202,6 @@ cally_actor_class_init (CallyActorClass *klass) AtkObjectClass *class = ATK_OBJECT_CLASS (klass); GObjectClass *gobject_class = G_OBJECT_CLASS (klass); - klass->notify_clutter = cally_actor_real_notify_clutter; - /* GObject */ gobject_class->finalize = cally_actor_finalize; @@ -619,48 +615,3 @@ cally_actor_notify_clutter (GObject *obj, if (klass->notify_clutter) klass->notify_clutter (obj, pspec); } - -/* - * This function is a signal handler for notify signal which gets emitted - * when a property changes value on the ClutterActor associated with a CallyActor - * - * It constructs an AtkPropertyValues structure and emits a "property_changed" - * signal which causes the user specified AtkPropertyChangeHandler - * to be called. - */ -static void -cally_actor_real_notify_clutter (GObject *obj, - GParamSpec *pspec) -{ - ClutterActor* actor = CLUTTER_ACTOR (obj); - AtkObject* atk_obj = clutter_actor_get_accessible (CLUTTER_ACTOR(obj)); - AtkState state; - gboolean value; - - if (g_strcmp0 (pspec->name, "visible") == 0) - { - state = ATK_STATE_VISIBLE; - value = clutter_actor_is_visible (actor); - } - else if (g_strcmp0 (pspec->name, "mapped") == 0) - { - /* Clones may temporarily map an actor in order to - * paint it; we don't want this to generate an ATK - * state change - */ - if (clutter_actor_is_painting_unmapped (actor)) - return; - - state = ATK_STATE_SHOWING; - value = clutter_actor_is_mapped (actor); - } - else if (g_strcmp0 (pspec->name, "reactive") == 0) - { - state = ATK_STATE_SENSITIVE; - value = clutter_actor_get_reactive (actor); - } - else - return; - - atk_object_notify_state_change (atk_obj, state, value); -} diff --git a/clutter/clutter/clutter-actor.c b/clutter/clutter/clutter-actor.c index 4e40ac172..f8efb0fb8 100644 --- a/clutter/clutter/clutter-actor.c +++ b/clutter/clutter/clutter-actor.c @@ -1412,6 +1412,7 @@ clutter_actor_real_map (ClutterActor *self) { ClutterActorPrivate *priv = self->priv; ClutterActor *iter; + AtkObject *accessible; g_assert (!clutter_actor_is_mapped (self)); @@ -1448,6 +1449,12 @@ clutter_actor_real_map (ClutterActor *self) */ g_object_notify_by_pspec (G_OBJECT (self), obj_props[PROP_MAPPED]); + accessible = clutter_actor_get_accessible (self); + if (accessible && !clutter_actor_is_painting_unmapped (self)) + atk_object_notify_state_change (accessible, + ATK_STATE_SHOWING, + TRUE); + for (iter = priv->first_child; iter != NULL; iter = iter->priv->next_sibling) @@ -1547,6 +1554,7 @@ clutter_actor_real_unmap (ClutterActor *self) { ClutterActorPrivate *priv = self->priv; ClutterActor *iter; + AtkObject *accessible; g_assert (clutter_actor_is_mapped (self)); @@ -1578,6 +1586,12 @@ clutter_actor_real_unmap (ClutterActor *self) */ g_object_notify_by_pspec (G_OBJECT (self), obj_props[PROP_MAPPED]); + accessible = clutter_actor_get_accessible (self); + if (accessible && !clutter_actor_is_painting_unmapped (self)) + atk_object_notify_state_change (accessible, + ATK_STATE_SHOWING, + FALSE); + if (priv->n_pointers > 0) { ClutterActor *stage = _clutter_actor_get_stage_internal (self); @@ -1711,6 +1725,7 @@ void clutter_actor_show (ClutterActor *self) { ClutterActorPrivate *priv; + AtkObject *accessible; g_return_if_fail (CLUTTER_IS_ACTOR (self)); @@ -1748,6 +1763,12 @@ clutter_actor_show (ClutterActor *self) g_signal_emit (self, actor_signals[SHOW], 0); g_object_notify_by_pspec (G_OBJECT (self), obj_props[PROP_VISIBLE]); + accessible = clutter_actor_get_accessible (self); + if (accessible) + atk_object_notify_state_change (accessible, + ATK_STATE_VISIBLE, + TRUE); + if (priv->parent != NULL) clutter_actor_queue_redraw (self); @@ -1802,6 +1823,7 @@ void clutter_actor_hide (ClutterActor *self) { ClutterActorPrivate *priv; + AtkObject *accessible; g_return_if_fail (CLUTTER_IS_ACTOR (self)); @@ -1839,6 +1861,13 @@ clutter_actor_hide (ClutterActor *self) g_signal_emit (self, actor_signals[HIDE], 0); g_object_notify_by_pspec (G_OBJECT (self), obj_props[PROP_VISIBLE]); + accessible = clutter_actor_get_accessible (self); + if (accessible) + atk_object_notify_state_change (accessible, + ATK_STATE_VISIBLE, + FALSE); + + if (priv->parent != NULL && priv->needs_allocation) clutter_actor_queue_redraw (priv->parent); else @@ -11782,6 +11811,7 @@ clutter_actor_set_reactive (ClutterActor *actor, gboolean reactive) { ClutterActorPrivate *priv; + AtkObject *accessible; g_return_if_fail (CLUTTER_IS_ACTOR (actor)); @@ -11797,6 +11827,12 @@ clutter_actor_set_reactive (ClutterActor *actor, g_object_notify_by_pspec (G_OBJECT (actor), obj_props[PROP_REACTIVE]); + accessible = clutter_actor_get_accessible (actor); + if (accessible) + atk_object_notify_state_change (accessible, + ATK_STATE_SENSITIVE, + reactive); + if (!clutter_actor_get_reactive (actor) && priv->n_pointers > 0) { ClutterActor *stage = _clutter_actor_get_stage_internal (actor);