Windows QPA: fix tree item discovery through UI Automation

This change reverts a workaround for a compatibility issue with
a Windows utility, which is no longer necessary with Qt6 and was
in some cases preventing accessibility tools from discovering
tree items.

This reverts commit 1c55a6caf1.

Fixes: QTBUG-105814
Pick-to: 6.4 6.3 6.2
Change-Id: Id464da49704b6953affca2fa40acc03f1ffd05ac
Reviewed-by: Oliver Wolff <oliver.wolff@qt.io>
bb10
André de la Rocha 2022-08-10 03:00:26 +02:00
parent 1ecfc4101c
commit 62d957f6aa
1 changed files with 11 additions and 19 deletions

View File

@ -699,26 +699,18 @@ HRESULT QWindowsUiaMainProvider::ElementProviderFromPoint(double x, double y, IR
QPoint point;
nativeUiaPointToPoint(uiaPoint, window, &point);
if (auto targetacc = accessible->childAt(point.x(), point.y())) {
auto acc = accessible->childAt(point.x(), point.y());
// Reject the cases where childAt() returns a different instance in each call for the same
// element (e.g., QAccessibleTree), as it causes an endless loop with Youdao Dictionary installed.
if (targetacc == acc) {
// Controls can be embedded within grouping elements. By default returns the innermost control.
while (acc) {
targetacc = acc;
// For accessibility tools it may be better to return the text element instead of its subcomponents.
if (targetacc->textInterface()) break;
acc = targetacc->childAt(point.x(), point.y());
if (acc != targetacc->childAt(point.x(), point.y())) {
qCDebug(lcQpaUiAutomation) << "Non-unique childAt() for" << targetacc;
break;
}
}
*pRetVal = providerForAccessible(targetacc);
} else {
qCDebug(lcQpaUiAutomation) << "Non-unique childAt() for" << accessible;
QAccessibleInterface *targetacc = accessible->childAt(point.x(), point.y());
if (targetacc) {
QAccessibleInterface *acc = targetacc;
// Controls can be embedded within grouping elements. By default returns the innermost control.
while (acc) {
targetacc = acc;
// For accessibility tools it may be better to return the text element instead of its subcomponents.
if (targetacc->textInterface()) break;
acc = acc->childAt(point.x(), point.y());
}
*pRetVal = providerForAccessible(targetacc);
}
return S_OK;
}