diff options
author | André de la Rocha <andre.rocha@qt.io> | 2022-03-25 14:40:56 -0300 |
---|---|---|
committer | Qt Cherry-pick Bot <cherrypick_bot@qt-project.org> | 2022-03-31 12:19:17 +0000 |
commit | a6760fd4a9c8a53a3430c4ef876c52b4d15e769b (patch) | |
tree | 0a3c4d5fbf21fcea5ca102825d3eed8ba41798f6 | |
parent | 09360954d5e7f982e10a1098edc538c3259a2306 (diff) |
Windows QPA: Avoid sending accessibility notifications before activation
When accessibility was activated after the application startup, it would
send state update notifications for every accessible object, which for a
large number of objects could result in a flood of UI Automation
notifications and UI slowdown. This patch ignores these notifications
until QAccessible is activated, which should avoid the slowdown and
seems to cause no side effects with accessibility tools.
Fixes: QTBUG-95114
Change-Id: If1495d0aa846d7810b3d297b7e156563a7e5f6e6
Reviewed-by: Jan Arve Sæther <jan-arve.saether@qt.io>
(cherry picked from commit 350a75f792156724a620ddfb987c27cfd767abbf)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
-rw-r--r-- | src/plugins/platforms/windows/uiautomation/qwindowsuiaaccessibility.cpp | 7 | ||||
-rw-r--r-- | src/plugins/platforms/windows/uiautomation/qwindowsuiaaccessibility.h | 2 |
2 files changed, 9 insertions, 0 deletions
diff --git a/src/plugins/platforms/windows/uiautomation/qwindowsuiaaccessibility.cpp b/src/plugins/platforms/windows/uiautomation/qwindowsuiaaccessibility.cpp index d6c5bd6c49..67db5d08bd 100644 --- a/src/plugins/platforms/windows/uiautomation/qwindowsuiaaccessibility.cpp +++ b/src/plugins/platforms/windows/uiautomation/qwindowsuiaaccessibility.cpp @@ -58,6 +58,7 @@ QT_BEGIN_NAMESPACE using namespace QWindowsUiAutomation; +bool QWindowsUiaAccessibility::m_accessibleActive = false; QWindowsUiaAccessibility::QWindowsUiaAccessibility() { @@ -72,6 +73,7 @@ bool QWindowsUiaAccessibility::handleWmGetObject(HWND hwnd, WPARAM wParam, LPARA { // Start handling accessibility internally QGuiApplicationPrivate::platformIntegration()->accessibility()->setActive(true); + m_accessibleActive = true; // Ignoring all requests while starting up / shutting down if (QCoreApplication::startingUp() || QCoreApplication::closingDown()) @@ -131,6 +133,11 @@ void QWindowsUiaAccessibility::notifyAccessibilityUpdate(QAccessibleEvent *event if (!event) return; + // Ignore events sent before the first UI Automation + // request or while QAccessible is being activated. + if (!m_accessibleActive) + return; + switch (event->type()) { case QAccessible::PopupMenuStart: playSystemSound(QStringLiteral("MenuPopup")); diff --git a/src/plugins/platforms/windows/uiautomation/qwindowsuiaaccessibility.h b/src/plugins/platforms/windows/uiautomation/qwindowsuiaaccessibility.h index b49b37e0c1..c7a0126f51 100644 --- a/src/plugins/platforms/windows/uiautomation/qwindowsuiaaccessibility.h +++ b/src/plugins/platforms/windows/uiautomation/qwindowsuiaaccessibility.h @@ -56,6 +56,8 @@ public: virtual ~QWindowsUiaAccessibility(); static bool handleWmGetObject(HWND hwnd, WPARAM wParam, LPARAM lParam, LRESULT *lResult); void notifyAccessibilityUpdate(QAccessibleEvent *event) override; +private: + static bool m_accessibleActive; }; QT_END_NAMESPACE |