Sophie

Sophie

distrib > Mageia > cauldron > x86_64 > media > core-release-src > by-pkgid > 4c532bfb9916518564da5ba2805999f5 > files > 128

qtbase5-5.15.12-3.mga10.src.rpm

From 50cf9b88d5688784b13ed93bf1afa94853a4df86 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Jan=20Arve=20S=C3=A6ther?= <jan-arve.saether@qt.io>
Date: Wed, 16 Aug 2023 09:51:52 +0200
Subject: [PATCH 130/147] Revert "Windows QPA: Add support to
 UiaRaiseNotificationEvent()"
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

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
Pick-to: 6.6 6.5 6.2 5.15
Change-Id: Ib91872adc563c31534fe2b30fd9c447bfcca6b40
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
(cherry picked from commit 193fb8bb68e35f6ad25a7d62a6e321bd41ecf688)
---
 .../qwindowsuiawrapper.cpp                    | 10 +------
 .../qwindowsuiawrapper_p.h                    |  3 ---
 .../windowsuiautomation/uiatypes_p.h          | 16 ------------
 .../uiautomation/qwindowsuiamainprovider.cpp  | 26 ++++---------------
 4 files changed, 6 insertions(+), 49 deletions(-)

diff --git a/src/platformsupport/windowsuiautomation/qwindowsuiawrapper.cpp b/src/platformsupport/windowsuiautomation/qwindowsuiawrapper.cpp
index 8038e1a3c3..79541fe636 100644
--- a/src/platformsupport/windowsuiautomation/qwindowsuiawrapper.cpp
+++ b/src/platformsupport/windowsuiautomation/qwindowsuiawrapper.cpp
@@ -53,7 +53,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"));
     }
 }
@@ -69,7 +68,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
@@ -114,12 +113,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
 
diff --git a/src/platformsupport/windowsuiautomation/qwindowsuiawrapper_p.h b/src/platformsupport/windowsuiautomation/qwindowsuiawrapper_p.h
index 9208acbc31..3ebc3008d3 100644
--- a/src/platformsupport/windowsuiautomation/qwindowsuiawrapper_p.h
+++ b/src/platformsupport/windowsuiautomation/qwindowsuiawrapper_p.h
@@ -80,20 +80,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;
 };
 
diff --git a/src/platformsupport/windowsuiautomation/uiatypes_p.h b/src/platformsupport/windowsuiautomation/uiatypes_p.h
index 0d2e1161e4..afbc957094 100644
--- a/src/platformsupport/windowsuiautomation/uiatypes_p.h
+++ b/src/platformsupport/windowsuiautomation/uiatypes_p.h
@@ -162,22 +162,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;
diff --git a/src/plugins/platforms/windows/uiautomation/qwindowsuiamainprovider.cpp b/src/plugins/platforms/windows/uiautomation/qwindowsuiamainprovider.cpp
index 754ded14f1..059df8d991 100644
--- a/src/plugins/platforms/windows/uiautomation/qwindowsuiamainprovider.cpp
+++ b/src/plugins/platforms/windows/uiautomation/qwindowsuiamainprovider.cpp
@@ -169,27 +169,11 @@ void QWindowsUiaMainProvider::notifyValueChange(QAccessibleValueChangeEvent *eve
         }
         if (event->value().type() == QVariant::String) {
             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)) {
-- 
2.40.1