summaryrefslogtreecommitdiffstats
path: root/src/plugins/platforms/windows
diff options
context:
space:
mode:
authorAndre de la Rocha <andre.rocha@qt.io>2020-03-02 20:30:13 +0100
committerAndre de la Rocha <andre.rocha@qt.io>2020-03-04 13:09:48 +0100
commit566def740ec58e842e6bb37177f80e20aebaa245 (patch)
treeaa2bac7a70531a0e84e5fade27c70f4a1b41affa /src/plugins/platforms/windows
parent295a16b0d3836a8f41b5133bcd9f355afb03f38b (diff)
Windows QPA: Add support to UiaRaiseNotificationEvent()
This change adds support to UiaRaiseNotificationEvent() in the UI Automation-based accessibility code, and uses it to notify changes in string-typed values, allowing Narrator, NVDA and other screen readers to notice changes in the application state that were previously missed. Fixes: QTBUG-75003 Change-Id: I646ca3a851ab7b69817d900b002eb91a3bf607a6 Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
Diffstat (limited to 'src/plugins/platforms/windows')
-rw-r--r--src/plugins/platforms/windows/uiautomation/qwindowsuiamainprovider.cpp26
1 files changed, 21 insertions, 5 deletions
diff --git a/src/plugins/platforms/windows/uiautomation/qwindowsuiamainprovider.cpp b/src/plugins/platforms/windows/uiautomation/qwindowsuiamainprovider.cpp
index 9adc5c78dd..59360616a1 100644
--- a/src/plugins/platforms/windows/uiautomation/qwindowsuiamainprovider.cpp
+++ b/src/plugins/platforms/windows/uiautomation/qwindowsuiamainprovider.cpp
@@ -166,11 +166,27 @@ void QWindowsUiaMainProvider::notifyValueChange(QAccessibleValueChangeEvent *eve
}
if (event->value().type() == QVariant::String) {
if (QWindowsUiaMainProvider *provider = providerForAccessible(accessible)) {
- // Notifies changes in string values.
- VARIANT oldVal, newVal;
- clearVariant(&oldVal);
- setVariantString(event->value().toString(), &newVal);
- QWindowsUiaWrapper::instance()->raiseAutomationPropertyChangedEvent(provider, UIA_ValueValuePropertyId, oldVal, newVal);
+
+ // Tries to notify the change using UiaRaiseNotificationEvent(), which is only available on
+ // Windows 10 version 1709 or newer. Otherwise uses UiaRaiseAutomationPropertyChangedEvent().
+
+ BSTR displayString = bStrFromQString(event->value().toString());
+ BSTR activityId = bStrFromQString(QString());
+
+ HRESULT hr = QWindowsUiaWrapper::instance()->raiseNotificationEvent(provider, NotificationKind_Other,
+ NotificationProcessing_ImportantMostRecent,
+ displayString, activityId);
+
+ ::SysFreeString(displayString);
+ ::SysFreeString(activityId);
+
+ if (hr == static_cast<HRESULT>(UIA_E_NOTSUPPORTED)) {
+ VARIANT oldVal, newVal;
+ clearVariant(&oldVal);
+ setVariantString(event->value().toString(), &newVal);
+ QWindowsUiaWrapper::instance()->raiseAutomationPropertyChangedEvent(provider, UIA_ValueValuePropertyId, oldVal, newVal);
+ ::SysFreeString(newVal.bstrVal);
+ }
}
} else if (QAccessibleValueInterface *valueInterface = accessible->valueInterface()) {
if (QWindowsUiaMainProvider *provider = providerForAccessible(accessible)) {