a11y atspi: Forward change of focused state

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ø <tor.arne.vestbo@qt.io>
This commit is contained in:
Michael Weghorn 2022-06-15 16:39:52 +02:00 committed by Tor Arne Vestbø
parent 64e6233252
commit f350956548

View File

@ -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;