From a77b19a911c4d6c47c185a8e59ebbcec8b14bcca Mon Sep 17 00:00:00 2001 From: Andre de la Rocha Date: Wed, 29 Apr 2020 17:07:24 +0200 Subject: [PATCH] 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 Reviewed-by: Oliver Wolff --- .../uiautomation/qwindowsuiaaccessibility.cpp | 3 +++ .../uiautomation/qwindowsuiamainprovider.cpp | 13 +++++++++++++ .../windows/uiautomation/qwindowsuiamainprovider.h | 1 + 3 files changed, 17 insertions(+) diff --git a/src/plugins/platforms/windows/uiautomation/qwindowsuiaaccessibility.cpp b/src/plugins/platforms/windows/uiautomation/qwindowsuiaaccessibility.cpp index fef5346eaf..93b9622655 100644 --- a/src/plugins/platforms/windows/uiautomation/qwindowsuiaaccessibility.cpp +++ b/src/plugins/platforms/windows/uiautomation/qwindowsuiaaccessibility.cpp @@ -167,6 +167,9 @@ void QWindowsUiaAccessibility::notifyAccessibilityUpdate(QAccessibleEvent *event case QAccessible::ValueChanged: QWindowsUiaMainProvider::notifyValueChange(static_cast(event)); break; + case QAccessible::NameChanged: + QWindowsUiaMainProvider::notifyNameChange(event); + break; case QAccessible::SelectionAdd: QWindowsUiaMainProvider::notifySelectionChange(event); break; diff --git a/src/plugins/platforms/windows/uiautomation/qwindowsuiamainprovider.cpp b/src/plugins/platforms/windows/uiautomation/qwindowsuiamainprovider.cpp index 3962d2d27f..9808d5481c 100644 --- a/src/plugins/platforms/windows/uiautomation/qwindowsuiamainprovider.cpp +++ b/src/plugins/platforms/windows/uiautomation/qwindowsuiamainprovider.cpp @@ -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()) { diff --git a/src/plugins/platforms/windows/uiautomation/qwindowsuiamainprovider.h b/src/plugins/platforms/windows/uiautomation/qwindowsuiamainprovider.h index cdc239ed99..f7320388f7 100644 --- a/src/plugins/platforms/windows/uiautomation/qwindowsuiamainprovider.h +++ b/src/plugins/platforms/windows/uiautomation/qwindowsuiamainprovider.h @@ -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);