From f3509565480107c2587212f7d55cc5f92facc417 Mon Sep 17 00:00:00 2001 From: Michael Weghorn Date: Wed, 15 Jun 2022 16:39:52 +0200 Subject: [PATCH] a11y atspi: Forward change of focused state MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The focused state exists in both, Qt (QAccessible::State::focused) and AT-SPI, so forwarding changes to that state is straightforward. However, so far, changes to the focused state in a QAccessible::StateChanged event were just ignored and not forwarded to the AT-SPI layer. While announcing focus changes to Qt's own widgets works without that because it uses events of type QAccessible::Focus instead of QAccessibleStateChangeEvent with the focused state set, this is not exactly the same and just ignoring the focused state in QAccessible::StateChanged events e.g. turned out to be one cause for the Orca screen reader not announcing UI elements when they received focus in the Qt-based UI variant of LibreOffice, which uses QAccessible::StateChanged with the focused flag set (s.a. LibreOffice commit [1]). [1] https://git.libreoffice.org/core/commit/8c3e8af0e60865ec6d38e2117efdb4ed2f10a20c Change-Id: If226af28960048c56af32979477605d6860e30e9 Reviewed-by: Tor Arne Vestbø --- src/gui/accessible/linux/atspiadaptor.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/gui/accessible/linux/atspiadaptor.cpp b/src/gui/accessible/linux/atspiadaptor.cpp index 6a51107531..f857d1985a 100644 --- a/src/gui/accessible/linux/atspiadaptor.cpp +++ b/src/gui/accessible/linux/atspiadaptor.cpp @@ -1066,6 +1066,11 @@ void AtSpiAdaptor::notify(QAccessibleEvent *event) notifyStateChange(iface, "enabled"_L1, enabled); notifyStateChange(iface, "sensitive"_L1, enabled); + } else if (stateChange.focused) { + QAccessibleInterface *iface = event->accessibleInterface(); + QAccessible::State state = iface->state(); + bool focused = state.focused; + notifyStateChange(iface, "focused"_L1, focused); } } break;