diff options
author | Michael Weghorn <m.weghorn@posteo.de> | 2022-08-25 13:56:53 +0200 |
---|---|---|
committer | Michael Weghorn <m.weghorn@posteo.de> | 2022-08-25 14:55:31 +0200 |
commit | 9d2c9a592ad697fd332b9bccb63e30c955f49422 (patch) | |
tree | 083c200a861377647c84463f35da6f213648b8d8 /vcl | |
parent | 9c3c564659320fb24d2a9c230464f06cf855a136 (diff) |
qt a11y: Work around Qt ignoring ActiveDescendantChanged events
While Qt has a `QAccessible::ActiveDescendantChanged` event type,
events of that type are just ignored in Qt's AT-SPI adapter [1].
Work around that by sending a "focused" event for the child
instead, for which handling inside Qt has been added in [2].
While adding support for properly handling
`QAccessible::ActiveDescendantChanged` in Qt might be
worth looking into at some point, this appears to
work just fine for now and e.g. makes Orca announce
the focused cell in Calc when moving between cells using
the keyboard in the qt6 VCL plugin.
[1] https://code.qt.io/cgit/qt/qtbase.git/tree/src/gui/accessible/linux/atspiadaptor.cpp?id=0131dbd2f95449c09758208d8b190c9238a5c46a#n1121
[2] https://code.qt.io/cgit/qt/qtbase.git/commit/?id=f3509565480107c2587212f7d55cc5f92facc417
Change-Id: I809695de427b6438d37a5a4840044e7ca3d4cd08
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/138809
Tested-by: Jenkins
Reviewed-by: Michael Weghorn <m.weghorn@posteo.de>
Diffstat (limited to 'vcl')
-rw-r--r-- | vcl/qt5/QtAccessibleEventListener.cxx | 19 |
1 files changed, 17 insertions, 2 deletions
diff --git a/vcl/qt5/QtAccessibleEventListener.cxx b/vcl/qt5/QtAccessibleEventListener.cxx index 53256181ea4e..dd2ee1b2eae6 100644 --- a/vcl/qt5/QtAccessibleEventListener.cxx +++ b/vcl/qt5/QtAccessibleEventListener.cxx @@ -18,6 +18,7 @@ */ #include <QtAccessibleEventListener.hxx> +#include <QtAccessibleRegistry.hxx> #include <QtTools.hxx> #include <sal/log.hxx> @@ -171,9 +172,23 @@ void QtAccessibleEventListener::notifyEvent(const css::accessibility::Accessible new QAccessibleEvent(pQAccessibleInterface, QAccessible::ActionChanged)); return; case AccessibleEventId::ACTIVE_DESCENDANT_CHANGED: - QAccessible::updateAccessibility( - new QAccessibleEvent(pQAccessibleInterface, QAccessible::ActiveDescendantChanged)); + { + // Qt has a QAccessible::ActiveDescendantChanged event type, but events of + // that type are currently just ignored on Qt side and not forwarded to AT-SPI. + // Send a state change event for the focused state of the newly + // active descendant instead + uno::Reference<accessibility::XAccessible> xActiveAccessible; + aEvent.NewValue >>= xActiveAccessible; + if (!xActiveAccessible.is()) + return; + + QObject* pQtAcc = QtAccessibleRegistry::getQObject(xActiveAccessible); + QAccessibleInterface* pInterface = QAccessible::queryAccessibleInterface(pQtAcc); + QAccessible::State aState; + aState.focused = true; + QAccessible::updateAccessibility(new QAccessibleStateChangeEvent(pInterface, aState)); return; + } case AccessibleEventId::CARET_CHANGED: { sal_Int32 nNewCursorPos = 0; |