summaryrefslogtreecommitdiffstats
path: root/src/plugins/platforms/windows
diff options
context:
space:
mode:
authorAndré de la Rocha <andre.rocha@qt.io>2022-03-25 14:40:56 -0300
committerAndré de la Rocha <andre.rocha@qt.io>2022-03-31 09:04:08 -0300
commit350a75f792156724a620ddfb987c27cfd767abbf (patch)
tree86c9e9ba2ed2465287b47448a2688f8b262b21a9 /src/plugins/platforms/windows
parentbcd0a3220348778c0d72faac202efb97f4d6dd07 (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 Pick-to: 6.2 6.3 5.15 Change-Id: If1495d0aa846d7810b3d297b7e156563a7e5f6e6 Reviewed-by: Jan Arve Sæther <jan-arve.saether@qt.io>
Diffstat (limited to 'src/plugins/platforms/windows')
-rw-r--r--src/plugins/platforms/windows/uiautomation/qwindowsuiaaccessibility.cpp7
-rw-r--r--src/plugins/platforms/windows/uiautomation/qwindowsuiaaccessibility.h2
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 0903f5a618..5f87badd51 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 48b4f9fa6a..ac01a51e76 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