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>
This commit is contained in:
parent
bcd0a32203
commit
350a75f792
@ -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"));
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user