vcl/unx/gtk3/gtkinst.cxx |   28 +++++++++++++++++++---------
 1 file changed, 19 insertions(+), 9 deletions(-)

New commits:
commit d746a39ea9dc2c39cc2a7aa5d78e6c9d7563d9ca
Author:     Michael Weghorn <m.wegh...@posteo.de>
AuthorDate: Tue Feb 4 11:29:03 2025 +0100
Commit:     Michael Weghorn <m.wegh...@posteo.de>
CommitDate: Tue Feb 4 13:58:35 2025 +0100

    tdf#165035 gtk3 a11y: Set relations for combobox's edit
    
    As described in
    
        commit 94c97ecdbfa606401fb53685048731128186672b
        Author: Michael Weghorn <m.wegh...@posteo.de>
        Date:   Thu Apr 18 18:59:46 2024 +0200
    
            gtk3 a11y: Set a11y relations for custom combobox impl
    
    , the gtk3 VCL plugin currently uses a custom combobox
    implementation.
    
    The above commit implemented that accessible relations set
    for the original GtkComboBox in the .ui file
    are taken over to the custom combobox implementation's
    toggle button.
    
    In case of an editable combobox, also set those relations
    for the box containing the combobox's GtkEntry.
    (Move the existing logic to set the role up to have everything
    in once place.)
    
    This makes the Orca screen reader announce the associated
    label's text also when the entry receives focus, not
    only when the toggle button does, e.g. in the
    "Format" -> "Character" dialog, "Font" tab, for the
    "Style" combobox.
    
    Change-Id: I2ece9177355aa18e43e0826bb07b6291944e8912
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/181093
    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 5001f71d11d3..92c40e5e91cd 100644
--- a/vcl/unx/gtk3/gtkinst.cxx
+++ b/vcl/unx/gtk3/gtkinst.cxx
@@ -22431,7 +22431,7 @@ public:
             g_signal_connect(getContainer(), "query-tooltip", 
G_CALLBACK(signalComboTooltipQuery), this);
         }
 
-        // take over a11y characteristics from the stock GtkComboBox to the 
toggle button
+        // take over a11y characteristics from the stock GtkComboBox
         if (AtkObject* pComboBoxAccessible = 
gtk_widget_get_accessible(GTK_WIDGET(m_pComboBox)))
         {
             if (AtkObject* pToggleButtonAccessible = 
gtk_widget_get_accessible(GTK_WIDGET(m_pToggleButton)))
@@ -22442,6 +22442,21 @@ public:
                 if (const char* pDesc = 
atk_object_get_description(pComboBoxAccessible))
                     atk_object_set_description(pToggleButtonAccessible, pDesc);
 
+                // for editable combobox, also set a11y combobox role and 
relations
+                // for the box containing the GtkEntry
+                AtkRelationSet* pBoxRelationSet = nullptr;
+                if (gtk_combo_box_get_has_entry(m_pComboBox))
+                {
+                    GtkWidget* pBox = 
GTK_WIDGET(gtk_builder_get_object(pComboBuilder, "box"));
+                    assert(pBox);
+                    if (AtkObject* pBoxAccessible = 
gtk_widget_get_accessible(pBox))
+                    {
+                        atk_object_set_role(pBoxAccessible, 
ATK_ROLE_COMBO_BOX);
+                        pBoxRelationSet = 
atk_object_ref_relation_set(pBoxAccessible);
+                        assert(pBoxRelationSet);
+                    }
+                }
+
                 if (AtkRelationSet* pComboBoxRelationSet = 
atk_object_ref_relation_set(pComboBoxAccessible))
                 {
                     AtkRelationSet* pToggleButtonRelationSet = 
atk_object_ref_relation_set(pToggleButtonAccessible);
@@ -22451,6 +22466,9 @@ public:
                         AtkRelation* pRelation = 
atk_relation_set_get_relation(pComboBoxRelationSet, i);
                         assert(pRelation);
                         atk_relation_set_add(pToggleButtonRelationSet, 
pRelation);
+
+                        if (pBoxRelationSet)
+                            atk_relation_set_add(pBoxRelationSet, pRelation);
                     }
                     g_object_unref(pComboBoxRelationSet);
                     g_object_unref(pToggleButtonRelationSet);
@@ -22504,14 +22522,6 @@ public:
             m_nEntryKeyPressEventSignalId = g_signal_connect(m_pEntry, 
"key-press-event", G_CALLBACK(signalEntryKeyPress), this);
             m_nEntryPopulatePopupMenuSignalId = g_signal_connect(m_pEntry, 
"populate-popup", G_CALLBACK(signalEntryPopulatePopup), nullptr);
             m_nKeyPressEventSignalId = 0;
-
-            // for editable combobox, set a11y combobox role for the box 
containing the entry
-            // (in addition to the button for which this is already set in the 
.ui file that
-            // gets focus in case of the non-editable combobox)
-            GtkWidget* pBox = GTK_WIDGET(gtk_builder_get_object(pComboBuilder, 
"box"));
-            assert(pBox);
-            if (AtkObject* pBoxAccessible = gtk_widget_get_accessible(pBox))
-                atk_object_set_role(pBoxAccessible, ATK_ROLE_COMBO_BOX);
         }
         else
         {

Reply via email to