vcl/unx/gtk3/gtkinst.cxx |   15 +++++++++++++++
 1 file changed, 15 insertions(+)

New commits:
commit 94c97ecdbfa606401fb53685048731128186672b
Author:     Michael Weghorn <m.wegh...@posteo.de>
AuthorDate: Thu Apr 18 18:59:46 2024 +0200
Commit:     Michael Weghorn <m.wegh...@posteo.de>
CommitDate: Sat Apr 20 15:29:29 2024 +0200

    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.wegh...@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.wegh...@posteo.de>

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);
+                }
             }
         }
 

Reply via email to