a11y atspi: Report app parent

While the application's a11y object doesn't have a parent
within Qt's a11y hierarchy, the AT-SPI registry/desktop is the
parent of all application objects.

Therefore, report that one instead of using a null path.

With that in place, querying the application parent
via Accerciser's IPython console now gives the expected
result:

    In [16]: acc.role
    Out[16]: <enum ATSPI_ROLE_APPLICATION of type Atspi.Role>
    In [17]: acc.parent
    Out[17]: <Atspi.Accessible object at 0x7fbebc3fc1c0 (AtspiAccessible at 0x139d6410)>
    In [18]: acc.parent.role
    Out[18]: <enum ATSPI_ROLE_DESKTOP_FRAME of type Atspi.Role>

While at it, also add a "m_" prefix for the
AtspiAdaptor::accessibilityRegistry member.

Fixes: QTBUG-132935
Change-Id: I0e174f73c837b233fe4d5788d1c375b404000025
Reviewed-by: Jan Arve Sæther <jan-arve.saether@qt.io>
(cherry picked from commit befce757faa0b0abd2c1f4ec408c1a0932794b0c)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
Michael Weghorn 2025-01-20 13:17:00 +01:00 committed by Qt Cherry-pick Bot
parent 4924480944
commit bd1cb1547f
2 changed files with 8 additions and 2 deletions

View File

@ -1546,7 +1546,7 @@ void AtSpiAdaptor::registerApplication()
reply.waitForFinished(); // TODO: make this async
if (reply.isValid ()) {
const QSpiObjectReference &socket = reply.value();
accessibilityRegistry = QSpiObjectReference(socket);
m_accessibilityRegistry = QSpiObjectReference(socket);
} else {
qCWarning(lcAccessibilityAtspi) << "Error in contacting registry:"
<< reply.error().name()
@ -1582,6 +1582,12 @@ bool AtSpiAdaptor::accessibleInterface(QAccessibleInterface *interface, const QS
QString path;
QAccessibleInterface * parent = interface->parent();
if (!parent) {
if (interface->object() == qApp) {
sendReply(connection, message,
QVariant::fromValue(QDBusVariant(QVariant::fromValue(m_accessibilityRegistry))));
return true;
}
path = ATSPI_DBUS_PATH_NULL ""_L1;
} else if (parent->role() == QAccessible::Application) {
path = ATSPI_DBUS_PATH_ROOT ""_L1;

View File

@ -113,7 +113,7 @@ private:
static bool inheritsQAction(QObject *object);
// private vars
QSpiObjectReference accessibilityRegistry;
QSpiObjectReference m_accessibilityRegistry;
QAtSpiDBusConnection *m_dbus;
QSpiApplicationAdaptor *m_applicationAdaptor;