diff options
author | Frederik Gladhorn <frederik.gladhorn@theqtcompany.com> | 2015-02-16 14:15:33 +0100 |
---|---|---|
committer | Frederik Gladhorn <frederik.gladhorn@theqtcompany.com> | 2015-03-09 09:30:44 +0000 |
commit | d23562da1c4cb525d4012bee55bd665c6cafef04 (patch) | |
tree | 1e230a88f9cc41701cc8284737bc9da01a8011f1 /src/plugins | |
parent | 4dc459837b42cbfff9a8e0325dc3319cc87e02ac (diff) |
A11y: query a11y bus address from X display
Attempt to get the accessibility bus address from the X display, to
match libatspi's behavior. This allows the accessibility bus to be
found when an application is running as root.
[ChangeLog][QtGui] Linux accessibility (using XCB) will now works for
applications launched as root
Done-with: Mike Gorse
Change-Id: I49a263571b328cbd1fd90cb7f5cb40919d2a4951
Task-number: QTBUG-43674
Reviewed-by: Laszlo Agocs <laszlo.agocs@theqtcompany.com>
Reviewed-by: Jørgen Lind <jorgen.lind@theqtcompany.com>
Diffstat (limited to 'src/plugins')
-rw-r--r-- | src/plugins/platforms/xcb/qxcbnativeinterface.cpp | 27 | ||||
-rw-r--r-- | src/plugins/platforms/xcb/qxcbnativeinterface.h | 4 |
2 files changed, 29 insertions, 2 deletions
diff --git a/src/plugins/platforms/xcb/qxcbnativeinterface.cpp b/src/plugins/platforms/xcb/qxcbnativeinterface.cpp index c6aa25350d..a375128288 100644 --- a/src/plugins/platforms/xcb/qxcbnativeinterface.cpp +++ b/src/plugins/platforms/xcb/qxcbnativeinterface.cpp @@ -77,7 +77,8 @@ static int resourceType(const QByteArray &key) QByteArrayLiteral("gettimestamp"), QByteArrayLiteral("x11screen"), QByteArrayLiteral("rootwindow"), QByteArrayLiteral("subpixeltype"), QByteArrayLiteral("antialiasingEnabled"), - QByteArrayLiteral("nofonthinting") + QByteArrayLiteral("nofonthinting"), + QByteArrayLiteral("atspibus") }; const QByteArray *end = names + sizeof(names) / sizeof(names[0]); const QByteArray *result = std::find(names, end, key); @@ -175,6 +176,9 @@ void *QXcbNativeInterface::nativeResourceForIntegration(const QByteArray &resour case Display: result = display(); break; + case AtspiBus: + result = atspiBus(); + break; default: break; } @@ -402,6 +406,27 @@ void *QXcbNativeInterface::display() #endif } +void *QXcbNativeInterface::atspiBus() +{ + QXcbIntegration *integration = static_cast<QXcbIntegration *>(QGuiApplicationPrivate::platformIntegration()); + QXcbConnection *defaultConnection = integration->defaultConnection(); + if (defaultConnection) { + xcb_atom_t atspiBusAtom = defaultConnection->internAtom("AT_SPI_BUS"); + xcb_get_property_cookie_t cookie = Q_XCB_CALL(xcb_get_property(defaultConnection->xcb_connection(), false, + defaultConnection->rootWindow(), + atspiBusAtom, + XCB_ATOM_STRING, 0, 128)); + xcb_get_property_reply_t *reply = Q_XCB_CALL(xcb_get_property_reply(defaultConnection->xcb_connection(), cookie, 0)); + Q_ASSERT(!reply->bytes_after); + char *data = (char *)xcb_get_property_value(reply); + int length = xcb_get_property_value_length(reply); + QByteArray *busAddress = new QByteArray(data, length); + free(reply); + return busAddress; + } + return 0; +} + void QXcbNativeInterface::setAppTime(QScreen* screen, xcb_timestamp_t time) { static_cast<QXcbScreen *>(screen->handle())->connection()->setTime(time); diff --git a/src/plugins/platforms/xcb/qxcbnativeinterface.h b/src/plugins/platforms/xcb/qxcbnativeinterface.h index b6c207785f..054c0ec2b5 100644 --- a/src/plugins/platforms/xcb/qxcbnativeinterface.h +++ b/src/plugins/platforms/xcb/qxcbnativeinterface.h @@ -67,7 +67,8 @@ public: RootWindow, ScreenSubpixelType, ScreenAntialiasingEnabled, - NoFontHinting + NoFontHinting, + AtspiBus }; QXcbNativeInterface(); @@ -98,6 +99,7 @@ public: void *x11Screen(); void *rootWindow(); void *display(); + void *atspiBus(); static void setStartupId(const char *); static void setAppTime(QScreen *screen, xcb_timestamp_t time); static void setAppUserTime(QScreen *screen, xcb_timestamp_t time); |