Windows QPA: Fix missing accessible name change events

Accessible name change events were not being relayed through UI Automation.
This caused changes in the state of combo boxes and possibly other quick
controls to be missed by UI Automation clients. This would result, for
instance, in Narrator not reading the state of a combo box when its current
index was changed with the keyboard.

Fixes: QTBUG-70621
Pick-to: 5.15
Change-Id: I16de0ff2bb0fb5227111d5347c25f442e9b0a533
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
Reviewed-by: Oliver Wolff <oliver.wolff@qt.io>
This commit is contained in:
Andre de la Rocha 2020-04-29 17:07:24 +02:00 committed by André de la Rocha
parent c54279a1ad
commit a77b19a911
3 changed files with 17 additions and 0 deletions

View File

@ -167,6 +167,9 @@ void QWindowsUiaAccessibility::notifyAccessibilityUpdate(QAccessibleEvent *event
case QAccessible::ValueChanged:
QWindowsUiaMainProvider::notifyValueChange(static_cast<QAccessibleValueChangeEvent *>(event));
break;
case QAccessible::NameChanged:
QWindowsUiaMainProvider::notifyNameChange(event);
break;
case QAccessible::SelectionAdd:
QWindowsUiaMainProvider::notifySelectionChange(event);
break;

View File

@ -200,6 +200,19 @@ void QWindowsUiaMainProvider::notifyValueChange(QAccessibleValueChangeEvent *eve
}
}
void QWindowsUiaMainProvider::notifyNameChange(QAccessibleEvent *event)
{
if (QAccessibleInterface *accessible = event->accessibleInterface()) {
if (QWindowsUiaMainProvider *provider = providerForAccessible(accessible)) {
VARIANT oldVal, newVal;
clearVariant(&oldVal);
setVariantString(accessible->text(QAccessible::Name), &newVal);
QWindowsUiaWrapper::instance()->raiseAutomationPropertyChangedEvent(provider, UIA_NamePropertyId, oldVal, newVal);
::SysFreeString(newVal.bstrVal);
}
}
}
void QWindowsUiaMainProvider::notifySelectionChange(QAccessibleEvent *event)
{
if (QAccessibleInterface *accessible = event->accessibleInterface()) {

View File

@ -68,6 +68,7 @@ public:
static void notifyFocusChange(QAccessibleEvent *event);
static void notifyStateChange(QAccessibleStateChangeEvent *event);
static void notifyValueChange(QAccessibleValueChangeEvent *event);
static void notifyNameChange(QAccessibleEvent *event);
static void notifySelectionChange(QAccessibleEvent *event);
static void notifyTextChange(QAccessibleEvent *event);