summaryrefslogtreecommitdiff
path: root/vcl
diff options
context:
space:
mode:
authorMichael Weghorn <m.weghorn@posteo.de>2023-11-06 17:48:08 +0100
committerMichael Weghorn <m.weghorn@posteo.de>2023-11-07 07:59:55 +0100
commit285c309ad7d92f6b92b5bdf1dd8f490fbdf59d56 (patch)
tree785d159e3cd71191c659ee073ec6ce3247a776e3 /vcl
parenta5c84405caf6f3dc51919fd937dfe21c3d6d53d1 (diff)
gtk4 a11y: Map states to corresponding GtkAccessibleState
Set those states that Gtk handles as `GtkAccessibleState`, see documentation at [1]. For the LO a11y states, the Gtk 4 a11y API differentiates between three different enums/ways of handling those: * `AccessibleProperty`, for which handling was added in the previous commit, Change-Id Ic033e66dd89021defca449bbe2251102bbd61015, "gtk4 a11y: Map states to corresponding gtk a11y properties" * `GtkAccessibleState`, for which this commit implements the handling * `GtkAccessiblePlatformState`, for which handling was implemented in `lo_accessible_get_platform_state` in commit 341ff232aec77c2b46325389da933315613b6f2d Author: Caolán McNamara <caolanm@redhat.com> Date: Mon Mar 20 20:37:15 2023 +0000 gtk4: get a11y to say hello world already. [1] https://docs.gtk.org/gtk4/enum.AccessibleState.html Change-Id: If22725dc2ccab5f73518e4171209a80a9c4df6d3 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/159006 Tested-by: Jenkins Reviewed-by: Michael Weghorn <m.weghorn@posteo.de>
Diffstat (limited to 'vcl')
-rw-r--r--vcl/unx/gtk4/a11y.cxx35
1 files changed, 34 insertions, 1 deletions
diff --git a/vcl/unx/gtk4/a11y.cxx b/vcl/unx/gtk4/a11y.cxx
index fc148d41c199..b60e3d0676de 100644
--- a/vcl/unx/gtk4/a11y.cxx
+++ b/vcl/unx/gtk4/a11y.cxx
@@ -474,7 +474,10 @@ lo_accessible_new(GdkDisplay* pDisplay, GtkAccessible* pParent,
ret->uno_accessible->getAccessibleContext());
assert(xContext.is() && "No accessible context");
- // set state properties
+ // handle states
+ // Gtk differentiates between GtkAccessibleState and GtkAccessibleProperty
+ // (both handled here) and GtkAccessiblePlatformState (handled in
+ // 'lo_accessible_get_platform_state')
const sal_Int64 nStates = xContext->getAccessibleStateSet();
gtk_accessible_update_property(
GTK_ACCESSIBLE(ret), GTK_ACCESSIBLE_PROPERTY_MODAL,
@@ -496,6 +499,36 @@ lo_accessible_new(GdkDisplay* pDisplay, GtkAccessible* pParent,
GTK_ORIENTATION_VERTICAL, -1);
}
+ gtk_accessible_update_state(
+ GTK_ACCESSIBLE(ret), 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);
+
+ const sal_Int16 nRole = xContext->getAccessibleRole();
+ if (nRole == com::sun::star::accessibility::AccessibleRole::CHECK_BOX)
+ {
+ GtkAccessibleTristate eState = GTK_ACCESSIBLE_TRISTATE_FALSE;
+ if (nStates & com::sun::star::accessibility::AccessibleStateType::INDETERMINATE)
+ eState = GTK_ACCESSIBLE_TRISTATE_MIXED;
+ else if (nStates & com::sun::star::accessibility::AccessibleStateType::CHECKED)
+ eState = GTK_ACCESSIBLE_TRISTATE_TRUE;
+ gtk_accessible_update_state(GTK_ACCESSIBLE(ret), GTK_ACCESSIBLE_STATE_CHECKED, eState, -1);
+ }
+ else if (nRole == com::sun::star::accessibility::AccessibleRole::TOGGLE_BUTTON)
+ {
+ GtkAccessibleTristate eState = GTK_ACCESSIBLE_TRISTATE_FALSE;
+ if (nStates & com::sun::star::accessibility::AccessibleStateType::INDETERMINATE)
+ eState = GTK_ACCESSIBLE_TRISTATE_MIXED;
+ else if (nStates & com::sun::star::accessibility::AccessibleStateType::PRESSED)
+ eState = GTK_ACCESSIBLE_TRISTATE_TRUE;
+ gtk_accessible_update_state(GTK_ACCESSIBLE(ret), GTK_ACCESSIBLE_STATE_PRESSED, eState, -1);
+ }
+
// set values from XAccessibleValue interface if that's implemented
css::uno::Reference<css::accessibility::XAccessibleValue> xAccessibleValue(xContext,
css::uno::UNO_QUERY);