Make sure windows send accessibility activated updates.
Both QWindow and QWidgetWindow should update with the active state signal. Change-Id: I0219f803aa0fb109765f0faa0aedb120c2a439f0 Reviewed-by: Jan-Arve Sæther <jan-arve.saether@nokia.com>
This commit is contained in:
parent
f195a8e2b6
commit
cea1a6bcd5
@ -52,6 +52,7 @@
|
|||||||
|
|
||||||
#include "qwindow_p.h"
|
#include "qwindow_p.h"
|
||||||
#include "qguiapplication_p.h"
|
#include "qguiapplication_p.h"
|
||||||
|
#include "qaccessible.h"
|
||||||
|
|
||||||
#include <private/qevent_p.h>
|
#include <private/qevent_p.h>
|
||||||
|
|
||||||
@ -1427,13 +1428,25 @@ bool QWindow::event(QEvent *ev)
|
|||||||
keyReleaseEvent(static_cast<QKeyEvent *>(ev));
|
keyReleaseEvent(static_cast<QKeyEvent *>(ev));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case QEvent::FocusIn:
|
case QEvent::FocusIn: {
|
||||||
focusInEvent(static_cast<QFocusEvent *>(ev));
|
focusInEvent(static_cast<QFocusEvent *>(ev));
|
||||||
break;
|
#ifndef QT_NO_ACCESSIBILITY
|
||||||
|
QAccessible::State state;
|
||||||
|
state.active = true;
|
||||||
|
QAccessibleStateChangeEvent event(this, state);
|
||||||
|
QAccessible::updateAccessibility(&event);
|
||||||
|
#endif
|
||||||
|
break; }
|
||||||
|
|
||||||
case QEvent::FocusOut:
|
case QEvent::FocusOut: {
|
||||||
focusOutEvent(static_cast<QFocusEvent *>(ev));
|
focusOutEvent(static_cast<QFocusEvent *>(ev));
|
||||||
break;
|
#ifndef QT_NO_ACCESSIBILITY
|
||||||
|
QAccessible::State state;
|
||||||
|
state.active = true;
|
||||||
|
QAccessibleStateChangeEvent event(this, state);
|
||||||
|
QAccessible::updateAccessibility(&event);
|
||||||
|
#endif
|
||||||
|
break; }
|
||||||
|
|
||||||
#ifndef QT_NO_WHEELEVENT
|
#ifndef QT_NO_WHEELEVENT
|
||||||
case QEvent::Wheel:
|
case QEvent::Wheel:
|
||||||
|
@ -557,6 +557,8 @@ QAccessible::State QAccessibleWidget::state() const
|
|||||||
state.movable = true;
|
state.movable = true;
|
||||||
if (w->minimumSize() != w->maximumSize())
|
if (w->minimumSize() != w->maximumSize())
|
||||||
state.sizeable = true;
|
state.sizeable = true;
|
||||||
|
if (w->isActiveWindow())
|
||||||
|
state.active = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
return state;
|
return state;
|
||||||
|
@ -96,8 +96,14 @@ bool QWidgetWindow::event(QEvent *event)
|
|||||||
// these should not be sent to QWidget, the corresponding events
|
// these should not be sent to QWidget, the corresponding events
|
||||||
// are sent by QApplicationPrivate::notifyActiveWindowChange()
|
// are sent by QApplicationPrivate::notifyActiveWindowChange()
|
||||||
case QEvent::FocusIn:
|
case QEvent::FocusIn:
|
||||||
case QEvent::FocusOut:
|
case QEvent::FocusOut: {
|
||||||
return false;
|
#ifndef QT_NO_ACCESSIBILITY
|
||||||
|
QAccessible::State state;
|
||||||
|
state.active = true;
|
||||||
|
QAccessibleStateChangeEvent ev(widget(), state);
|
||||||
|
QAccessible::updateAccessibility(&ev);
|
||||||
|
#endif
|
||||||
|
return false; }
|
||||||
|
|
||||||
case QEvent::FocusAboutToChange:
|
case QEvent::FocusAboutToChange:
|
||||||
if (QApplicationPrivate::focus_widget) {
|
if (QApplicationPrivate::focus_widget) {
|
||||||
|
@ -777,6 +777,7 @@ void tst_QAccessibility::applicationTest()
|
|||||||
|
|
||||||
void tst_QAccessibility::mainWindowTest()
|
void tst_QAccessibility::mainWindowTest()
|
||||||
{
|
{
|
||||||
|
{
|
||||||
QMainWindow *mw = new QMainWindow;
|
QMainWindow *mw = new QMainWindow;
|
||||||
mw->resize(300, 200);
|
mw->resize(300, 200);
|
||||||
mw->show(); // triggers layout
|
mw->show(); // triggers layout
|
||||||
@ -787,12 +788,51 @@ void tst_QAccessibility::mainWindowTest()
|
|||||||
QAccessibleEvent show(mw, QAccessible::ObjectShow);
|
QAccessibleEvent show(mw, QAccessible::ObjectShow);
|
||||||
QVERIFY_EVENT(&show);
|
QVERIFY_EVENT(&show);
|
||||||
|
|
||||||
QAccessibleInterface *interface = QAccessible::queryAccessibleInterface(mw);
|
QAccessibleInterface *iface = QAccessible::queryAccessibleInterface(mw);
|
||||||
QCOMPARE(interface->text(QAccessible::Name), name);
|
QCOMPARE(iface->text(QAccessible::Name), name);
|
||||||
QCOMPARE(interface->role(), QAccessible::Window);
|
QCOMPARE(iface->role(), QAccessible::Window);
|
||||||
delete interface;
|
QVERIFY(iface->state().active);
|
||||||
|
|
||||||
|
QAccessible::State activeState;
|
||||||
|
activeState.active = true;
|
||||||
|
QAccessibleStateChangeEvent active(mw, activeState);
|
||||||
|
QVERIFY_EVENT(&active);
|
||||||
|
|
||||||
|
delete iface;
|
||||||
delete mw;
|
delete mw;
|
||||||
|
}
|
||||||
QTestAccessibility::clearEvents();
|
QTestAccessibility::clearEvents();
|
||||||
|
|
||||||
|
{
|
||||||
|
QWindow window;
|
||||||
|
window.setGeometry(80, 80, 40, 40);
|
||||||
|
window.show();
|
||||||
|
QTRY_VERIFY(QGuiApplication::focusWindow() == &window);
|
||||||
|
|
||||||
|
// We currently don't have an accessible interface for QWindow
|
||||||
|
// the active state is either in the QMainWindow or QQuickView
|
||||||
|
// QAIPtr windowIface(QAccessible::queryAccessibleInterface(&window));
|
||||||
|
// QVERIFY(windowIface->state().active);
|
||||||
|
|
||||||
|
QAccessible::State activeState;
|
||||||
|
activeState.active = true;
|
||||||
|
QAccessibleStateChangeEvent active(&window, activeState);
|
||||||
|
QVERIFY_EVENT(&active);
|
||||||
|
|
||||||
|
QWindow child;
|
||||||
|
child.setParent(&window);
|
||||||
|
child.setGeometry(10, 10, 20, 20);
|
||||||
|
child.show();
|
||||||
|
|
||||||
|
child.requestActivateWindow();
|
||||||
|
QTRY_VERIFY(QGuiApplication::focusWindow() == &child);
|
||||||
|
|
||||||
|
QAccessibleStateChangeEvent deactivate(&window, activeState);
|
||||||
|
QVERIFY_EVENT(&deactivate); // deactivation of parent
|
||||||
|
|
||||||
|
QAccessibleStateChangeEvent activeChild(&child, activeState);
|
||||||
|
QVERIFY_EVENT(&activeChild);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class CounterButton : public QPushButton {
|
class CounterButton : public QPushButton {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user