Revert "Accessibility: don't emit focus change when reason is window activation"
This reverts commit 79a11470f3c4c61951906223f97001a77ce36500, which resulted in QTBUG-105735. The new behavior is worse and affects multiple screen readers, while the old issue is isolated to Windows Narrator and could be considered a narrator bug. Task-number: QTBUG-105735 Change-Id: Ic8be1dbd592a3fdf2c3219ec4c5524bc2c7f0f6a Reviewed-by: Jan Arve Sæther <jan-arve.saether@qt.io> (cherry picked from commit d300a0fe765259d490c3510c9e2a8bac58e0aa15) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
parent
9c3434c4e7
commit
5faba47f95
@ -6516,15 +6516,11 @@ void QWidget::setFocus(Qt::FocusReason reason)
|
||||
|
||||
QApplicationPrivate::setFocusWidget(f, reason);
|
||||
#if QT_CONFIG(accessibility)
|
||||
// If the widget gets focus because its window becomes active, then the accessibility
|
||||
// subsystem is already informed about the window opening, and also knows which child
|
||||
// within the window has focus. Don't interrupt it by emitting another focus event.
|
||||
if (reason != Qt::ActiveWindowFocusReason) {
|
||||
// menus update the focus manually and this would create bogus events
|
||||
if (!(f->inherits("QMenuBar") || f->inherits("QMenu") || f->inherits("QMenuItem"))) {
|
||||
QAccessibleEvent event(f, QAccessible::Focus);
|
||||
QAccessible::updateAccessibility(&event);
|
||||
}
|
||||
// menus update the focus manually and this would create bogus events
|
||||
if (!(f->inherits("QMenuBar") || f->inherits("QMenu") || f->inherits("QMenuItem")))
|
||||
{
|
||||
QAccessibleEvent event(f, QAccessible::Focus);
|
||||
QAccessible::updateAccessibility(&event);
|
||||
}
|
||||
#endif
|
||||
#if QT_CONFIG(graphicsview)
|
||||
|
@ -4336,20 +4336,10 @@ void tst_QAccessibility::messageBoxTest()
|
||||
if (!boxPrivate->canBeNativeDialog()) {
|
||||
// platforms that use a native message box will not emit accessibility events
|
||||
box.show();
|
||||
QVERIFY(QTest::qWaitForWindowActive(&box));
|
||||
|
||||
QAccessibleEvent showEvent(&box, QAccessible::DialogStart);
|
||||
QVERIFY(QTestAccessibility::containsEvent(&showEvent));
|
||||
|
||||
// on some platforms, like macOS, not all widgets get key board focus; we
|
||||
// only care about a push button getting focus
|
||||
if (QTest::qWaitFor([&box]{ return qobject_cast<QPushButton *>(box.focusWidget()); }, 1000)) {
|
||||
// a widget that gets focus through window activation should not emit an accessibility
|
||||
// notification
|
||||
QAccessibleEvent focusEvent(box.focusWidget(), QAccessible::Focus);
|
||||
QVERIFY(!QTestAccessibility::containsEvent(&focusEvent));
|
||||
}
|
||||
|
||||
box.hide();
|
||||
|
||||
QAccessibleEvent hideEvent(&box, QAccessible::DialogEnd);
|
||||
|
Loading…
x
Reference in New Issue
Block a user