Revert "Windows QPA: Add support to UiaRaiseNotificationEvent()"

This reverts commit 566def740ec58e842e6bb37177f80e20aebaa245.

The fix had some unwanted side-effects when the
QAccessibleValueChangeEvent carried a value of type string. Only
QComboBox uses QAccessibleValueChangeEvent in such a way.
The consequence of the reverted patch was that it broke QComboBox
so that the screen reader would read aloud the value change event
regardless of the visibility or focus state of the QComboBox. (Thus, if
you e.g. changed the QComboBox::currentIndex on a *hidden* combo box,
the screen reader would still read aloud the event)
This is also the root cause of what is described in QTBUG-93763.

Also, due to the usage of NotificationProcessing_ImportantMostRecent
the screen reader would treat it as such an important event that it
would abort whatever it was currently speaking.

In addition, the reverted change didn't fix any bugs and it failed to
implement the suggested behavior in a correct way (as was described in
QTBUG-75003 - albeit properly described after the change was merged).
QTBUG-75003 has already been reopened due to this, and the change can
therefore be reverted quite risk-free.

Task-number: QTBUG-75003
Task-number: QTBUG-93763
Change-Id: Ib91872adc563c31534fe2b30fd9c447bfcca6b40
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
(cherry picked from commit 193fb8bb68e35f6ad25a7d62a6e321bd41ecf688)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
Jan Arve Sæther 2023-08-16 09:51:52 +02:00 committed by Qt Cherry-pick Bot
parent bc88069890
commit a3346dbef3
4 changed files with 6 additions and 49 deletions

View File

@ -17,7 +17,6 @@ QWindowsUiaWrapper::QWindowsUiaWrapper()
m_pUiaHostProviderFromHwnd = reinterpret_cast<PtrUiaHostProviderFromHwnd>(uiaLib.resolve("UiaHostProviderFromHwnd"));
m_pUiaRaiseAutomationPropertyChangedEvent = reinterpret_cast<PtrUiaRaiseAutomationPropertyChangedEvent>(uiaLib.resolve("UiaRaiseAutomationPropertyChangedEvent"));
m_pUiaRaiseAutomationEvent = reinterpret_cast<PtrUiaRaiseAutomationEvent>(uiaLib.resolve("UiaRaiseAutomationEvent"));
m_pUiaRaiseNotificationEvent = reinterpret_cast<PtrUiaRaiseNotificationEvent>(uiaLib.resolve("UiaRaiseNotificationEvent"));
m_pUiaClientsAreListening = reinterpret_cast<PtrUiaClientsAreListening>(uiaLib.resolve("UiaClientsAreListening"));
}
}
@ -33,7 +32,7 @@ QWindowsUiaWrapper *QWindowsUiaWrapper::instance()
return &wrapper;
}
// True if most symbols resolved (UiaRaiseNotificationEvent is optional).
// True if all symbols resolved.
BOOL QWindowsUiaWrapper::ready()
{
return m_pUiaReturnRawElementProvider
@ -78,12 +77,5 @@ HRESULT QWindowsUiaWrapper::raiseAutomationEvent(IRawElementProviderSimple *pPro
return m_pUiaRaiseAutomationEvent(pProvider, id);
}
HRESULT QWindowsUiaWrapper::raiseNotificationEvent(IRawElementProviderSimple *provider, NotificationKind notificationKind, NotificationProcessing notificationProcessing, BSTR displayString, BSTR activityId)
{
if (!m_pUiaRaiseNotificationEvent)
return UIA_E_NOTSUPPORTED;
return m_pUiaRaiseNotificationEvent(provider, notificationKind, notificationProcessing, displayString, activityId);
}
QT_END_NAMESPACE

View File

@ -44,20 +44,17 @@ public:
HRESULT hostProviderFromHwnd(HWND hwnd, IRawElementProviderSimple **ppProvider);
HRESULT raiseAutomationPropertyChangedEvent(IRawElementProviderSimple *pProvider, PROPERTYID id, VARIANT oldValue, VARIANT newValue);
HRESULT raiseAutomationEvent(IRawElementProviderSimple *pProvider, EVENTID id);
HRESULT raiseNotificationEvent(IRawElementProviderSimple *provider, NotificationKind notificationKind, NotificationProcessing notificationProcessing, BSTR displayString, BSTR activityId);
private:
typedef LRESULT (WINAPI *PtrUiaReturnRawElementProvider)(HWND, WPARAM, LPARAM, IRawElementProviderSimple *);
typedef HRESULT (WINAPI *PtrUiaHostProviderFromHwnd)(HWND, IRawElementProviderSimple **);
typedef HRESULT (WINAPI *PtrUiaRaiseAutomationPropertyChangedEvent)(IRawElementProviderSimple *, PROPERTYID, VARIANT, VARIANT);
typedef HRESULT (WINAPI *PtrUiaRaiseAutomationEvent)(IRawElementProviderSimple *, EVENTID);
typedef HRESULT (WINAPI *PtrUiaRaiseNotificationEvent)(IRawElementProviderSimple *, NotificationKind, NotificationProcessing, BSTR, BSTR);
typedef BOOL (WINAPI *PtrUiaClientsAreListening)();
PtrUiaReturnRawElementProvider m_pUiaReturnRawElementProvider = nullptr;
PtrUiaHostProviderFromHwnd m_pUiaHostProviderFromHwnd = nullptr;
PtrUiaRaiseAutomationPropertyChangedEvent m_pUiaRaiseAutomationPropertyChangedEvent = nullptr;
PtrUiaRaiseAutomationEvent m_pUiaRaiseAutomationEvent = nullptr;
PtrUiaRaiseNotificationEvent m_pUiaRaiseNotificationEvent = nullptr;
PtrUiaClientsAreListening m_pUiaClientsAreListening = nullptr;
};

View File

@ -126,22 +126,6 @@ enum ExpandCollapseState {
ExpandCollapseState_LeafNode = 3
};
enum NotificationKind {
NotificationKind_ItemAdded = 0,
NotificationKind_ItemRemoved = 1,
NotificationKind_ActionCompleted = 2,
NotificationKind_ActionAborted = 3,
NotificationKind_Other = 4
};
enum NotificationProcessing {
NotificationProcessing_ImportantAll = 0,
NotificationProcessing_ImportantMostRecent = 1,
NotificationProcessing_All = 2,
NotificationProcessing_MostRecent = 3,
NotificationProcessing_CurrentThenMostRecent = 4
};
struct UiaRect {
double left;
double top;

View File

@ -141,27 +141,11 @@ void QWindowsUiaMainProvider::notifyValueChange(QAccessibleValueChangeEvent *eve
}
if (event->value().typeId() == QMetaType::QString) {
if (QWindowsUiaMainProvider *provider = providerForAccessible(accessible)) {
// 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);
}
// Notifies changes in string values.
VARIANT oldVal, newVal;
clearVariant(&oldVal);
setVariantString(event->value().toString(), &newVal);
QWindowsUiaWrapper::instance()->raiseAutomationPropertyChangedEvent(provider, UIA_ValueValuePropertyId, oldVal, newVal);
}
} else if (QAccessibleValueInterface *valueInterface = accessible->valueInterface()) {
if (QWindowsUiaMainProvider *provider = providerForAccessible(accessible)) {