Skip to content

Commit

Permalink
Windows QPA: Fix UIA-to-MSAA accessibility bridge
Browse files Browse the repository at this point in the history
According to MS sample code, MSAA requests should be replied with
UI Automation providers to enable the use the UIA-to-MSAA bridge, in
order to support MSAA-only clients. Also changing the mapping of
QAccessible::Client from UIA_CustomControlTypeId to UIA_GroupControlTypeId,
as it seems more appropriate and avoids an incorrect mapping to a push button
type in the UIA-to-MSAA conversion.

Change-Id: I5149d250da2d1bd7b14b44ca46e856a81c9be045
Reviewed-by: Friedemann Kleint <[email protected]>
  • Loading branch information
Andre de la Rocha committed Aug 6, 2018
1 parent a09a288 commit f271dd8
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -68,21 +68,18 @@ QWindowsUiaAccessibility::~QWindowsUiaAccessibility()
// Handles UI Automation window messages.
bool QWindowsUiaAccessibility::handleWmGetObject(HWND hwnd, WPARAM wParam, LPARAM lParam, LRESULT *lResult)
{
if (lParam == LPARAM(UiaRootObjectId)) {

// Start handling accessibility internally
QGuiApplicationPrivate::platformIntegration()->accessibility()->setActive(true);

// Ignoring all requests while starting up / shutting down
if (QCoreApplication::startingUp() || QCoreApplication::closingDown())
return false;

if (QWindow *window = QWindowsContext::instance()->findWindow(hwnd)) {
if (QAccessibleInterface *accessible = window->accessibleRoot()) {
QWindowsUiaMainProvider *provider = QWindowsUiaMainProvider::providerForAccessible(accessible);
*lResult = QWindowsUiaWrapper::instance()->returnRawElementProvider(hwnd, wParam, lParam, provider);
return true;
}
// Start handling accessibility internally
QGuiApplicationPrivate::platformIntegration()->accessibility()->setActive(true);

// Ignoring all requests while starting up / shutting down
if (QCoreApplication::startingUp() || QCoreApplication::closingDown())
return false;

if (QWindow *window = QWindowsContext::instance()->findWindow(hwnd)) {
if (QAccessibleInterface *accessible = window->accessibleRoot()) {
QWindowsUiaMainProvider *provider = QWindowsUiaMainProvider::providerForAccessible(accessible);
*lResult = QWindowsUiaWrapper::instance()->returnRawElementProvider(hwnd, wParam, lParam, provider);
return true;
}
}
return false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ long roleToControlTypeId(QAccessible::Role role)
{QAccessible::Caret, UIA_CustomControlTypeId},
{QAccessible::AlertMessage, UIA_CustomControlTypeId},
{QAccessible::Window, UIA_WindowControlTypeId},
{QAccessible::Client, UIA_CustomControlTypeId},
{QAccessible::Client, UIA_GroupControlTypeId},
{QAccessible::PopupMenu, UIA_MenuControlTypeId},
{QAccessible::MenuItem, UIA_MenuItemControlTypeId},
{QAccessible::ToolTip, UIA_ToolTipControlTypeId},
Expand Down

0 comments on commit f271dd8

Please sign in to comment.