vcl/unx/gtk4/a11y.cxx |   20 +++++++++++++++-----
 1 file changed, 15 insertions(+), 5 deletions(-)

New commits:
commit 1a81fd69e10ad1ce7193fe7231ff29b2b94f67c7
Author:     Michael Weghorn <m.wegh...@posteo.de>
AuthorDate: Wed Dec 20 08:14:24 2023 +0100
Commit:     Michael Weghorn <m.wegh...@posteo.de>
CommitDate: Wed Dec 20 22:29:50 2023 +0100

    gtk4 a11y: Take SELECTABLE/EXPANDABLE states into account
    
    The Gtk API has no direct equivalent for the selectable
    and expandable states, but sets them on the AT-SPI layer
    whenever a value for the selected/expanded states is
    explicitly set.
    Therefore, only explicitly set values for these
    if the selectable/expandable state is present,
    to avoid the expandable/selectable state being
    set on AT-SPI layer when it shouldn't.
    
    Change-Id: Ib0cf2095d4834869856bf786e662115f6a328e13
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/161046
    Tested-by: Jenkins
    Reviewed-by: Michael Weghorn <m.wegh...@posteo.de>

diff --git a/vcl/unx/gtk4/a11y.cxx b/vcl/unx/gtk4/a11y.cxx
index 48c22beb21ee..6bc89f15c401 100644
--- a/vcl/unx/gtk4/a11y.cxx
+++ b/vcl/unx/gtk4/a11y.cxx
@@ -296,11 +296,7 @@ static void applyStates(GtkAccessible* pGtkAccessible,
         pGtkAccessible, GTK_ACCESSIBLE_STATE_BUSY,
         bool(nStates & 
com::sun::star::accessibility::AccessibleStateType::BUSY),
         GTK_ACCESSIBLE_STATE_DISABLED,
-        bool(!(nStates & 
com::sun::star::accessibility::AccessibleStateType::ENABLED)),
-        GTK_ACCESSIBLE_STATE_EXPANDED,
-        bool(nStates & 
com::sun::star::accessibility::AccessibleStateType::EXPANDED),
-        GTK_ACCESSIBLE_STATE_SELECTED,
-        bool(nStates & 
com::sun::star::accessibility::AccessibleStateType::SELECTED), -1);
+        bool(!(nStates & 
com::sun::star::accessibility::AccessibleStateType::ENABLED)), -1);
 
     // when explicitly setting any value for GTK_ACCESSIBLE_STATE_CHECKED,
     // Gtk will also report ATSPI_STATE_CHECKABLE on the AT-SPI layer
@@ -314,6 +310,20 @@ static void applyStates(GtkAccessible* pGtkAccessible,
         gtk_accessible_update_state(pGtkAccessible, 
GTK_ACCESSIBLE_STATE_CHECKED, eState, -1);
     }
 
+    if (nStates & 
com::sun::star::accessibility::AccessibleStateType::EXPANDABLE)
+    {
+        gtk_accessible_update_state(
+            pGtkAccessible, GTK_ACCESSIBLE_STATE_EXPANDED,
+            bool(nStates & 
com::sun::star::accessibility::AccessibleStateType::EXPANDED), -1);
+    }
+
+    if (nStates & 
com::sun::star::accessibility::AccessibleStateType::SELECTABLE)
+    {
+        gtk_accessible_update_state(
+            pGtkAccessible, GTK_ACCESSIBLE_STATE_SELECTED,
+            bool(nStates & 
com::sun::star::accessibility::AccessibleStateType::SELECTED), -1);
+    }
+
     const sal_Int16 nRole = xContext->getAccessibleRole();
     if (nRole == com::sun::star::accessibility::AccessibleRole::TOGGLE_BUTTON)
     {

Reply via email to