diff options
author | Michael Weghorn <m.weghorn@posteo.de> | 2024-04-18 18:59:46 +0200 |
---|---|---|
committer | Michael Weghorn <m.weghorn@posteo.de> | 2024-04-20 15:29:29 +0200 |
commit | 94c97ecdbfa606401fb53685048731128186672b (patch) | |
tree | 65ba95c5d16297a90fb14f8657c9e5176b68dac7 /vcl/unx | |
parent | 1e851093f0148d2c55fc3fd377d274f6703c71c9 (diff) |
gtk3 a11y: Set a11y relations for custom combobox impl
As described in more detail in the previous commit
Change-Id: If5faf77c5f82836c376c04bb6e4e42ce5a3023a2
Author: Michael Weghorn <m.weghorn@posteo.de>
Date: Thu Apr 18 14:02:25 2024 +0200
tdf#159910 gtk3 a11y: Keep a11y props for combobox
, the gtk3 VCL plugin uses a custom combobox implementation
rather than the stock GtkComboBox.
Similar to how the above commit makes sure that accessible
role, name and description set for the stock GtkComboBox
are also set in the custom implementation, do the same
for the accessible relations as well, by taking over
the relations from the GtkComboBox to the toggle
button of the custom implementation as well.
One particularly relevant relation in practice is
`ATK_RELATION_LABELLED_BY`, because the target set
via that relation is what screen readers tend to
announce when a combobox receives focus and doesn't
have an accessible name set for itself.
With this change in place, the Orca screen reader
announces the corresponding label e.g. in the
"Format" -> "Character" dialog in Writer, tab
"Font Effects", so e.g. "Overlining:, combobox"
is announced by Orca when the combobox for setting
the value for the overlining receives focus,
rather than just saying "combobox", which
wouldn't make clear to the user what this
combobox is for.
(This also matches what Orca already does for
the qt6 VCL plugin.)
This change only takes over the relations
set for the combobox itself. Usually, relations
are set both ways (e.g. the target of the
`ATK_RELATION_LABELLED_BY` relation would
itself have an `ATK_RELATION_LABEL_FOR`
relation with the combobox as a target).
If necessary, this solution could be
extended to also iterate over all the
target objects and check whether they
have relations with the combobox as a target
and set corresponding relations to the toggle
button as well (or instead).
Change-Id: I05e39ef5606ffa49ca7673039de3e1aa74fc8649
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/166259
Tested-by: Jenkins
Reviewed-by: Michael Weghorn <m.weghorn@posteo.de>
Diffstat (limited to 'vcl/unx')
-rw-r--r-- | vcl/unx/gtk3/gtkinst.cxx | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/vcl/unx/gtk3/gtkinst.cxx b/vcl/unx/gtk3/gtkinst.cxx index bcdcbc1c6157..41aa48dbed7f 100644 --- a/vcl/unx/gtk3/gtkinst.cxx +++ b/vcl/unx/gtk3/gtkinst.cxx @@ -22172,6 +22172,7 @@ public: g_signal_connect(getContainer(), "query-tooltip", G_CALLBACK(signalComboTooltipQuery), this); } + // take over a11y characteristics from the stock GtkComboBox to the toggle button if (AtkObject* pComboBoxAccessible = gtk_widget_get_accessible(GTK_WIDGET(m_pComboBox))) { if (AtkObject* pToggleButtonAccessible = gtk_widget_get_accessible(GTK_WIDGET(m_pToggleButton))) @@ -22181,6 +22182,20 @@ public: atk_object_set_name(pToggleButtonAccessible, pName); if (const char* pDesc = atk_object_get_description(pComboBoxAccessible)) atk_object_set_description(pToggleButtonAccessible, pDesc); + + if (AtkRelationSet* pComboBoxRelationSet = atk_object_ref_relation_set(pComboBoxAccessible)) + { + AtkRelationSet* pToggleButtonRelationSet = atk_object_ref_relation_set(pToggleButtonAccessible); + assert(pToggleButtonRelationSet); + for (int i = 0; i < atk_relation_set_get_n_relations(pComboBoxRelationSet); i++) + { + AtkRelation* pRelation = atk_relation_set_get_relation(pComboBoxRelationSet, i); + assert(pRelation); + atk_relation_set_add(pToggleButtonRelationSet, pRelation); + } + g_object_unref(pComboBoxRelationSet); + g_object_unref(pToggleButtonRelationSet); + } } } |