summaryrefslogtreecommitdiffstats
path: root/src/platformsupport/linuxaccessibility/atspiadaptor.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/platformsupport/linuxaccessibility/atspiadaptor.cpp')
-rw-r--r--src/platformsupport/linuxaccessibility/atspiadaptor.cpp61
1 files changed, 41 insertions, 20 deletions
diff --git a/src/platformsupport/linuxaccessibility/atspiadaptor.cpp b/src/platformsupport/linuxaccessibility/atspiadaptor.cpp
index 1eda1dfab9..0db8e31537 100644
--- a/src/platformsupport/linuxaccessibility/atspiadaptor.cpp
+++ b/src/platformsupport/linuxaccessibility/atspiadaptor.cpp
@@ -99,6 +99,7 @@ AtSpiAdaptor::AtSpiAdaptor(DBusConnection *connection, QObject *parent)
, sendObject_row_inserted(0)
, sendObject_row_reordered(0)
, sendObject_selection_changed(0)
+ , sendObject_state_changed(0)
, sendObject_text_attributes_changed(0)
, sendObject_text_bounds_changed(0)
, sendObject_text_caret_moved(0)
@@ -903,6 +904,14 @@ QAIPointer AtSpiAdaptor::interfaceFromPath(const QString& dbusPath) const
return QAIPointer();
}
+void AtSpiAdaptor::notifyStateChange(const QAIPointer &interface, const QString &state, int value)
+{
+ QString path = pathForInterface(interface);
+ QVariantList stateArgs = packDBusSignalArguments(state, value, 0, variantForPath(path));
+ sendDBusSignal(path, QLatin1String(ATSPI_DBUS_INTERFACE_EVENT_OBJECT),
+ QLatin1String("StateChanged"), stateArgs);
+}
+
/*!
This function gets called when Qt notifies about accessibility updates.
@@ -919,19 +928,13 @@ void AtSpiAdaptor::notify(QAccessibleEvent *event)
break;
case QAccessible::ObjectShow: {
if (sendObject || sendObject_state_changed) {
- QString path = pathForInterface(QAIPointer(event->accessibleInterface()));
- QVariantList stateArgs = packDBusSignalArguments(QLatin1String("showing"), 1, 0, variantForPath(path));
- sendDBusSignal(path, QLatin1String(ATSPI_DBUS_INTERFACE_EVENT_OBJECT),
- QLatin1String("StateChanged"), stateArgs);
+ notifyStateChange(QAIPointer(event->accessibleInterface()), QLatin1String("showing"), 1);
}
break;
}
case QAccessible::ObjectHide: {
if (sendObject || sendObject_state_changed) {
- QString path = pathForInterface(QAIPointer(event->accessibleInterface()));
- QVariantList stateArgs = packDBusSignalArguments(QLatin1String("showing"), 0, 0, variantForPath(path));
- sendDBusSignal(path, QLatin1String(ATSPI_DBUS_INTERFACE_EVENT_OBJECT),
- QLatin1String("StateChanged"), stateArgs);
+ notifyStateChange(QAIPointer(event->accessibleInterface()), QLatin1String("showing"), 0);
}
break;
}
@@ -968,7 +971,10 @@ void AtSpiAdaptor::notify(QAccessibleEvent *event)
case QAccessible::TextUpdated: {
if (sendObject || sendObject_text_changed) {
QAIPointer iface = QAIPointer(event->accessibleInterface());
- Q_ASSERT(iface->textInterface());
+ if (!iface || !iface->textInterface()) {
+ qAtspiDebug() << "Received text event for invalid interface.";
+ return;
+ }
QString path = pathForInterface(iface);
int changePosition = 0;
@@ -1023,8 +1029,8 @@ void AtSpiAdaptor::notify(QAccessibleEvent *event)
case QAccessible::TextCaretMoved: {
if (sendObject || sendObject_text_caret_moved) {
QAIPointer iface = QAIPointer(event->accessibleInterface());
- if (!iface->textInterface()) {
- qWarning() << "Sending TextCaretMoved from object that does not implement text interface: " << iface << iface->object();
+ if (!iface || !iface->textInterface()) {
+ qWarning() << "Sending TextCaretMoved from object that does not implement text interface: " << iface;
return;
}
@@ -1051,7 +1057,11 @@ void AtSpiAdaptor::notify(QAccessibleEvent *event)
case QAccessible::ValueChanged: {
if (sendObject || sendObject_value_changed || sendObject_property_change_accessible_value) {
QAIPointer iface = QAIPointer(event->accessibleInterface());
- Q_ASSERT(iface->valueInterface());
+ if (!iface || !iface->valueInterface()) {
+ qWarning() << "ValueChanged event from invalid accessible: " << iface;
+ return;
+ }
+
QString path = pathForInterface(iface);
QVariantList args = packDBusSignalArguments(QLatin1String("accessible-value"), 0, 0, variantForPath(path));
sendDBusSignal(path, QLatin1String(ATSPI_DBUS_INTERFACE_EVENT_OBJECT),
@@ -1061,6 +1071,10 @@ void AtSpiAdaptor::notify(QAccessibleEvent *event)
}
case QAccessible::Selection: {
QAIPointer iface = QAIPointer(event->accessibleInterface());
+ if (!iface) {
+ qWarning() << "Selection event from invalid accessible.";
+ return;
+ }
QString path = pathForInterface(iface);
int selected = iface->state().selected ? 1 : 0;
QVariantList stateArgs = packDBusSignalArguments(QLatin1String("selected"), selected, 0, variantForPath(path));
@@ -1074,14 +1088,15 @@ void AtSpiAdaptor::notify(QAccessibleEvent *event)
QAccessible::State stateChange = static_cast<QAccessibleStateChangeEvent*>(event)->changedStates();
if (stateChange.checked) {
QAIPointer iface = QAIPointer(event->accessibleInterface());
+ if (!iface) {
+ qWarning() << "StateChanged event from invalid accessible.";
+ return;
+ }
int checked = iface->state().checked;
- QString path = pathForInterface(iface);
- QVariantList args = packDBusSignalArguments(QLatin1String("checked"), checked, 0, variantForPath(path));
- sendDBusSignal(path, QLatin1String(ATSPI_DBUS_INTERFACE_EVENT_OBJECT),
- QLatin1String("StateChanged"), args);
+ notifyStateChange(iface, QLatin1String("checked"), checked);
} else if (stateChange.active) {
QAIPointer iface = QAIPointer(event->accessibleInterface());
- if (!(iface->role() == QAccessible::Window && (sendWindow || sendWindow_activate)))
+ if (!iface || !(iface->role() == QAccessible::Window && (sendWindow || sendWindow_activate)))
return;
QString windowTitle = iface->text(QAccessible::Name);
QDBusVariant data;
@@ -1092,9 +1107,15 @@ void AtSpiAdaptor::notify(QAccessibleEvent *event)
QString path = pathForInterface(iface);
sendDBusSignal(path, QLatin1String(ATSPI_DBUS_INTERFACE_EVENT_WINDOW), status, args);
- QVariantList stateArgs = packDBusSignalArguments(QLatin1String("active"), iface->state().active ? 1 : 0, 0, variantForPath(path));
- sendDBusSignal(path, QLatin1String(ATSPI_DBUS_INTERFACE_EVENT_OBJECT),
- QLatin1String("StateChanged"), stateArgs);
+ int isActive = iface->state().active;
+ notifyStateChange(iface, QLatin1String("active"), isActive);
+ } else if (stateChange.disabled) {
+ QAIPointer iface = QAIPointer(event->accessibleInterface());
+ QAccessible::State state = iface->state();
+ bool enabled = !state.disabled;
+
+ notifyStateChange(iface, QLatin1String("enabled"), enabled);
+ notifyStateChange(iface, QLatin1String("sensitive"), enabled);
}
}
break;