clutter/text: Emit accessibility state changes

Not everything can be easily moved, so only parts of it is done for now

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3917>
This commit is contained in:
Bilal Elmoussaoui 2024-08-02 11:59:00 +02:00 committed by Marge Bot
parent e6a394ca10
commit d8fbaf4533
2 changed files with 14 additions and 12 deletions

View File

@ -1741,22 +1741,10 @@ cally_text_notify_clutter (GObject *obj,
if (_check_for_selection_change (cally_text, clutter_text)) if (_check_for_selection_change (cally_text, clutter_text))
g_signal_emit_by_name (atk_obj, "text_selection_changed"); g_signal_emit_by_name (atk_obj, "text_selection_changed");
} }
else if (g_strcmp0 (pspec->name, "editable") == 0)
{
atk_object_notify_state_change (atk_obj, ATK_STATE_EDITABLE,
clutter_text_get_editable (clutter_text));
}
else if (g_strcmp0 (pspec->name, "activatable") == 0) else if (g_strcmp0 (pspec->name, "activatable") == 0)
{ {
_check_activate_action (cally_text, clutter_text); _check_activate_action (cally_text, clutter_text);
} }
else if (g_strcmp0 (pspec->name, "password-char") == 0)
{
if (clutter_text_get_password_char (clutter_text) != 0)
atk_object_set_role (atk_obj, ATK_ROLE_PASSWORD_TEXT);
else
atk_object_set_role (atk_obj, ATK_ROLE_TEXT);
}
else else
{ {
CALLY_ACTOR_CLASS (cally_text_parent_class)->notify_clutter (obj, pspec); CALLY_ACTOR_CLASS (cally_text_parent_class)->notify_clutter (obj, pspec);

View File

@ -39,6 +39,8 @@
#include "config.h" #include "config.h"
#include <atk/atk.h>
#include <string.h> #include <string.h>
#include <math.h> #include <math.h>
@ -4830,6 +4832,7 @@ clutter_text_set_editable (ClutterText *self,
ClutterBackend *backend = clutter_get_default_backend (); ClutterBackend *backend = clutter_get_default_backend ();
ClutterInputMethod *method = clutter_backend_get_input_method (backend); ClutterInputMethod *method = clutter_backend_get_input_method (backend);
ClutterTextPrivate *priv; ClutterTextPrivate *priv;
AtkObject *accessible;
g_return_if_fail (CLUTTER_IS_TEXT (self)); g_return_if_fail (CLUTTER_IS_TEXT (self));
@ -4837,6 +4840,7 @@ clutter_text_set_editable (ClutterText *self,
if (priv->editable != editable) if (priv->editable != editable)
{ {
accessible = clutter_actor_get_accessible (CLUTTER_ACTOR (self));
priv->editable = editable; priv->editable = editable;
if (method) if (method)
@ -4850,6 +4854,10 @@ clutter_text_set_editable (ClutterText *self,
clutter_text_queue_redraw (CLUTTER_ACTOR (self)); clutter_text_queue_redraw (CLUTTER_ACTOR (self));
g_object_notify_by_pspec (G_OBJECT (self), obj_props[PROP_EDITABLE]); g_object_notify_by_pspec (G_OBJECT (self), obj_props[PROP_EDITABLE]);
if (accessible)
atk_object_notify_state_change (accessible,
ATK_STATE_EDITABLE,
priv->editable);
} }
} }
@ -6162,6 +6170,7 @@ clutter_text_set_password_char (ClutterText *self,
gunichar wc) gunichar wc)
{ {
ClutterTextPrivate *priv; ClutterTextPrivate *priv;
AtkObject *accessible;
g_return_if_fail (CLUTTER_IS_TEXT (self)); g_return_if_fail (CLUTTER_IS_TEXT (self));
@ -6169,12 +6178,17 @@ clutter_text_set_password_char (ClutterText *self,
if (priv->password_char != wc) if (priv->password_char != wc)
{ {
accessible = clutter_actor_get_accessible (CLUTTER_ACTOR (self));
priv->password_char = wc; priv->password_char = wc;
clutter_text_dirty_cache (self); clutter_text_dirty_cache (self);
clutter_actor_queue_relayout (CLUTTER_ACTOR (self)); clutter_actor_queue_relayout (CLUTTER_ACTOR (self));
g_object_notify_by_pspec (G_OBJECT (self), obj_props[PROP_PASSWORD_CHAR]); g_object_notify_by_pspec (G_OBJECT (self), obj_props[PROP_PASSWORD_CHAR]);
if (accessible)
atk_object_set_role (accessible,
priv->password_char != 0 ? ATK_ROLE_PASSWORD_TEXT : ATK_ROLE_TEXT);
} }
} }