7#include <QtGui/qwindow.h>
8#include <QtGui/qguiapplication.h>
9#include <qdbusmessage.h>
10#include <qdbusreply.h>
11#include <qclipboard.h>
13#include <QtCore/qloggingcategory.h>
14#include <QtCore/qtversion.h>
16#if QT_CONFIG(accessibility)
17#include "socket_interface.h"
18#include "qspi_constant_mappings_p.h"
19#include <QtCore/private/qstringiterator_p.h>
20#include <QtGui/private/qaccessiblebridgeutils_p.h>
22#include "qspiapplicationadaptor_p.h"
24
25
26
27
28
29
30
31
34#if ATSPI_COORD_TYPE_COUNT < 3
35#define ATSPI_COORD_TYPE_PARENT 2
40#if !defined(ATSPI_MAJOR_VERSION) || !defined(ATSPI_MINOR_VERSION) || ATSPI_MAJOR_VERSION < 2
|| ATSPI_MINOR_VERSION < 50
41#define ATSPI_LIVE_POLITE 1
42#define ATSPI_LIVE_ASSERTIVE 2
47using namespace Qt::StringLiterals;
48using namespace QtGuiPrivate;
50Q_STATIC_LOGGING_CATEGORY(lcAccessibilityAtspi,
"qt.accessibility.atspi")
51Q_STATIC_LOGGING_CATEGORY(lcAccessibilityAtspiCreation,
"qt.accessibility.atspi.creation")
53AtSpiAdaptor::AtSpiAdaptor(QAtSpiDBusConnection *connection, QObject *parent)
54 : QDBusVirtualObject(parent), m_dbus(connection)
57 , sendObject_active_descendant_changed(0)
58 , sendObject_announcement(0)
59 , sendObject_attributes_changed(0)
60 , sendObject_bounds_changed(0)
61 , sendObject_children_changed(0)
64 , sendObject_column_deleted(0)
65 , sendObject_column_inserted(0)
66 , sendObject_column_reordered(0)
67 , sendObject_link_selected(0)
68 , sendObject_model_changed(0)
69 , sendObject_property_change(0)
70 , sendObject_property_change_accessible_description(0)
71 , sendObject_property_change_accessible_name(0)
72 , sendObject_property_change_accessible_parent(0)
73 , sendObject_property_change_accessible_role(0)
74 , sendObject_property_change_accessible_table_caption(0)
75 , sendObject_property_change_accessible_table_column_description(0)
76 , sendObject_property_change_accessible_table_column_header(0)
77 , sendObject_property_change_accessible_table_row_description(0)
78 , sendObject_property_change_accessible_table_row_header(0)
79 , sendObject_property_change_accessible_table_summary(0)
80 , sendObject_property_change_accessible_value(0)
81 , sendObject_row_deleted(0)
82 , sendObject_row_inserted(0)
83 , sendObject_row_reordered(0)
84 , sendObject_selection_changed(0)
85 , sendObject_state_changed(0)
86 , sendObject_text_attributes_changed(0)
87 , sendObject_text_bounds_changed(0)
88 , sendObject_text_caret_moved(0)
89 , sendObject_text_changed(0)
92 , sendObject_text_selection_changed(0)
93 , sendObject_value_changed(0)
94 , sendObject_visible_data_changed(0)
96 , sendWindow_activate(0)
98 , sendWindow_create(0)
99 , sendWindow_deactivate(0)
102 , sendWindow_lower(0)
103 , sendWindow_maximize(0)
104 , sendWindow_minimize(0)
106 , sendWindow_raise(0)
107 , sendWindow_reparent(0)
108 , sendWindow_resize(0)
109 , sendWindow_restore(0)
110 , sendWindow_restyle(0)
111 , sendWindow_shade(0)
112 , sendWindow_unshade(0)
114 m_applicationAdaptor =
new QSpiApplicationAdaptor(m_dbus->connection(),
this);
115 connect(m_applicationAdaptor, SIGNAL(windowActivated(QObject*,
bool)),
this, SLOT(windowActivated(QObject*,
bool)));
117 updateEventListeners();
118 bool success = m_dbus->connection().connect(
"org.a11y.atspi.Registry"_L1,
"/org/a11y/atspi/registry"_L1,
119 "org.a11y.atspi.Registry"_L1,
"EventListenerRegistered"_L1,
this,
120 SLOT(eventListenerRegistered(QString,QString)));
121 success = success && m_dbus->connection().connect(
"org.a11y.atspi.Registry"_L1,
"/org/a11y/atspi/registry"_L1,
122 "org.a11y.atspi.Registry"_L1,
"EventListenerDeregistered"_L1,
this,
123 SLOT(eventListenerDeregistered(QString,QString)));
126AtSpiAdaptor::~AtSpiAdaptor()
131
132
133QString AtSpiAdaptor::introspect(
const QString &path)
const
135 constexpr auto accessibleIntrospection =
136 " <interface name=\"org.a11y.atspi.Accessible\">\n"
137 " <property access=\"read\" type=\"s\" name=\"Name\"/>\n"
138 " <property access=\"read\" type=\"s\" name=\"Description\"/>\n"
139 " <property access=\"read\" type=\"s\" name=\"HelpText\"/>\n"
140 " <property access=\"read\" type=\"(so)\" name=\"Parent\">\n"
141 " <annotation value=\"QSpiObjectReference\" name=\"org.qtproject.QtDBus.QtTypeName\"/>\n"
143 " <property access=\"read\" type=\"i\" name=\"ChildCount\"/>\n"
144 " <method name=\"GetChildAtIndex\">\n"
145 " <arg direction=\"in\" type=\"i\" name=\"index\"/>\n"
146 " <arg direction=\"out\" type=\"(so)\"/>\n"
147 " <annotation value=\"QSpiObjectReference\" name=\"org.qtproject.QtDBus.QtTypeName.Out0\"/>\n"
149 " <method name=\"GetChildren\">\n"
150 " <arg direction=\"out\" type=\"a(so)\"/>\n"
151 " <annotation value=\"QSpiObjectReferenceArray\" name=\"org.qtproject.QtDBus.QtTypeName.Out0\"/>\n"
153 " <method name=\"GetIndexInParent\">\n"
154 " <arg direction=\"out\" type=\"i\"/>\n"
156 " <method name=\"GetRelationSet\">\n"
157 " <arg direction=\"out\" type=\"a(ua(so))\"/>\n"
158 " <annotation value=\"QSpiRelationArray\" name=\"org.qtproject.QtDBus.QtTypeName.Out0\"/>\n"
160 " <method name=\"GetRole\">\n"
161 " <arg direction=\"out\" type=\"u\"/>\n"
163 " <method name=\"GetRoleName\">\n"
164 " <arg direction=\"out\" type=\"s\"/>\n"
166 " <method name=\"GetLocalizedRoleName\">\n"
167 " <arg direction=\"out\" type=\"s\"/>\n"
169 " <method name=\"GetState\">\n"
170 " <arg direction=\"out\" type=\"au\"/>\n"
171 " <annotation value=\"QSpiUIntList\" name=\"org.qtproject.QtDBus.QtTypeName.Out0\"/>\n"
173 " <method name=\"GetAttributes\">\n"
174 " <arg direction=\"out\" type=\"a{ss}\"/>\n"
175 " <annotation value=\"QSpiAttributeSet\" name=\"org.qtproject.QtDBus.QtTypeName.Out0\"/>\n"
177 " <method name=\"GetApplication\">\n"
178 " <arg direction=\"out\" type=\"(so)\"/>\n"
179 " <annotation value=\"QSpiObjectReference\" name=\"org.qtproject.QtDBus.QtTypeName.Out0\"/>\n"
181 " <method name=\"GetAccessibleId\">\n"
182 " <arg direction=\"out\" type=\"s\"/>\n"
187 constexpr auto actionIntrospection =
188 " <interface name=\"org.a11y.atspi.Action\">\n"
189 " <property access=\"read\" type=\"i\" name=\"NActions\"/>\n"
190 " <method name=\"GetDescription\">\n"
191 " <arg direction=\"in\" type=\"i\" name=\"index\"/>\n"
192 " <arg direction=\"out\" type=\"s\"/>\n"
194 " <method name=\"GetName\">\n"
195 " <arg direction=\"in\" type=\"i\" name=\"index\"/>\n"
196 " <arg direction=\"out\" type=\"s\"/>\n"
198 " <method name=\"GetKeyBinding\">\n"
199 " <arg direction=\"in\" type=\"i\" name=\"index\"/>\n"
200 " <arg direction=\"out\" type=\"s\"/>\n"
202 " <method name=\"GetActions\">\n"
203 " <arg direction=\"out\" type=\"a(sss)\" name=\"index\"/>\n"
204 " <annotation value=\"QSpiActionArray\" name=\"org.qtproject.QtDBus.QtTypeName.Out0\"/>\n"
206 " <method name=\"DoAction\">\n"
207 " <arg direction=\"in\" type=\"i\" name=\"index\"/>\n"
208 " <arg direction=\"out\" type=\"b\"/>\n"
213 constexpr auto applicationIntrospection =
214 " <interface name=\"org.a11y.atspi.Application\">\n"
215 " <property access=\"read\" type=\"s\" name=\"ToolkitName\"/>\n"
216 " <property access=\"read\" type=\"s\" name=\"Version\"/>\n"
217 " <property access=\"readwrite\" type=\"i\" name=\"Id\"/>\n"
218 " <method name=\"GetLocale\">\n"
219 " <arg direction=\"in\" type=\"u\" name=\"lctype\"/>\n"
220 " <arg direction=\"out\" type=\"s\"/>\n"
222 " <method name=\"GetApplicationBusAddress\">\n"
223 " <arg direction=\"out\" type=\"s\" name=\"address\"/>\n"
228 constexpr auto collectionIntrospection =
229 " <interface name=\"org.a11y.atspi.Collection\">\n"
230 " <method name=\"GetMatches\">\n"
231 " <arg direction=\"in\" name=\"rule\" type=\"(aiia{ss}iaiiasib)\"/>\n"
232 " <annotation name=\"org.qtproject.QtDBus.QtTypeName.In0\" value=\"QSpiMatchRule\"/>\n"
233 " <arg direction=\"in\" name=\"sortby\" type=\"u\"/>\n"
234 " <arg direction=\"in\" name=\"count\" type=\"i\"/>\n"
235 " <arg direction=\"in\" name=\"traverse\" type=\"b\"/>\n"
236 " <arg direction=\"out\" type=\"a(so)\"/>\n"
237 " <annotation name=\"org.qtproject.QtDBus.QtTypeName.Out0\" value=\"QSpiReferenceSet\"/>\n"
239 " <method name=\"GetMatchesTo\">\n"
240 " <arg direction=\"in\" name=\"current_object\" type=\"o\"/>\n"
241 " <annotation name=\"org.qtproject.QtDBus.QtTypeName.In0\" value=\"QSpiObjectReference\"/>\n"
242 " <arg direction=\"in\" name=\"rule\" type=\"(aiia{ss}iaiiasib)\"/>\n"
243 " <annotation name=\"org.qtproject.QtDBus.QtTypeName.In1\" value=\"QSpiMatchRule\"/>\n"
244 " <arg direction=\"in\" name=\"sortby\" type=\"u\"/>\n"
245 " <arg direction=\"in\" name=\"tree\" type=\"u\"/>\n"
246 " <arg direction=\"in\" name=\"limit_scope\" type=\"b\"/>\n"
247 " <arg direction=\"in\" name=\"count\" type=\"i\"/>\n"
248 " <arg direction=\"in\" name=\"traverse\" type=\"b\"/>\n"
249 " <arg direction=\"out\" type=\"a(so)\"/>\n"
250 " <annotation name=\"org.qtproject.QtDBus.QtTypeName.Out0\" value=\"QSpiReferenceSet\"/>\n"
252 " <method name=\"GetMatchesFrom\">\n"
253 " <arg direction=\"in\" name=\"current_object\" type=\"o\"/>\n"
254 " <annotation name=\"org.qtproject.QtDBus.QtTypeName.In0\" value=\"QSpiObjectReference\"/>\n"
255 " <arg direction=\"in\" name=\"rule\" type=\"(aiia{ss}iaiiasib)\"/>\n"
256 " <annotation name=\"org.qtproject.QtDBus.QtTypeName.In1\" value=\"QSpiMatchRule\"/>\n"
257 " <arg direction=\"in\" name=\"sortby\" type=\"u\"/>\n"
258 " <arg direction=\"in\" name=\"tree\" type=\"u\"/>\n"
259 " <arg direction=\"in\" name=\"count\" type=\"i\"/>\n"
260 " <arg direction=\"in\" name=\"traverse\" type=\"b\"/>\n"
261 " <arg direction=\"out\" type=\"a(so)\"/>\n"
262 " <annotation name=\"org.qtproject.QtDBus.QtTypeName.Out0\" value=\"QSpiReferenceSet\"/>\n"
264 " <method name=\"GetActiveDescendant\">\n"
265 " <arg direction=\"out\" type=\"(so)\"/>\n"
266 " <annotation name=\"org.qtproject.QtDBus.QtTypeName.Out0\" value=\"QSpiReferenceSet\"/>\n"
271 constexpr auto componentIntrospection =
272 " <interface name=\"org.a11y.atspi.Component\">\n"
273 " <method name=\"Contains\">\n"
274 " <arg direction=\"in\" type=\"i\" name=\"x\"/>\n"
275 " <arg direction=\"in\" type=\"i\" name=\"y\"/>\n"
276 " <arg direction=\"in\" type=\"u\" name=\"coord_type\"/>\n"
277 " <arg direction=\"out\" type=\"b\"/>\n"
279 " <method name=\"GetAccessibleAtPoint\">\n"
280 " <arg direction=\"in\" type=\"i\" name=\"x\"/>\n"
281 " <arg direction=\"in\" type=\"i\" name=\"y\"/>\n"
282 " <arg direction=\"in\" type=\"u\" name=\"coord_type\"/>\n"
283 " <arg direction=\"out\" type=\"(so)\"/>\n"
284 " <annotation value=\"QSpiObjectReference\" name=\"org.qtproject.QtDBus.QtTypeName.Out0\"/>\n"
286 " <method name=\"GetExtents\">\n"
287 " <arg direction=\"in\" type=\"u\" name=\"coord_type\"/>\n"
288 " <arg direction=\"out\" type=\"(iiii)\"/>\n"
289 " <annotation value=\"QSpiRect\" name=\"org.qtproject.QtDBus.QtTypeName.Out0\"/>\n"
291 " <method name=\"GetPosition\">\n"
292 " <arg direction=\"in\" type=\"u\" name=\"coord_type\"/>\n"
293 " <arg direction=\"out\" type=\"i\" name=\"x\"/>\n"
294 " <arg direction=\"out\" type=\"i\" name=\"y\"/>\n"
296 " <method name=\"GetSize\">\n"
297 " <arg direction=\"out\" type=\"i\" name=\"width\"/>\n"
298 " <arg direction=\"out\" type=\"i\" name=\"height\"/>\n"
300 " <method name=\"GetLayer\">\n"
301 " <arg direction=\"out\" type=\"u\"/>\n"
303 " <method name=\"GetMDIZOrder\">\n"
304 " <arg direction=\"out\" type=\"n\"/>\n"
306 " <method name=\"GrabFocus\">\n"
307 " <arg direction=\"out\" type=\"b\"/>\n"
309 " <method name=\"GetAlpha\">\n"
310 " <arg direction=\"out\" type=\"d\"/>\n"
312 " <method name=\"SetExtents\">\n"
313 " <arg direction=\"in\" type=\"i\" name=\"x\"/>\n"
314 " <arg direction=\"in\" type=\"i\" name=\"y\"/>\n"
315 " <arg direction=\"in\" type=\"i\" name=\"width\"/>\n"
316 " <arg direction=\"in\" type=\"i\" name=\"height\"/>\n"
317 " <arg direction=\"in\" type=\"u\" name=\"coord_type\"/>\n"
318 " <arg direction=\"out\" type=\"b\"/>\n"
320 " <method name=\"SetPosition\">\n"
321 " <arg direction=\"in\" type=\"i\" name=\"x\"/>\n"
322 " <arg direction=\"in\" type=\"i\" name=\"y\"/>\n"
323 " <arg direction=\"in\" type=\"u\" name=\"coord_type\"/>\n"
324 " <arg direction=\"out\" type=\"b\"/>\n"
326 " <method name=\"SetSize\">\n"
327 " <arg direction=\"in\" type=\"i\" name=\"width\"/>\n"
328 " <arg direction=\"in\" type=\"i\" name=\"height\"/>\n"
329 " <arg direction=\"out\" type=\"b\"/>\n"
334 constexpr auto editableTextIntrospection =
335 " <interface name=\"org.a11y.atspi.EditableText\">\n"
336 " <method name=\"SetTextContents\">\n"
337 " <arg direction=\"in\" type=\"s\" name=\"newContents\"/>\n"
338 " <arg direction=\"out\" type=\"b\"/>\n"
340 " <method name=\"InsertText\">\n"
341 " <arg direction=\"in\" type=\"i\" name=\"position\"/>\n"
342 " <arg direction=\"in\" type=\"s\" name=\"text\"/>\n"
343 " <arg direction=\"in\" type=\"i\" name=\"length\"/>\n"
344 " <arg direction=\"out\" type=\"b\"/>\n"
346 " <method name=\"CopyText\">\n"
347 " <arg direction=\"in\" type=\"i\" name=\"startPos\"/>\n"
348 " <arg direction=\"in\" type=\"i\" name=\"endPos\"/>\n"
350 " <method name=\"CutText\">\n"
351 " <arg direction=\"in\" type=\"i\" name=\"startPos\"/>\n"
352 " <arg direction=\"in\" type=\"i\" name=\"endPos\"/>\n"
353 " <arg direction=\"out\" type=\"b\"/>\n"
355 " <method name=\"DeleteText\">\n"
356 " <arg direction=\"in\" type=\"i\" name=\"startPos\"/>\n"
357 " <arg direction=\"in\" type=\"i\" name=\"endPos\"/>\n"
358 " <arg direction=\"out\" type=\"b\"/>\n"
360 " <method name=\"PasteText\">\n"
361 " <arg direction=\"in\" type=\"i\" name=\"position\"/>\n"
362 " <arg direction=\"out\" type=\"b\"/>\n"
367 constexpr auto selectionIntrospection =
368 " <interface name=\"org.a11y.atspi.Selection\">\n"
369 " <property name=\"NSelectedChildren\" type=\"i\" access=\"read\"/>\n"
370 " <method name=\"GetSelectedChild\">\n"
371 " <arg direction=\"in\" name=\"selectedChildIndex\" type=\"i\"/>\n"
372 " <arg direction=\"out\" type=\"(so)\"/>\n"
373 " <annotation name=\"org.qtproject.QtDBus.QtTypeName.Out0\" value=\"QSpiObjectReference\"/>\n"
375 " <method name=\"SelectChild\">\n"
376 " <arg direction=\"in\" name=\"childIndex\" type=\"i\"/>\n"
377 " <arg direction=\"out\" type=\"b\"/>\n"
379 " <method name=\"DeselectSelectedChild\">\n"
380 " <arg direction=\"in\" name=\"selectedChildIndex\" type=\"i\"/>\n"
381 " <arg direction=\"out\" type=\"b\"/>\n"
383 " <method name=\"IsChildSelected\">\n"
384 " <arg direction=\"in\" name=\"childIndex\" type=\"i\"/>\n"
385 " <arg direction=\"out\" type=\"b\"/>\n"
387 " <method name=\"SelectAll\">\n"
388 " <arg direction=\"out\" type=\"b\"/>\n"
390 " <method name=\"ClearSelection\">\n"
391 " <arg direction=\"out\" type=\"b\"/>\n"
393 " <method name=\"DeselectChild\">\n"
394 " <arg direction=\"in\" name=\"childIndex\" type=\"i\"/>\n"
395 " <arg direction=\"out\" type=\"b\"/>\n"
400 constexpr auto tableIntrospection =
401 " <interface name=\"org.a11y.atspi.Table\">\n"
402 " <property access=\"read\" type=\"i\" name=\"NRows\"/>\n"
403 " <property access=\"read\" type=\"i\" name=\"NColumns\"/>\n"
404 " <property access=\"read\" type=\"(so)\" name=\"Caption\">\n"
405 " <annotation value=\"QSpiObjectReference\" name=\"org.qtproject.QtDBus.QtTypeName\"/>\n"
407 " <property access=\"read\" type=\"(so)\" name=\"Summary\">\n"
408 " <annotation value=\"QSpiObjectReference\" name=\"org.qtproject.QtDBus.QtTypeName\"/>\n"
410 " <property access=\"read\" type=\"i\" name=\"NSelectedRows\"/>\n"
411 " <property access=\"read\" type=\"i\" name=\"NSelectedColumns\"/>\n"
412 " <method name=\"GetAccessibleAt\">\n"
413 " <arg direction=\"in\" type=\"i\" name=\"row\"/>\n"
414 " <arg direction=\"in\" type=\"i\" name=\"column\"/>\n"
415 " <arg direction=\"out\" type=\"(so)\"/>\n"
416 " <annotation value=\"QSpiObjectReference\" name=\"org.qtproject.QtDBus.QtTypeName.Out0\"/>\n"
418 " <method name=\"GetIndexAt\">\n"
419 " <arg direction=\"in\" type=\"i\" name=\"row\"/>\n"
420 " <arg direction=\"in\" type=\"i\" name=\"column\"/>\n"
421 " <arg direction=\"out\" type=\"i\"/>\n"
423 " <method name=\"GetRowAtIndex\">\n"
424 " <arg direction=\"in\" type=\"i\" name=\"index\"/>\n"
425 " <arg direction=\"out\" type=\"i\"/>\n"
427 " <method name=\"GetColumnAtIndex\">\n"
428 " <arg direction=\"in\" type=\"i\" name=\"index\"/>\n"
429 " <arg direction=\"out\" type=\"i\"/>\n"
431 " <method name=\"GetRowDescription\">\n"
432 " <arg direction=\"in\" type=\"i\" name=\"row\"/>\n"
433 " <arg direction=\"out\" type=\"s\"/>\n"
435 " <method name=\"GetColumnDescription\">\n"
436 " <arg direction=\"in\" type=\"i\" name=\"column\"/>\n"
437 " <arg direction=\"out\" type=\"s\"/>\n"
439 " <method name=\"GetRowExtentAt\">\n"
440 " <arg direction=\"in\" type=\"i\" name=\"row\"/>\n"
441 " <arg direction=\"in\" type=\"i\" name=\"column\"/>\n"
442 " <arg direction=\"out\" type=\"i\"/>\n"
444 " <method name=\"GetColumnExtentAt\">\n"
445 " <arg direction=\"in\" type=\"i\" name=\"row\"/>\n"
446 " <arg direction=\"in\" type=\"i\" name=\"column\"/>\n"
447 " <arg direction=\"out\" type=\"i\"/>\n"
449 " <method name=\"GetRowHeader\">\n"
450 " <arg direction=\"in\" type=\"i\" name=\"row\"/>\n"
451 " <arg direction=\"out\" type=\"(so)\"/>\n"
452 " <annotation value=\"QSpiObjectReference\" name=\"org.qtproject.QtDBus.QtTypeName.Out0\"/>\n"
454 " <method name=\"GetColumnHeader\">\n"
455 " <arg direction=\"in\" type=\"i\" name=\"column\"/>\n"
456 " <arg direction=\"out\" type=\"(so)\"/>\n"
457 " <annotation value=\"QSpiObjectReference\" name=\"org.qtproject.QtDBus.QtTypeName.Out0\"/>\n"
459 " <method name=\"GetSelectedRows\">\n"
460 " <arg direction=\"out\" type=\"ai\"/>\n"
461 " <annotation value=\"QSpiIntList\" name=\"org.qtproject.QtDBus.QtTypeName.Out0\"/>\n"
463 " <method name=\"GetSelectedColumns\">\n"
464 " <arg direction=\"out\" type=\"ai\"/>\n"
465 " <annotation value=\"QSpiIntList\" name=\"org.qtproject.QtDBus.QtTypeName.Out0\"/>\n"
467 " <method name=\"IsRowSelected\">\n"
468 " <arg direction=\"in\" type=\"i\" name=\"row\"/>\n"
469 " <arg direction=\"out\" type=\"b\"/>\n"
471 " <method name=\"IsColumnSelected\">\n"
472 " <arg direction=\"in\" type=\"i\" name=\"column\"/>\n"
473 " <arg direction=\"out\" type=\"b\"/>\n"
475 " <method name=\"IsSelected\">\n"
476 " <arg direction=\"in\" type=\"i\" name=\"row\"/>\n"
477 " <arg direction=\"in\" type=\"i\" name=\"column\"/>\n"
478 " <arg direction=\"out\" type=\"b\"/>\n"
480 " <method name=\"AddRowSelection\">\n"
481 " <arg direction=\"in\" type=\"i\" name=\"row\"/>\n"
482 " <arg direction=\"out\" type=\"b\"/>\n"
484 " <method name=\"AddColumnSelection\">\n"
485 " <arg direction=\"in\" type=\"i\" name=\"column\"/>\n"
486 " <arg direction=\"out\" type=\"b\"/>\n"
488 " <method name=\"RemoveRowSelection\">\n"
489 " <arg direction=\"in\" type=\"i\" name=\"row\"/>\n"
490 " <arg direction=\"out\" type=\"b\"/>\n"
492 " <method name=\"RemoveColumnSelection\">\n"
493 " <arg direction=\"in\" type=\"i\" name=\"column\"/>\n"
494 " <arg direction=\"out\" type=\"b\"/>\n"
496 " <method name=\"GetRowColumnExtentsAtIndex\">\n"
497 " <arg direction=\"in\" type=\"i\" name=\"index\"/>\n"
498 " <arg direction=\"out\" type=\"b\"/>\n"
499 " <arg direction=\"out\" type=\"i\" name=\"row\"/>\n"
500 " <arg direction=\"out\" type=\"i\" name=\"col\"/>\n"
501 " <arg direction=\"out\" type=\"i\" name=\"row_extents\"/>\n"
502 " <arg direction=\"out\" type=\"i\" name=\"col_extents\"/>\n"
503 " <arg direction=\"out\" type=\"b\" name=\"is_selected\"/>\n"
508 constexpr auto tableCellIntrospection =
509 " <interface name=\"org.a11y.atspi.TableCell\">\n"
510 " <property access=\"read\" name=\"ColumnSpan\" type=\"i\" />\n"
511 " <property access=\"read\" name=\"Position\" type=\"(ii)\">\n"
512 " <annotation name=\"org.qtproject.QtDBus.QtTypeName\" value=\"QPoint\"/>\n"
514 " <property access=\"read\" name=\"RowSpan\" type=\"i\" />\n"
515 " <property access=\"read\" name=\"Table\" type=\"(so)\" >\n"
516 " <annotation name=\"org.qtproject.QtDBus.QtTypeName\" value=\"QSpiObjectReference\"/>\n"
518 " <method name=\"GetRowColumnSpan\">\n"
519 " <arg direction=\"out\" type=\"b\" />\n"
520 " <arg direction=\"out\" name=\"row\" type=\"i\" />\n"
521 " <arg direction=\"out\" name=\"col\" type=\"i\" />\n"
522 " <arg direction=\"out\" name=\"row_extents\" type=\"i\" />\n"
523 " <arg direction=\"out\" name=\"col_extents\" type=\"i\" />\n"
525 " <method name=\"GetColumnHeaderCells\">\n"
526 " <arg direction=\"out\" type=\"a(so)\"/>\n"
527 " <annotation value=\"QSpiObjectReferenceArray\" name=\"org.qtproject.QtDBus.QtTypeName.Out0\"/>\n"
529 " <method name=\"GetRowHeaderCells\">\n"
530 " <arg direction=\"out\" type=\"a(so)\"/>\n"
531 " <annotation value=\"QSpiObjectReferenceArray\" name=\"org.qtproject.QtDBus.QtTypeName.Out0\"/>\n"
536 constexpr auto textIntrospection =
537 " <interface name=\"org.a11y.atspi.Text\">\n"
538 " <property access=\"read\" type=\"i\" name=\"CharacterCount\"/>\n"
539 " <property access=\"read\" type=\"i\" name=\"CaretOffset\"/>\n"
540 " <method name=\"GetStringAtOffset\">\n"
541 " <arg direction=\"in\" name=\"offset\" type=\"i\"/>\n"
542 " <arg direction=\"in\" name=\"granularity\" type=\"u\"/>\n"
543 " <arg direction=\"out\" type=\"s\"/>\n"
544 " <arg direction=\"out\" name=\"startOffset\" type=\"i\"/>\n"
545 " <arg direction=\"out\" name=\"endOffset\" type=\"i\"/>\n"
547 " <method name=\"GetText\">\n"
548 " <arg direction=\"in\" type=\"i\" name=\"startOffset\"/>\n"
549 " <arg direction=\"in\" type=\"i\" name=\"endOffset\"/>\n"
550 " <arg direction=\"out\" type=\"s\"/>\n"
552 " <method name=\"SetCaretOffset\">\n"
553 " <arg direction=\"in\" type=\"i\" name=\"offset\"/>\n"
554 " <arg direction=\"out\" type=\"b\"/>\n"
556 " <method name=\"GetTextBeforeOffset\">\n"
557 " <arg direction=\"in\" type=\"i\" name=\"offset\"/>\n"
558 " <arg direction=\"in\" type=\"u\" name=\"type\"/>\n"
559 " <arg direction=\"out\" type=\"s\"/>\n"
560 " <arg direction=\"out\" type=\"i\" name=\"startOffset\"/>\n"
561 " <arg direction=\"out\" type=\"i\" name=\"endOffset\"/>\n"
563 " <method name=\"GetTextAtOffset\">\n"
564 " <arg direction=\"in\" type=\"i\" name=\"offset\"/>\n"
565 " <arg direction=\"in\" type=\"u\" name=\"type\"/>\n"
566 " <arg direction=\"out\" type=\"s\"/>\n"
567 " <arg direction=\"out\" type=\"i\" name=\"startOffset\"/>\n"
568 " <arg direction=\"out\" type=\"i\" name=\"endOffset\"/>\n"
570 " <method name=\"GetTextAfterOffset\">\n"
571 " <arg direction=\"in\" type=\"i\" name=\"offset\"/>\n"
572 " <arg direction=\"in\" type=\"u\" name=\"type\"/>\n"
573 " <arg direction=\"out\" type=\"s\"/>\n"
574 " <arg direction=\"out\" type=\"i\" name=\"startOffset\"/>\n"
575 " <arg direction=\"out\" type=\"i\" name=\"endOffset\"/>\n"
577 " <method name=\"GetCharacterAtOffset\">\n"
578 " <arg direction=\"in\" type=\"i\" name=\"offset\"/>\n"
579 " <arg direction=\"out\" type=\"i\"/>\n"
581 " <method name=\"GetAttributeValue\">\n"
582 " <arg direction=\"in\" type=\"i\" name=\"offset\"/>\n"
583 " <arg direction=\"in\" type=\"s\" name=\"attributeName\"/>\n"
584 " <arg direction=\"out\" type=\"s\"/>\n"
586 " <method name=\"GetAttributes\">\n"
587 " <arg direction=\"in\" type=\"i\" name=\"offset\"/>\n"
588 " <arg direction=\"out\" type=\"a{ss}\"/>\n"
589 " <arg direction=\"out\" type=\"i\" name=\"startOffset\"/>\n"
590 " <arg direction=\"out\" type=\"i\" name=\"endOffset\"/>\n"
591 " <annotation value=\"QSpiAttributeSet\" name=\"org.qtproject.QtDBus.QtTypeName.Out0\"/>\n"
593 " <method name=\"GetDefaultAttributes\">\n"
594 " <arg direction=\"out\" type=\"a{ss}\"/>\n"
595 " <annotation value=\"QSpiAttributeSet\" name=\"org.qtproject.QtDBus.QtTypeName.Out0\"/>\n"
597 " <method name=\"GetCharacterExtents\">\n"
598 " <arg direction=\"in\" type=\"i\" name=\"offset\"/>\n"
599 " <arg direction=\"out\" type=\"i\" name=\"x\"/>\n"
600 " <arg direction=\"out\" type=\"i\" name=\"y\"/>\n"
601 " <arg direction=\"out\" type=\"i\" name=\"width\"/>\n"
602 " <arg direction=\"out\" type=\"i\" name=\"height\"/>\n"
603 " <arg direction=\"in\" type=\"u\" name=\"coordType\"/>\n"
605 " <method name=\"GetOffsetAtPoint\">\n"
606 " <arg direction=\"in\" type=\"i\" name=\"x\"/>\n"
607 " <arg direction=\"in\" type=\"i\" name=\"y\"/>\n"
608 " <arg direction=\"in\" type=\"u\" name=\"coordType\"/>\n"
609 " <arg direction=\"out\" type=\"i\"/>\n"
611 " <method name=\"GetNSelections\">\n"
612 " <arg direction=\"out\" type=\"i\"/>\n"
614 " <method name=\"GetSelection\">\n"
615 " <arg direction=\"in\" type=\"i\" name=\"selectionNum\"/>\n"
616 " <arg direction=\"out\" type=\"i\" name=\"startOffset\"/>\n"
617 " <arg direction=\"out\" type=\"i\" name=\"endOffset\"/>\n"
619 " <method name=\"AddSelection\">\n"
620 " <arg direction=\"in\" type=\"i\" name=\"startOffset\"/>\n"
621 " <arg direction=\"in\" type=\"i\" name=\"endOffset\"/>\n"
622 " <arg direction=\"out\" type=\"b\"/>\n"
624 " <method name=\"RemoveSelection\">\n"
625 " <arg direction=\"in\" type=\"i\" name=\"selectionNum\"/>\n"
626 " <arg direction=\"out\" type=\"b\"/>\n"
628 " <method name=\"SetSelection\">\n"
629 " <arg direction=\"in\" type=\"i\" name=\"selectionNum\"/>\n"
630 " <arg direction=\"in\" type=\"i\" name=\"startOffset\"/>\n"
631 " <arg direction=\"in\" type=\"i\" name=\"endOffset\"/>\n"
632 " <arg direction=\"out\" type=\"b\"/>\n"
634 " <method name=\"GetRangeExtents\">\n"
635 " <arg direction=\"in\" type=\"i\" name=\"startOffset\"/>\n"
636 " <arg direction=\"in\" type=\"i\" name=\"endOffset\"/>\n"
637 " <arg direction=\"out\" type=\"i\" name=\"x\"/>\n"
638 " <arg direction=\"out\" type=\"i\" name=\"y\"/>\n"
639 " <arg direction=\"out\" type=\"i\" name=\"width\"/>\n"
640 " <arg direction=\"out\" type=\"i\" name=\"height\"/>\n"
641 " <arg direction=\"in\" type=\"u\" name=\"coordType\"/>\n"
643 " <method name=\"GetBoundedRanges\">\n"
644 " <arg direction=\"in\" type=\"i\" name=\"x\"/>\n"
645 " <arg direction=\"in\" type=\"i\" name=\"y\"/>\n"
646 " <arg direction=\"in\" type=\"i\" name=\"width\"/>\n"
647 " <arg direction=\"in\" type=\"i\" name=\"height\"/>\n"
648 " <arg direction=\"in\" type=\"u\" name=\"coordType\"/>\n"
649 " <arg direction=\"in\" type=\"u\" name=\"xClipType\"/>\n"
650 " <arg direction=\"in\" type=\"u\" name=\"yClipType\"/>\n"
651 " <arg direction=\"out\" type=\"a(iisv)\"/>\n"
652 " <annotation value=\"QSpiRangeList\" name=\"org.qtproject.QtDBus.QtTypeName.Out0\"/>\n"
654 " <method name=\"GetAttributeRun\">\n"
655 " <arg direction=\"in\" type=\"i\" name=\"offset\"/>\n"
656 " <arg direction=\"in\" type=\"b\" name=\"includeDefaults\"/>\n"
657 " <arg direction=\"out\" type=\"a{ss}\"/>\n"
658 " <arg direction=\"out\" type=\"i\" name=\"startOffset\"/>\n"
659 " <arg direction=\"out\" type=\"i\" name=\"endOffset\"/>\n"
660 " <annotation value=\"QSpiAttributeSet\" name=\"org.qtproject.QtDBus.QtTypeName.Out0\"/>\n"
662 " <method name=\"GetDefaultAttributeSet\">\n"
663 " <arg direction=\"out\" type=\"a{ss}\"/>\n"
664 " <annotation value=\"QSpiAttributeSet\" name=\"org.qtproject.QtDBus.QtTypeName.Out0\"/>\n"
666 " <method name=\"ScrollSubstringTo\">\n"
667 " <arg direction=\"in\" name=\"startOffset\" type=\"i\"/>\n"
668 " <arg direction=\"in\" name=\"endOffset\" type=\"i\"/>\n"
669 " <arg direction=\"in\" name=\"type\" type=\"u\"/>\n"
670 " <arg direction=\"out\" type=\"b\"/>\n"
675 constexpr auto valueIntrospection =
676 " <interface name=\"org.a11y.atspi.Value\">\n"
677 " <property access=\"read\" type=\"d\" name=\"MinimumValue\"/>\n"
678 " <property access=\"read\" type=\"d\" name=\"MaximumValue\"/>\n"
679 " <property access=\"read\" type=\"d\" name=\"MinimumIncrement\"/>\n"
680 " <property access=\"readwrite\" type=\"d\" name=\"CurrentValue\"/>\n"
681 " <method name=\"SetCurrentValue\">\n"
682 " <arg direction=\"in\" type=\"d\" name=\"value\"/>\n"
687 QAccessibleInterface * interface = interfaceFromPath(path);
689 qCWarning(lcAccessibilityAtspi) <<
"Could not find accessible on path:" << path;
693 QStringList interfaces = accessibleInterfaces(interface);
696 xml.append(accessibleIntrospection);
697 xml.append(collectionIntrospection);
699 if (interfaces.contains(ATSPI_DBUS_INTERFACE_COMPONENT
""_L1))
700 xml.append(componentIntrospection);
701 if (interfaces.contains(ATSPI_DBUS_INTERFACE_TEXT
""_L1))
702 xml.append(textIntrospection);
703 if (interfaces.contains(ATSPI_DBUS_INTERFACE_EDITABLE_TEXT
""_L1))
704 xml.append(editableTextIntrospection);
705 if (interfaces.contains(ATSPI_DBUS_INTERFACE_ACTION
""_L1))
706 xml.append(actionIntrospection);
707 if (interfaces.contains(ATSPI_DBUS_INTERFACE_SELECTION
""_L1))
708 xml.append(selectionIntrospection);
709 if (interfaces.contains(ATSPI_DBUS_INTERFACE_TABLE
""_L1))
710 xml.append(tableIntrospection);
711 if (interfaces.contains(ATSPI_DBUS_INTERFACE_TABLE_CELL
""_L1))
712 xml.append(tableCellIntrospection);
713 if (interfaces.contains(ATSPI_DBUS_INTERFACE_VALUE
""_L1))
714 xml.append(valueIntrospection);
715 if (path == ATSPI_DBUS_PATH_ROOT
""_L1)
716 xml.append(applicationIntrospection);
721void AtSpiAdaptor::setBitFlag(
const QString &flag)
723 Q_ASSERT(flag.size());
726 switch (flag.at(0).toLower().toLatin1()) {
728 if (flag.size() <= 8) {
731 QString right = flag.mid(7);
733 }
else if (right.startsWith(
"ActiveDescendantChanged"_L1)) {
734 sendObject_active_descendant_changed = 1;
735 }
else if (right.startsWith(
"Announcement"_L1)) {
736 sendObject_announcement = 1;
737 }
else if (right.startsWith(
"AttributesChanged"_L1)) {
738 sendObject_attributes_changed = 1;
739 }
else if (right.startsWith(
"BoundsChanged"_L1)) {
740 sendObject_bounds_changed = 1;
741 }
else if (right.startsWith(
"ChildrenChanged"_L1)) {
742 sendObject_children_changed = 1;
743 }
else if (right.startsWith(
"ColumnDeleted"_L1)) {
744 sendObject_column_deleted = 1;
745 }
else if (right.startsWith(
"ColumnInserted"_L1)) {
746 sendObject_column_inserted = 1;
747 }
else if (right.startsWith(
"ColumnReordered"_L1)) {
748 sendObject_column_reordered = 1;
749 }
else if (right.startsWith(
"LinkSelected"_L1)) {
750 sendObject_link_selected = 1;
751 }
else if (right.startsWith(
"ModelChanged"_L1)) {
752 sendObject_model_changed = 1;
753 }
else if (right.startsWith(
"PropertyChange"_L1)) {
754 if (right ==
"PropertyChange:AccessibleDescription"_L1) {
755 sendObject_property_change_accessible_description = 1;
756 }
else if (right ==
"PropertyChange:AccessibleName"_L1) {
757 sendObject_property_change_accessible_name = 1;
758 }
else if (right ==
"PropertyChange:AccessibleParent"_L1) {
759 sendObject_property_change_accessible_parent = 1;
760 }
else if (right ==
"PropertyChange:AccessibleRole"_L1) {
761 sendObject_property_change_accessible_role = 1;
762 }
else if (right ==
"PropertyChange:TableCaption"_L1) {
763 sendObject_property_change_accessible_table_caption = 1;
764 }
else if (right ==
"PropertyChange:TableColumnDescription"_L1) {
765 sendObject_property_change_accessible_table_column_description = 1;
766 }
else if (right ==
"PropertyChange:TableColumnHeader"_L1) {
767 sendObject_property_change_accessible_table_column_header = 1;
768 }
else if (right ==
"PropertyChange:TableRowDescription"_L1) {
769 sendObject_property_change_accessible_table_row_description = 1;
770 }
else if (right ==
"PropertyChange:TableRowHeader"_L1) {
771 sendObject_property_change_accessible_table_row_header = 1;
772 }
else if (right ==
"PropertyChange:TableSummary"_L1) {
773 sendObject_property_change_accessible_table_summary = 1;
774 }
else if (right ==
"PropertyChange:AccessibleValue"_L1) {
775 sendObject_property_change_accessible_value = 1;
777 sendObject_property_change = 1;
779 }
else if (right.startsWith(
"RowDeleted"_L1)) {
780 sendObject_row_deleted = 1;
781 }
else if (right.startsWith(
"RowInserted"_L1)) {
782 sendObject_row_inserted = 1;
783 }
else if (right.startsWith(
"RowReordered"_L1)) {
784 sendObject_row_reordered = 1;
785 }
else if (right.startsWith(
"SelectionChanged"_L1)) {
786 sendObject_selection_changed = 1;
787 }
else if (right.startsWith(
"StateChanged"_L1)) {
788 sendObject_state_changed = 1;
789 }
else if (right.startsWith(
"TextAttributesChanged"_L1)) {
790 sendObject_text_attributes_changed = 1;
791 }
else if (right.startsWith(
"TextBoundsChanged"_L1)) {
792 sendObject_text_bounds_changed = 1;
793 }
else if (right.startsWith(
"TextCaretMoved"_L1)) {
794 sendObject_text_caret_moved = 1;
795 }
else if (right.startsWith(
"TextChanged"_L1)) {
796 sendObject_text_changed = 1;
797 }
else if (right.startsWith(
"TextSelectionChanged"_L1)) {
798 sendObject_text_selection_changed = 1;
799 }
else if (right.startsWith(
"ValueChanged"_L1)) {
800 sendObject_value_changed = 1;
801 }
else if (right.startsWith(
"VisibleDataChanged"_L1)
802 || right.startsWith(
"VisibledataChanged"_L1)) {
803 sendObject_visible_data_changed = 1;
805 qCWarning(lcAccessibilityAtspi) <<
"Subscription string not handled:" << flag;
811 if (flag.size() <= 8) {
814 QString right = flag.mid(7);
816 }
else if (right.startsWith(
"Activate"_L1)) {
817 sendWindow_activate = 1;
818 }
else if (right.startsWith(
"Close"_L1)) {
820 }
else if (right.startsWith(
"Create"_L1)) {
821 sendWindow_create = 1;
822 }
else if (right.startsWith(
"Deactivate"_L1)) {
823 sendWindow_deactivate = 1;
824 }
else if (right.startsWith(
"Lower"_L1)) {
825 sendWindow_lower = 1;
826 }
else if (right.startsWith(
"Maximize"_L1)) {
827 sendWindow_maximize = 1;
828 }
else if (right.startsWith(
"Minimize"_L1)) {
829 sendWindow_minimize = 1;
830 }
else if (right.startsWith(
"Move"_L1)) {
832 }
else if (right.startsWith(
"Raise"_L1)) {
833 sendWindow_raise = 1;
834 }
else if (right.startsWith(
"Reparent"_L1)) {
835 sendWindow_reparent = 1;
836 }
else if (right.startsWith(
"Resize"_L1)) {
837 sendWindow_resize = 1;
838 }
else if (right.startsWith(
"Restore"_L1)) {
839 sendWindow_restore = 1;
840 }
else if (right.startsWith(
"Restyle"_L1)) {
841 sendWindow_restyle = 1;
842 }
else if (right.startsWith(
"Shade"_L1)) {
843 sendWindow_shade = 1;
844 }
else if (right.startsWith(
"Unshade"_L1)) {
845 sendWindow_unshade = 1;
846 }
else if (right.startsWith(
"DesktopCreate"_L1)) {
848 }
else if (right.startsWith(
"DesktopDestroy"_L1)) {
851 qCWarning(lcAccessibilityAtspi) <<
"Subscription string not handled:" << flag;
870 qCWarning(lcAccessibilityAtspi) <<
"Subscription string not handled:" << flag;
875
876
877void AtSpiAdaptor::updateEventListeners()
879 QDBusMessage m = QDBusMessage::createMethodCall(
"org.a11y.atspi.Registry"_L1,
880 "/org/a11y/atspi/registry"_L1,
881 "org.a11y.atspi.Registry"_L1,
"GetRegisteredEvents"_L1);
882 QDBusReply<QSpiEventListenerArray> listenersReply = m_dbus->connection().call(m);
883 if (listenersReply.isValid()) {
884 const QSpiEventListenerArray evList = listenersReply.value();
885 for (
const QSpiEventListener &ev : evList)
886 setBitFlag(ev.eventName);
887 m_applicationAdaptor->sendEvents(!evList.isEmpty());
889 qCDebug(lcAccessibilityAtspi) <<
"Could not query active accessibility event listeners.";
893void AtSpiAdaptor::eventListenerDeregistered(
const QString &,
const QString &)
896 updateEventListeners();
899void AtSpiAdaptor::eventListenerRegistered(
const QString &,
const QString &)
902 updateEventListeners();
906
907
908
909void AtSpiAdaptor::windowActivated(QObject* window,
bool active)
911 if (!(sendWindow || sendWindow_activate))
914 QAccessibleInterface *iface = QAccessible::queryAccessibleInterface(window);
916 if (iface ==
nullptr)
918 Q_ASSERT(!active || iface->isValid());
922 if (iface->isValid())
923 windowTitle = iface->text(QAccessible::Name);
926 data.setVariant(windowTitle);
928 QVariantList args = packDBusSignalArguments(QString(), 0, 0, QVariant::fromValue(data));
930 QString status = active ?
"Activate"_L1 :
"Deactivate"_L1;
931 QString path = pathForObject(window);
932 sendDBusSignal(path, ATSPI_DBUS_INTERFACE_EVENT_WINDOW
""_L1, status, args);
934 QVariantList stateArgs = packDBusSignalArguments(
"active"_L1, active ? 1 : 0, 0, variantForPath(path));
935 sendDBusSignal(path, ATSPI_DBUS_INTERFACE_EVENT_OBJECT
""_L1,
"StateChanged"_L1, stateArgs);
938QVariantList AtSpiAdaptor::packDBusSignalArguments(
const QString &type,
int data1,
int data2,
const QVariant &variantData)
940 QVariantList arguments;
941 arguments << type << data1 << data2 << variantData << QMap<QString, QVariant>();
945QVariant AtSpiAdaptor::variantForPath(
const QString &path)
const
948 data.setVariant(QVariant::fromValue(QSpiObjectReference(m_dbus->connection(), QDBusObjectPath(path))));
949 return QVariant::fromValue(data);
952bool AtSpiAdaptor::sendDBusSignal(
const QString &path,
const QString &interface,
const QString &signalName,
const QVariantList &arguments)
const
954 QDBusMessage message = QDBusMessage::createSignal(path, interface, signalName);
955 message.setArguments(arguments);
956 return m_dbus->connection().send(message);
959QAccessibleInterface *AtSpiAdaptor::interfaceFromPath(
const QString &dbusPath)
961 if (dbusPath == ATSPI_DBUS_PATH_ROOT
""_L1)
962 return QAccessible::queryAccessibleInterface(qApp);
964 QStringList parts = dbusPath.split(u'/');
965 if (parts.size() != 6) {
966 qCDebug(lcAccessibilityAtspi) <<
"invalid path: " << dbusPath;
970 QString objectString = parts.at(5);
971 QAccessible::Id id = objectString.toUInt();
975 qCWarning(lcAccessibilityAtspi) <<
"No accessible object found for id: " << id;
977 return QAccessible::accessibleInterface(id);
980void AtSpiAdaptor::notifyStateChange(QAccessibleInterface *interface,
const QString &state,
int value)
982 QString path = pathForInterface(interface);
983 QVariantList stateArgs = packDBusSignalArguments(state, value, 0, variantForPath(path));
984 sendDBusSignal(path, ATSPI_DBUS_INTERFACE_EVENT_OBJECT
""_L1,
"StateChanged"_L1, stateArgs);
987void AtSpiAdaptor::sendAnnouncement(QAccessibleAnnouncementEvent *event)
989 QAccessibleInterface *iface = event->accessibleInterface();
991 qCWarning(lcAccessibilityAtspi,
"Announcement event has no accessible set.");
994 if (!iface->isValid()) {
995 qCWarning(lcAccessibilityAtspi) <<
"Announcement event with invalid accessible: " << iface;
999 const QString path = pathForInterface(iface);
1000 const QString message = event->message();
1001 const QAccessible::AnnouncementPoliteness prio = event->politeness();
1002 const int politeness = (prio == QAccessible::AnnouncementPoliteness::Assertive) ? ATSPI_LIVE_ASSERTIVE : ATSPI_LIVE_POLITE;
1004 const QVariantList args = packDBusSignalArguments(QString(), politeness, 0, QVariant::fromValue(QDBusVariant(message)));
1005 sendDBusSignal(path, ATSPI_DBUS_INTERFACE_EVENT_OBJECT
""_L1,
"Announcement"_L1, args);
1009
1010
1011void AtSpiAdaptor::notify(QAccessibleEvent *event)
1013 switch (event->type()) {
1014 case QAccessible::ObjectCreated:
1015 if (sendObject || sendObject_children_changed)
1016 notifyAboutCreation(event->accessibleInterface());
1018 case QAccessible::ObjectShow: {
1019 if (sendObject || sendObject_state_changed) {
1020 notifyStateChange(event->accessibleInterface(),
"showing"_L1, 1);
1024 case QAccessible::ObjectHide: {
1025 if (sendObject || sendObject_state_changed) {
1026 notifyStateChange(event->accessibleInterface(),
"showing"_L1, 0);
1030 case QAccessible::ObjectDestroyed: {
1031 if (sendObject || sendObject_state_changed)
1032 notifyAboutDestruction(event->accessibleInterface());
1035 case QAccessible::ObjectReorder: {
1036 if (sendObject || sendObject_children_changed)
1037 childrenChanged(event->accessibleInterface());
1040 case QAccessible::NameChanged: {
1041 if (sendObject || sendObject_property_change || sendObject_property_change_accessible_name) {
1042 QAccessibleInterface *iface = event->accessibleInterface();
1044 qCDebug(lcAccessibilityAtspi,
1045 "NameChanged event from invalid accessible.");
1049 QString path = pathForInterface(iface);
1050 QVariantList args = packDBusSignalArguments(
1051 "accessible-name"_L1, 0, 0,
1052 QVariant::fromValue(QDBusVariant(iface->text(QAccessible::Name))));
1053 sendDBusSignal(path, ATSPI_DBUS_INTERFACE_EVENT_OBJECT
""_L1,
1054 "PropertyChange"_L1, args);
1058 case QAccessible::RoleChanged: {
1059 if (sendObject || sendObject_property_change
1060 || sendObject_property_change_accessible_role) {
1061 QAccessibleInterface *iface = event->accessibleInterface();
1062 if (!iface || !iface->isValid()) {
1063 qCDebug(lcAccessibilityAtspi,
"RoleChanged event from invalid accessible.");
1067 QString path = pathForInterface(iface);
1068 QVariantList args = packDBusSignalArguments(
1069 "accessible-role"_L1, 0, 0,
1070 QVariant::fromValue(QDBusVariant(uint(getRole(iface)))));
1071 sendDBusSignal(path, ATSPI_DBUS_INTERFACE_EVENT_OBJECT
""_L1,
"PropertyChange"_L1,
1076 case QAccessible::DescriptionChanged: {
1077 if (sendObject || sendObject_property_change || sendObject_property_change_accessible_description) {
1078 QAccessibleInterface *iface = event->accessibleInterface();
1080 qCDebug(lcAccessibilityAtspi,
1081 "DescriptionChanged event from invalid accessible.");
1085 QString path = pathForInterface(iface);
1086 QVariantList args = packDBusSignalArguments(
1087 "accessible-description"_L1, 0, 0,
1088 QVariant::fromValue(QDBusVariant(iface->text(QAccessible::Description))));
1089 sendDBusSignal(path, ATSPI_DBUS_INTERFACE_EVENT_OBJECT
""_L1,
1090 "PropertyChange"_L1, args);
1094 case QAccessible::Focus: {
1095 if (sendFocus || sendObject || sendObject_state_changed)
1096 sendFocusChanged(event->accessibleInterface());
1100 case QAccessible::Announcement: {
1101 if (sendObject || sendObject_announcement) {
1102 QAccessibleAnnouncementEvent *announcementEvent =
static_cast<QAccessibleAnnouncementEvent*>(event);
1103 sendAnnouncement(announcementEvent);
1107 case QAccessible::TextInserted:
1108 case QAccessible::TextRemoved:
1109 case QAccessible::TextUpdated: {
1110 if (sendObject || sendObject_text_changed) {
1111 QAccessibleInterface * iface = event->accessibleInterface();
1112 if (!iface || !iface->textInterface()) {
1113 qCWarning(lcAccessibilityAtspi) <<
"Received text event for invalid interface.";
1116 QString path = pathForInterface(iface);
1118 int changePosition = 0;
1119 int cursorPosition = 0;
1120 QString textRemoved;
1121 QString textInserted;
1123 if (event->type() == QAccessible::TextInserted) {
1124 QAccessibleTextInsertEvent *textEvent =
static_cast<QAccessibleTextInsertEvent*>(event);
1125 textInserted = textEvent->textInserted();
1126 changePosition = textEvent->changePosition();
1127 cursorPosition = textEvent->cursorPosition();
1128 }
else if (event->type() == QAccessible::TextRemoved) {
1129 QAccessibleTextRemoveEvent *textEvent =
static_cast<QAccessibleTextRemoveEvent*>(event);
1130 textRemoved = textEvent->textRemoved();
1131 changePosition = textEvent->changePosition();
1132 cursorPosition = textEvent->cursorPosition();
1133 }
else if (event->type() == QAccessible::TextUpdated) {
1134 QAccessibleTextUpdateEvent *textEvent =
static_cast<QAccessibleTextUpdateEvent*>(event);
1135 textInserted = textEvent->textInserted();
1136 textRemoved = textEvent->textRemoved();
1137 changePosition = textEvent->changePosition();
1138 cursorPosition = textEvent->cursorPosition();
1143 if (!textRemoved.isEmpty()) {
1144 data.setVariant(QVariant::fromValue(textRemoved));
1145 QVariantList args = packDBusSignalArguments(
"delete"_L1, changePosition, textRemoved.size(), QVariant::fromValue(data));
1146 sendDBusSignal(path, ATSPI_DBUS_INTERFACE_EVENT_OBJECT
""_L1,
1147 "TextChanged"_L1, args);
1150 if (!textInserted.isEmpty()) {
1151 data.setVariant(QVariant::fromValue(textInserted));
1152 QVariantList args = packDBusSignalArguments(
"insert"_L1, changePosition, textInserted.size(), QVariant::fromValue(data));
1153 sendDBusSignal(path, ATSPI_DBUS_INTERFACE_EVENT_OBJECT
""_L1,
1154 "TextChanged"_L1, args);
1158 Q_UNUSED(cursorPosition);
1167 case QAccessible::TextCaretMoved: {
1168 if (sendObject || sendObject_text_caret_moved) {
1169 QAccessibleInterface * iface = event->accessibleInterface();
1170 if (!iface || !iface->textInterface()) {
1171 qCWarning(lcAccessibilityAtspi) <<
"Sending TextCaretMoved from object that does not implement text interface: " << iface;
1175 QString path = pathForInterface(iface);
1176 QDBusVariant cursorData;
1177 int pos = iface->textInterface()->cursorPosition();
1178 cursorData.setVariant(QVariant::fromValue(pos));
1179 QVariantList args = packDBusSignalArguments(QString(), pos, 0, QVariant::fromValue(cursorData));
1180 sendDBusSignal(path, ATSPI_DBUS_INTERFACE_EVENT_OBJECT
""_L1,
1181 "TextCaretMoved"_L1, args);
1185 case QAccessible::TextSelectionChanged: {
1186 if (sendObject || sendObject_text_selection_changed) {
1187 QAccessibleInterface * iface = event->accessibleInterface();
1188 QString path = pathForInterface(iface);
1189 QVariantList args = packDBusSignalArguments(QString(), 0, 0, QVariant::fromValue(QDBusVariant(QVariant(QString()))));
1190 sendDBusSignal(path, ATSPI_DBUS_INTERFACE_EVENT_OBJECT
""_L1,
1191 "TextSelectionChanged"_L1, args);
1195 case QAccessible::ValueChanged: {
1196 if (sendObject || sendObject_value_changed || sendObject_property_change_accessible_value) {
1197 QAccessibleInterface * iface = event->accessibleInterface();
1199 qCWarning(lcAccessibilityAtspi) <<
"ValueChanged event from invalid accessible.";
1202 if (iface->valueInterface()) {
1203 QString path = pathForInterface(iface);
1204 QVariantList args = packDBusSignalArguments(
"accessible-value"_L1, 0, 0, variantForPath(path));
1205 sendDBusSignal(path, ATSPI_DBUS_INTERFACE_EVENT_OBJECT
""_L1,
1206 "PropertyChange"_L1, args);
1207 }
else if (iface->role() == QAccessible::ComboBox) {
1210 QString path = pathForInterface(iface);
1211 QVariantList args1 = packDBusSignalArguments(
1212 "accessible-name"_L1, 0, 0,
1213 QVariant::fromValue(QDBusVariant(iface->text(QAccessible::Name))));
1214 sendDBusSignal(path, ATSPI_DBUS_INTERFACE_EVENT_OBJECT
""_L1,
1215 "PropertyChange"_L1, args1);
1216 QVariantList args2 = packDBusSignalArguments(QString(), 0, 0, QVariant::fromValue(QDBusVariant(QVariant(0))));
1217 sendDBusSignal(path, ATSPI_DBUS_INTERFACE_EVENT_OBJECT
""_L1,
1218 "SelectionChanged"_L1, args2);
1220 qCWarning(lcAccessibilityAtspi) <<
"ValueChanged event and no ValueInterface or ComboBox: " << iface;
1225 case QAccessible::SelectionAdd:
1226 case QAccessible::SelectionRemove:
1227 case QAccessible::Selection: {
1228 QAccessibleInterface * iface = event->accessibleInterface();
1230 qCWarning(lcAccessibilityAtspi) <<
"Selection event from invalid accessible.";
1234 QString path = pathForInterface(iface);
1235 int selected = iface->state().selected ? 1 : 0;
1236 QVariantList stateArgs = packDBusSignalArguments(
"selected"_L1, selected, 0, variantForPath(path));
1237 sendDBusSignal(path, ATSPI_DBUS_INTERFACE_EVENT_OBJECT
""_L1,
"StateChanged"_L1, stateArgs);
1240 QAccessibleInterface* parent = iface->parent();
1242 qCDebug(lcAccessibilityAtspi) <<
"No valid parent in selection event.";
1246 QString parentPath = pathForInterface(parent);
1247 QVariantList args = packDBusSignalArguments(QString(), 0, 0, variantForPath(parentPath));
1248 sendDBusSignal(parentPath, QLatin1String(ATSPI_DBUS_INTERFACE_EVENT_OBJECT),
1249 QLatin1String(
"SelectionChanged"), args);
1252 case QAccessible::SelectionWithin: {
1253 QAccessibleInterface * iface = event->accessibleInterface();
1255 qCWarning(lcAccessibilityAtspi) <<
"SelectionWithin event from invalid accessible.";
1259 QString path = pathForInterface(iface);
1260 QVariantList args = packDBusSignalArguments(QString(), 0, 0, variantForPath(path));
1261 sendDBusSignal(path, QLatin1String(ATSPI_DBUS_INTERFACE_EVENT_OBJECT), QLatin1String(
"SelectionChanged"), args);
1264 case QAccessible::StateChanged: {
1265 if (sendObject || sendObject_state_changed || sendWindow || sendWindow_activate) {
1266 QAccessible::State stateChange =
static_cast<QAccessibleStateChangeEvent*>(event)->changedStates();
1267 if (stateChange.checked) {
1268 QAccessibleInterface * iface = event->accessibleInterface();
1270 qCWarning(lcAccessibilityAtspi) <<
"StateChanged event from invalid accessible.";
1273 int checked = iface->state().checked;
1274 notifyStateChange(iface,
"checked"_L1, checked);
1275 }
else if (stateChange.active) {
1276 QAccessibleInterface * iface = event->accessibleInterface();
1277 if (!iface || !(iface->role() == QAccessible::Window && (sendWindow || sendWindow_activate)))
1279 int isActive = iface->state().active;
1280 QString windowTitle = iface->text(QAccessible::Name);
1282 data.setVariant(windowTitle);
1283 QVariantList args = packDBusSignalArguments(QString(), 0, 0, QVariant::fromValue(data));
1284 QString status = isActive ?
"Activate"_L1 :
"Deactivate"_L1;
1285 QString path = pathForInterface(iface);
1286 sendDBusSignal(path, ATSPI_DBUS_INTERFACE_EVENT_WINDOW
""_L1, status, args);
1287 notifyStateChange(iface,
"active"_L1, isActive);
1288 }
else if (stateChange.disabled) {
1289 QAccessibleInterface *iface = event->accessibleInterface();
1290 QAccessible::State state = iface->state();
1291 bool enabled = !state.disabled;
1293 notifyStateChange(iface,
"enabled"_L1, enabled);
1294 notifyStateChange(iface,
"sensitive"_L1, enabled);
1295 }
else if (stateChange.focused) {
1296 QAccessibleInterface *iface = event->accessibleInterface();
1297 QAccessible::State state = iface->state();
1298 bool focused = state.focused;
1299 notifyStateChange(iface,
"focused"_L1, focused);
1300 }
else if (stateChange.expanded) {
1301 QAccessibleInterface *iface = event->accessibleInterface();
1302 QAccessible::State state = iface->state();
1303 bool expanded = state.expanded;
1304 notifyStateChange(iface,
"expanded"_L1, expanded);
1305 }
else if (stateChange.collapsed) {
1306 QAccessibleInterface *iface = event->accessibleInterface();
1307 QAccessible::State state = iface->state();
1308 bool collapsed = state.collapsed;
1309 notifyStateChange(iface,
"collapsed"_L1, collapsed);
1310 }
else if (stateChange.expandable) {
1311 QAccessibleInterface *iface = event->accessibleInterface();
1312 QAccessible::State state = iface->state();
1313 bool expandable = state.expandable;
1314 notifyStateChange(iface,
"expandable"_L1, expandable);
1319 case QAccessible::TableModelChanged: {
1320 QAccessibleInterface *interface = event->accessibleInterface();
1321 if (!interface || !interface->isValid()) {
1322 qCWarning(lcAccessibilityAtspi) <<
"TableModelChanged event from invalid accessible.";
1326 const QString path = pathForInterface(interface);
1327 QAccessibleTableModelChangeEvent *tableModelEvent =
static_cast<QAccessibleTableModelChangeEvent*>(event);
1328 switch (tableModelEvent->modelChangeType()) {
1329 case QAccessibleTableModelChangeEvent::ColumnsInserted: {
1330 if (sendObject || sendObject_column_inserted) {
1331 const int firstColumn = tableModelEvent->firstColumn();
1332 const int insertedColumnCount = tableModelEvent->lastColumn() - firstColumn + 1;
1333 QVariantList args = packDBusSignalArguments(QString(), firstColumn, insertedColumnCount, QVariant::fromValue(QDBusVariant(QVariant(QString()))));
1334 sendDBusSignal(path, ATSPI_DBUS_INTERFACE_EVENT_OBJECT
""_L1,
"ColumnInserted"_L1, args);
1338 case QAccessibleTableModelChangeEvent::ColumnsRemoved: {
1339 if (sendObject || sendObject_column_deleted) {
1340 const int firstColumn = tableModelEvent->firstColumn();
1341 const int removedColumnCount = tableModelEvent->lastColumn() - firstColumn + 1;
1342 QVariantList args = packDBusSignalArguments(QString(), firstColumn, removedColumnCount, QVariant::fromValue(QDBusVariant(QVariant(QString()))));
1343 sendDBusSignal(path, ATSPI_DBUS_INTERFACE_EVENT_OBJECT
""_L1,
"ColumnDeleted"_L1, args);
1347 case QAccessibleTableModelChangeEvent::RowsInserted: {
1348 if (sendObject || sendObject_row_inserted) {
1349 const int firstRow = tableModelEvent->firstRow();
1350 const int insertedRowCount = tableModelEvent->lastRow() - firstRow + 1;
1351 QVariantList args = packDBusSignalArguments(QString(), firstRow, insertedRowCount, QVariant::fromValue(QDBusVariant(QVariant(QString()))));
1352 sendDBusSignal(path, ATSPI_DBUS_INTERFACE_EVENT_OBJECT
""_L1,
"RowInserted"_L1, args);
1356 case QAccessibleTableModelChangeEvent::RowsRemoved: {
1357 if (sendObject || sendObject_row_deleted) {
1358 const int firstRow = tableModelEvent->firstRow();
1359 const int removedRowCount = tableModelEvent->lastRow() - firstRow + 1;
1360 QVariantList args = packDBusSignalArguments(QString(), firstRow, removedRowCount, QVariant::fromValue(QDBusVariant(QVariant(QString()))));
1361 sendDBusSignal(path, ATSPI_DBUS_INTERFACE_EVENT_OBJECT
""_L1,
"RowDeleted"_L1, args);
1365 case QAccessibleTableModelChangeEvent::ModelChangeType::ModelReset: {
1366 if (sendObject || sendObject_model_changed) {
1367 QVariantList args = packDBusSignalArguments(QString(), 0, 0, QVariant::fromValue(QDBusVariant(QVariant(QString()))));
1368 sendDBusSignal(path, ATSPI_DBUS_INTERFACE_EVENT_OBJECT
""_L1,
"ModelChanged"_L1, args);
1372 case QAccessibleTableModelChangeEvent::DataChanged: {
1373 if (sendObject || sendObject_visible_data_changed) {
1374 QVariantList args = packDBusSignalArguments(QString(), 0, 0, QVariant::fromValue(QDBusVariant(QVariant(QString()))));
1375 sendDBusSignal(path, ATSPI_DBUS_INTERFACE_EVENT_OBJECT
""_L1,
"VisibleDataChanged"_L1, args);
1384 case QAccessible::ParentChanged:
1385 case QAccessible::DialogStart:
1386 case QAccessible::DialogEnd:
1387 case QAccessible::PopupMenuStart:
1388 case QAccessible::PopupMenuEnd:
1389 case QAccessible::SoundPlayed:
1390 case QAccessible::Alert:
1391 case QAccessible::ForegroundChanged:
1392 case QAccessible::MenuStart:
1393 case QAccessible::MenuEnd:
1394 case QAccessible::ContextHelpStart:
1395 case QAccessible::ContextHelpEnd:
1396 case QAccessible::DragDropStart:
1397 case QAccessible::DragDropEnd:
1398 case QAccessible::ScrollingStart:
1399 case QAccessible::ScrollingEnd:
1400 case QAccessible::ScrollingPositionChanged:
1401 case QAccessible::MenuCommand:
1402 case QAccessible::ActionChanged:
1403 case QAccessible::ActiveDescendantChanged:
1404 case QAccessible::AttributeChanged:
1405 case QAccessible::DocumentContentChanged:
1406 case QAccessible::DocumentLoadComplete:
1407 case QAccessible::DocumentLoadStopped:
1408 case QAccessible::DocumentReload:
1409 case QAccessible::HyperlinkEndIndexChanged:
1410 case QAccessible::HyperlinkNumberOfAnchorsChanged:
1411 case QAccessible::HyperlinkSelectedLinkChanged:
1412 case QAccessible::HypertextLinkActivated:
1413 case QAccessible::HypertextLinkSelected:
1414 case QAccessible::HyperlinkStartIndexChanged:
1415 case QAccessible::HypertextChanged:
1416 case QAccessible::HypertextNLinksChanged:
1417 case QAccessible::ObjectAttributeChanged:
1418 case QAccessible::PageChanged:
1419 case QAccessible::SectionChanged:
1420 case QAccessible::TableCaptionChanged:
1421 case QAccessible::TableColumnDescriptionChanged:
1422 case QAccessible::TableColumnHeaderChanged:
1423 case QAccessible::TableRowDescriptionChanged:
1424 case QAccessible::TableRowHeaderChanged:
1425 case QAccessible::TableSummaryChanged:
1426 case QAccessible::TextAttributeChanged:
1427 case QAccessible::TextColumnChanged:
1428 case QAccessible::VisibleDataChanged:
1429 case QAccessible::LocationChanged:
1430 case QAccessible::HelpChanged:
1431 case QAccessible::DefaultActionChanged:
1432 case QAccessible::AcceleratorChanged:
1433 case QAccessible::IdentifierChanged:
1434 case QAccessible::InvalidEvent:
1439void AtSpiAdaptor::sendFocusChanged(QAccessibleInterface *interface)
const
1441 static QString lastFocusPath;
1443 if (!lastFocusPath.isEmpty()) {
1444 QVariantList stateArgs = packDBusSignalArguments(
"focused"_L1, 0, 0, variantForPath(lastFocusPath));
1445 sendDBusSignal(lastFocusPath, ATSPI_DBUS_INTERFACE_EVENT_OBJECT
""_L1,
1446 "StateChanged"_L1, stateArgs);
1450 QString path = pathForInterface(interface);
1452 QVariantList stateArgs = packDBusSignalArguments(
"focused"_L1, 1, 0, variantForPath(path));
1453 sendDBusSignal(path, ATSPI_DBUS_INTERFACE_EVENT_OBJECT
""_L1,
1454 "StateChanged"_L1, stateArgs);
1456 QVariantList focusArgs = packDBusSignalArguments(QString(), 0, 0, variantForPath(path));
1457 sendDBusSignal(path, ATSPI_DBUS_INTERFACE_EVENT_FOCUS
""_L1,
"Focus"_L1, focusArgs);
1458 lastFocusPath = path;
1462void AtSpiAdaptor::childrenChanged(QAccessibleInterface *interface)
const
1464 QString parentPath = pathForInterface(interface);
1465 const int childCount = interface->childCount();
1466 for (
int i = 0; i < childCount; ++i) {
1467 QString childPath = pathForInterface(interface->child(i));
1468 QVariantList args = packDBusSignalArguments(
"add"_L1, i, 0, childPath);
1469 sendDBusSignal(parentPath, ATSPI_DBUS_INTERFACE_EVENT_OBJECT
""_L1,
"ChildrenChanged"_L1, args);
1473void AtSpiAdaptor::notifyAboutCreation(QAccessibleInterface *interface)
const
1476 QAccessibleInterface * parent = interface->parent();
1478 qCDebug(lcAccessibilityAtspi) <<
"AtSpiAdaptor::notifyAboutCreation: Could not find parent for " << interface->object();
1481 QString path = pathForInterface(interface);
1482 const int childIndex = parent->indexOfChild(interface);
1483 QString parentPath = pathForInterface(parent);
1484 QVariantList args = packDBusSignalArguments(
"add"_L1, childIndex, 0, variantForPath(path));
1485 sendDBusSignal(parentPath, ATSPI_DBUS_INTERFACE_EVENT_OBJECT
""_L1,
"ChildrenChanged"_L1, args);
1488void AtSpiAdaptor::notifyAboutDestruction(QAccessibleInterface *interface)
const
1490 if (!interface || !interface->isValid())
1493 QAccessibleInterface * parent = interface->parent();
1495 qCDebug(lcAccessibilityAtspi) <<
"AtSpiAdaptor::notifyAboutDestruction: Could not find parent for " << interface->object();
1498 QString path = pathForInterface(interface);
1502 int childIndex = -1;
1509 QString parentPath = pathForInterface(parent);
1510 QVariantList args = packDBusSignalArguments(
"remove"_L1, childIndex, 0, variantForPath(path));
1511 sendDBusSignal(parentPath, ATSPI_DBUS_INTERFACE_EVENT_OBJECT
""_L1,
"ChildrenChanged"_L1, args);
1515
1516
1517
1518bool AtSpiAdaptor::handleMessage(
const QDBusMessage &message,
const QDBusConnection &connection)
1521 QAccessibleInterface * accessible = interfaceFromPath(message.path());
1523 qCWarning(lcAccessibilityAtspi) <<
"Could not find accessible on path:" << message.path();
1526 if (!accessible->isValid()) {
1527 qCWarning(lcAccessibilityAtspi) <<
"Accessible invalid:" << accessible << message.path();
1531 QString interface = message.interface();
1532 QString function = message.member();
1536 if (function ==
"Introspect"_L1) {
1542 if (interface ==
"org.freedesktop.DBus.Properties"_L1) {
1543 const auto arguments = message.arguments();
1544 if (arguments.size() > 0) {
1545 interface = arguments.at(0).toString();
1546 if (arguments.size() > 1)
1547 function = function + arguments.at(1).toString();
1552 if (interface == ATSPI_DBUS_INTERFACE_ACCESSIBLE
""_L1)
1553 return accessibleInterface(accessible, function, message, connection);
1554 if (interface == ATSPI_DBUS_INTERFACE_APPLICATION
""_L1)
1555 return applicationInterface(accessible, function, message, connection);
1556 if (interface == ATSPI_DBUS_INTERFACE_COLLECTION
""_L1)
1557 return collectionInterface(accessible, function, message, connection);
1558 if (interface == ATSPI_DBUS_INTERFACE_COMPONENT
""_L1)
1559 return componentInterface(accessible, function, message, connection);
1560 if (interface == ATSPI_DBUS_INTERFACE_ACTION
""_L1)
1561 return actionInterface(accessible, function, message, connection);
1562 if (interface == ATSPI_DBUS_INTERFACE_SELECTION
""_L1)
1563 return selectionInterface(accessible, function, message, connection);
1564 if (interface == ATSPI_DBUS_INTERFACE_TEXT
""_L1)
1565 return textInterface(accessible, function, message, connection);
1566 if (interface == ATSPI_DBUS_INTERFACE_EDITABLE_TEXT
""_L1)
1567 return editableTextInterface(accessible, function, message, connection);
1568 if (interface == ATSPI_DBUS_INTERFACE_VALUE
""_L1)
1569 return valueInterface(accessible, function, message, connection);
1570 if (interface == ATSPI_DBUS_INTERFACE_TABLE
""_L1)
1571 return tableInterface(accessible, function, message, connection);
1572 if (interface == ATSPI_DBUS_INTERFACE_TABLE_CELL
""_L1)
1573 return tableCellInterface(accessible, function, message, connection);
1575 qCDebug(lcAccessibilityAtspi) <<
"AtSpiAdaptor::handleMessage with unknown interface: " << message.path() << interface << function;
1580bool AtSpiAdaptor::applicationInterface(QAccessibleInterface *interface,
const QString &function,
const QDBusMessage &message,
const QDBusConnection &connection)
1582 if (message.path() != ATSPI_DBUS_PATH_ROOT
""_L1) {
1583 qCWarning(lcAccessibilityAtspi) <<
"Could not find application interface for:" << message.path() << interface;
1587 if (function ==
"SetId"_L1) {
1588 Q_ASSERT(message.signature() ==
"ssv"_L1);
1589 QVariant value = qvariant_cast<QDBusVariant>(message.arguments().at(2)).variant();
1591 m_applicationId = value.toInt();
1594 if (function ==
"GetId"_L1) {
1595 Q_ASSERT(message.signature() ==
"ss"_L1);
1596 QDBusMessage reply = message.createReply(QVariant::fromValue(QDBusVariant(m_applicationId)));
1597 return connection.send(reply);
1599 if (function ==
"GetAtspiVersion"_L1) {
1600 Q_ASSERT(message.signature() ==
"ss"_L1);
1602 QDBusMessage reply = message.createReply(QVariant::fromValue(QDBusVariant(
"2.1"_L1)));
1603 return connection.send(reply);
1605 if (function ==
"GetToolkitName"_L1) {
1606 Q_ASSERT(message.signature() ==
"ss"_L1);
1607 QDBusMessage reply = message.createReply(QVariant::fromValue(QDBusVariant(
"Qt"_L1)));
1608 return connection.send(reply);
1610 if (function ==
"GetVersion"_L1) {
1611 Q_ASSERT(message.signature() ==
"ss"_L1);
1612 QDBusMessage reply = message.createReply(QVariant::fromValue(QDBusVariant(QLatin1StringView(qVersion()))));
1613 return connection.send(reply);
1615 if (function ==
"GetLocale"_L1) {
1616 Q_ASSERT(message.signature() ==
"u"_L1);
1617 QDBusMessage reply = message.createReply(QVariant::fromValue(QLocale().name()));
1618 return connection.send(reply);
1620 qCWarning(lcAccessibilityAtspi) <<
"AtSpiAdaptor::applicationInterface does not implement"
1621 << function << message.path();
1626
1627
1628void AtSpiAdaptor::registerApplication()
1630 OrgA11yAtspiSocketInterface registry(ATSPI_DBUS_NAME_REGISTRY
""_L1, ATSPI_DBUS_PATH_ROOT
""_L1,
1631 m_dbus->connection());
1633 QDBusPendingReply<QSpiObjectReference> reply;
1634 QSpiObjectReference ref = QSpiObjectReference(m_dbus->connection(), QDBusObjectPath(ATSPI_DBUS_PATH_ROOT));
1635 reply = registry.Embed(ref);
1636 reply.waitForFinished();
1637 if (reply.isValid ()) {
1638 const QSpiObjectReference &socket = reply.value();
1639 m_accessibilityRegistry = QSpiObjectReference(socket);
1641 qCWarning(lcAccessibilityAtspi) <<
"Error in contacting registry:"
1642 << reply.error().name()
1643 << reply.error().message();
1648bool AtSpiAdaptor::accessibleInterface(QAccessibleInterface *interface,
const QString &function,
const QDBusMessage &message,
const QDBusConnection &connection)
1650 if (function ==
"GetRole"_L1) {
1651 sendReply(connection, message, (uint) getRole(interface));
1652 }
else if (function ==
"GetName"_L1) {
1653 sendReply(connection, message, QVariant::fromValue(QDBusVariant(interface->text(QAccessible::Name))));
1654 }
else if (function ==
"GetRoleName"_L1) {
1655 sendReply(connection, message, QSpiAccessibleBridge::namesForRole(interface->role()).name());
1656 }
else if (function ==
"GetLocalizedRoleName"_L1) {
1657 sendReply(connection, message, QVariant::fromValue(QSpiAccessibleBridge::namesForRole(interface->role()).localizedName()));
1658 }
else if (function ==
"GetChildCount"_L1) {
1659 sendReply(connection, message, QVariant::fromValue(QDBusVariant(interface->childCount())));
1660 }
else if (function ==
"GetIndexInParent"_L1) {
1661 int childIndex = -1;
1662 QAccessibleInterface * parent = interface->parent();
1664 childIndex = parent->indexOfChild(interface);
1665 if (childIndex < 0) {
1666 qCDebug(lcAccessibilityAtspi) <<
"GetIndexInParent get invalid index: " << childIndex << interface;
1669 sendReply(connection, message, childIndex);
1670 }
else if (function ==
"GetParent"_L1) {
1672 QAccessibleInterface * parent = interface->parent();
1674 if (interface->object() == qApp) {
1675 sendReply(connection, message,
1676 QVariant::fromValue(QDBusVariant(QVariant::fromValue(m_accessibilityRegistry))));
1680 path = ATSPI_DBUS_PATH_NULL
""_L1;
1681 }
else if (parent->role() == QAccessible::Application) {
1682 path = ATSPI_DBUS_PATH_ROOT
""_L1;
1684 path = pathForInterface(parent);
1687 sendReply(connection, message, QVariant::fromValue(
1688 QDBusVariant(QVariant::fromValue(QSpiObjectReference(connection, QDBusObjectPath(path))))));
1689 }
else if (function ==
"GetChildAtIndex"_L1) {
1690 const int index = message.arguments().at(0).toInt();
1692 sendReply(connection, message, QVariant::fromValue(
1693 QSpiObjectReference(connection, QDBusObjectPath(ATSPI_DBUS_PATH_NULL))));
1695 QAccessibleInterface * childInterface = interface->child(index);
1696 sendReply(connection, message, QVariant::fromValue(
1697 QSpiObjectReference(connection, QDBusObjectPath(pathForInterface(childInterface)))));
1699 }
else if (function ==
"GetInterfaces"_L1) {
1700 sendReply(connection, message, accessibleInterfaces(interface));
1701 }
else if (function ==
"GetDescription"_L1) {
1702 sendReply(connection, message, QVariant::fromValue(QDBusVariant(interface->text(QAccessible::Description))));
1703 }
else if (function ==
"GetHelpText"_L1) {
1704 sendReply(connection, message, QVariant::fromValue(QDBusVariant(interface->text(QAccessible::Help))));
1705 }
else if (function ==
"GetState"_L1) {
1706 quint64 spiState = spiStatesFromQState(interface->state());
1707 if (QAccessibleAttributesInterface *attributesIface = interface->attributesInterface()) {
1708 const QVariant orientationVariant =
1709 attributesIface->attributeValue(QAccessible::Attribute::Orientation);
1710 if (orientationVariant.isValid()) {
1711 Q_ASSERT(orientationVariant.canConvert<Qt::Orientation>());
1712 const Qt::Orientation orientation = orientationVariant.value<Qt::Orientation>();
1713 setSpiStateBit(&spiState,
1714 orientation == Qt::Horizontal ? ATSPI_STATE_HORIZONTAL
1715 : ATSPI_STATE_VERTICAL);
1718 if (interface->tableInterface()) {
1722 setSpiStateBit(&spiState, ATSPI_STATE_MANAGES_DESCENDANTS);
1724 QAccessible::Role role = interface->role();
1725 if (role == QAccessible::TreeItem ||
1726 role == QAccessible::ListItem) {
1728
1729
1730
1731 setSpiStateBit(&spiState, ATSPI_STATE_TRANSIENT);
1733 sendReply(connection, message,
1734 QVariant::fromValue(spiStateSetFromSpiStates(spiState)));
1735 }
else if (function ==
"GetAttributes"_L1) {
1736 sendReply(connection, message, QVariant::fromValue(getAttributes(interface)));
1737 }
else if (function ==
"GetRelationSet"_L1) {
1738 sendReply(connection, message, QVariant::fromValue(relationSet(interface, connection)));
1739 }
else if (function ==
"GetApplication"_L1) {
1740 sendReply(connection, message, QVariant::fromValue(
1741 QSpiObjectReference(connection, QDBusObjectPath(ATSPI_DBUS_PATH_ROOT))));
1742 }
else if (function ==
"GetLocale"_L1) {
1744 if (QAccessibleAttributesInterface *attributesIface = interface->attributesInterface()) {
1745 const QVariant localeVariant = attributesIface->attributeValue(QAccessible::Attribute::Locale);
1746 if (localeVariant.isValid()) {
1747 Q_ASSERT(localeVariant.canConvert<QLocale>());
1748 locale = localeVariant.toLocale();
1751 sendReply(connection, message, QVariant::fromValue(QDBusVariant(locale.name())));
1752 }
else if (function ==
"GetChildren"_L1) {
1753 QSpiObjectReferenceArray children;
1754 const int numChildren = interface->childCount();
1755 children.reserve(numChildren);
1756 for (
int i = 0; i < numChildren; ++i) {
1757 QString childPath = pathForInterface(interface->child(i));
1758 QSpiObjectReference ref(connection, QDBusObjectPath(childPath));
1761 connection.send(message.createReply(QVariant::fromValue(children)));
1762 }
else if (function ==
"GetAccessibleId"_L1) {
1763 sendReply(connection, message,
1764 QVariant::fromValue(QDBusVariant(QAccessibleBridgeUtils::accessibleId(interface))));
1766 qCWarning(lcAccessibilityAtspi) <<
"AtSpiAdaptor::accessibleInterface does not implement" << function << message.path();
1772AtspiRole AtSpiAdaptor::getRole(QAccessibleInterface *interface)
1774 if ((interface->role() == QAccessible::EditableText) && interface->state().passwordEdit)
1775 return ATSPI_ROLE_PASSWORD_TEXT;
1776 return QSpiAccessibleBridge::namesForRole(interface->role()).spiRole();
1779QStringList AtSpiAdaptor::accessibleInterfaces(QAccessibleInterface *interface)
1782 qCDebug(lcAccessibilityAtspiCreation) <<
"AtSpiAdaptor::accessibleInterfaces create: " << interface->object();
1783 ifaces << u"" ATSPI_DBUS_INTERFACE_ACCESSIBLE
""_s;
1785 ifaces << u"" ATSPI_DBUS_INTERFACE_COLLECTION
""_s;
1787 if ( (!interface->rect().isEmpty()) ||
1788 (interface->object() && interface->object()->isWidgetType()) ||
1789 (interface->role() == QAccessible::ListItem) ||
1790 (interface->role() == QAccessible::Cell) ||
1791 (interface->role() == QAccessible::TreeItem) ||
1792 (interface->role() == QAccessible::Row) ||
1793 (interface->object() && interface->object()->inherits(
"QSGItem"))
1795 ifaces << u"" ATSPI_DBUS_INTERFACE_COMPONENT
""_s;
1797 qCDebug(lcAccessibilityAtspiCreation) <<
" IS NOT a component";
1799 if (interface->role() == QAccessible::Application)
1800 ifaces << u"" ATSPI_DBUS_INTERFACE_APPLICATION
""_s;
1802 if (interface->actionInterface() || interface->valueInterface())
1803 ifaces << u"" ATSPI_DBUS_INTERFACE_ACTION
""_s;
1805 if (interface->selectionInterface())
1806 ifaces << ATSPI_DBUS_INTERFACE_SELECTION
""_L1;
1808 if (interface->textInterface())
1809 ifaces << u"" ATSPI_DBUS_INTERFACE_TEXT
""_s;
1811 if (interface->editableTextInterface())
1812 ifaces << u"" ATSPI_DBUS_INTERFACE_EDITABLE_TEXT
""_s;
1814 if (interface->valueInterface())
1815 ifaces << u"" ATSPI_DBUS_INTERFACE_VALUE
""_s;
1817 if (interface->tableInterface())
1818 ifaces << u"" ATSPI_DBUS_INTERFACE_TABLE
""_s;
1820 if (interface->tableCellInterface())
1821 ifaces << u"" ATSPI_DBUS_INTERFACE_TABLE_CELL
""_s;
1826QSpiRelationArray AtSpiAdaptor::relationSet(QAccessibleInterface *interface,
1827 const QDBusConnection &connection)
1829 typedef std::pair<QAccessibleInterface*, QAccessible::Relation> RelationPair;
1830 const QList<RelationPair> relationInterfaces = interface->relations();
1832 QSpiRelationArray relations;
1833 for (
const RelationPair &pair : relationInterfaces) {
1836 QSpiObjectReferenceArray related;
1838 QDBusObjectPath path = QDBusObjectPath(pathForInterface(pair.first));
1839 related.append(QSpiObjectReference(connection, path));
1841 if (!related.isEmpty())
1842 relations.append(QSpiRelationArrayEntry(qAccessibleRelationToAtSpiRelation(pair.second), related));
1847void AtSpiAdaptor::sendReply(
const QDBusConnection &connection,
const QDBusMessage &message,
const QVariant &argument)
const
1849 QDBusMessage reply = message.createReply(argument);
1850 connection.send(reply);
1853QString AtSpiAdaptor::pathForObject(QObject *object)
1857 if (inheritsQAction(object)) {
1858 qCWarning(lcAccessibilityAtspi) <<
"AtSpiAdaptor::pathForObject: Creating path with QAction as object.";
1861 QAccessibleInterface *iface = QAccessible::queryAccessibleInterface(object);
1862 return pathForInterface(iface);
1865QString AtSpiAdaptor::pathForInterface(QAccessibleInterface *interface)
1867 if (!interface || !interface->isValid())
1868 return u"" ATSPI_DBUS_PATH_NULL
""_s;
1869 if (interface->role() == QAccessible::Application)
1870 return u"" ATSPI_DBUS_PATH_ROOT
""_s;
1872 QAccessible::Id id = QAccessible::uniqueId(interface);
1873 Q_ASSERT((
int)id < 0);
1874 return QSPI_OBJECT_PATH_PREFIX
""_L1 + QString::number(id);
1877bool AtSpiAdaptor::inheritsQAction(QObject *object)
1879 const QMetaObject *mo = object->metaObject();
1881 const QLatin1StringView cn(mo->className());
1882 if (cn ==
"QAction"_L1)
1884 mo = mo->superClass();
1890static QAccessibleInterface * getWindow(QAccessibleInterface * interface)
1894 QAccessibleInterface* app = QAccessible::queryAccessibleInterface(qApp);
1895 while (interface && interface->role() != QAccessible::Dialog
1896 && interface->role() != QAccessible::Window && interface->parent() != app)
1897 interface = interface->parent();
1902void AtSpiAdaptor::addMatchingDescendants(QList<QAccessibleInterface *> &matches,
1903 QAccessibleInterface *accessible,
1904 const QSpiMatchRuleMatcher &matcher,
bool invert,
1905 int count,
bool traverse)
1907 if (!accessible || (count != 0 && matches.size() >= count))
1910 const int childCount = accessible->childCount();
1911 for (
int i = 0; i < childCount; ++i) {
1912 if (QAccessibleInterface *child = accessible->child(i)) {
1913 if (matcher.match(*child) != invert)
1914 matches.append(child);
1917 addMatchingDescendants(matches, child, matcher, invert, count, traverse);
1919 if (count != 0 && matches.size() >= count)
1925bool AtSpiAdaptor::collectionInterface(QAccessibleInterface *interface,
const QString &function,
1926 const QDBusMessage &message,
1927 const QDBusConnection &connection)
1929 if (function ==
"GetMatches"_L1) {
1930 if (message.signature() != u"(aiia{ss}iaiiasib)uib") {
1931 qCWarning(lcAccessibilityAtspi)
1932 <<
"AtSpiAdaptor::collectionInterface: Invalid signature for " << function
1933 <<
": " << message.path();
1937 const QSpiMatchRule matchRule = qdbus_cast<QSpiMatchRule>(message.arguments().at(0));
1938 const int count = message.arguments().at(2).toInt();
1939 const bool traverse = message.arguments().at(3).toBool();
1941 QList<QAccessibleInterface *> matchedAccessibles;
1942 addMatchingDescendants(matchedAccessibles, interface, QSpiMatchRuleMatcher(matchRule),
1943 matchRule.invert, count, traverse);
1945 QSpiObjectReferenceArray result;
1946 result.reserve(matchedAccessibles.size());
1947 for (QAccessibleInterface *iface : std::as_const(matchedAccessibles)) {
1948 QSpiObjectReference ref(connection, QDBusObjectPath(pathForInterface(iface)));
1951 connection.send(message.createReply(QVariant::fromValue(result)));
1955 qCWarning(lcAccessibilityAtspi)
1956 <<
"AtSpiAdaptor::collectionInterface does not implement" << function << message.path();
1960bool AtSpiAdaptor::componentInterface(QAccessibleInterface *interface,
const QString &function,
const QDBusMessage &message,
const QDBusConnection &connection)
1962 if (function ==
"Contains"_L1) {
1964 int x = message.arguments().at(0).toInt();
1965 int y = message.arguments().at(1).toInt();
1966 uint coordType = message.arguments().at(2).toUInt();
1967 if (!isValidCoordType(coordType))
1969 ret = getExtents(interface, coordType).contains(x, y);
1970 sendReply(connection, message, ret);
1971 }
else if (function ==
"GetAccessibleAtPoint"_L1) {
1972 QPoint point(message.arguments().at(0).toInt(), message.arguments().at(1).toInt());
1973 uint coordType = message.arguments().at(2).toUInt();
1974 if (!isValidCoordType(coordType))
1976 QPoint screenPos = translateToScreenCoordinates(interface, point, coordType);
1978 QAccessibleInterface * childInterface(interface->childAt(screenPos.x(), screenPos.y()));
1979 QAccessibleInterface * iface =
nullptr;
1980 while (childInterface) {
1981 iface = childInterface;
1982 childInterface = iface->childAt(screenPos.x(), screenPos.y());
1985 QString path = pathForInterface(iface);
1986 sendReply(connection, message, QVariant::fromValue(
1987 QSpiObjectReference(connection, QDBusObjectPath(path))));
1989 sendReply(connection, message, QVariant::fromValue(
1990 QSpiObjectReference(connection, QDBusObjectPath(ATSPI_DBUS_PATH_NULL))));
1992 }
else if (function ==
"GetAlpha"_L1) {
1993 sendReply(connection, message, (
double) 1.0);
1994 }
else if (function ==
"GetExtents"_L1) {
1995 uint coordType = message.arguments().at(0).toUInt();
1996 if (!isValidCoordType(coordType))
1998 sendReply(connection, message, QVariant::fromValue(getExtents(interface, coordType)));
1999 }
else if (function ==
"GetLayer"_L1) {
2000 sendReply(connection, message, QVariant::fromValue((uint)1));
2001 }
else if (function ==
"GetMDIZOrder"_L1) {
2002 sendReply(connection, message, QVariant::fromValue((
short)0));
2003 }
else if (function ==
"GetPosition"_L1) {
2004 uint coordType = message.arguments().at(0).toUInt();
2005 if (!isValidCoordType(coordType))
2007 QRect rect = getExtents(interface, coordType);
2009 pos << rect.x() << rect.y();
2010 connection.send(message.createReply(pos));
2011 }
else if (function ==
"GetSize"_L1) {
2012 QRect rect = interface->rect();
2014 size << rect.width() << rect.height();
2015 connection.send(message.createReply(size));
2016 }
else if (function ==
"GrabFocus"_L1) {
2017 QAccessibleActionInterface *actionIface = interface->actionInterface();
2018 if (actionIface && actionIface->actionNames().contains(QAccessibleActionInterface::setFocusAction())) {
2019 actionIface->doAction(QAccessibleActionInterface::setFocusAction());
2020 sendReply(connection, message,
true);
2022 sendReply(connection, message,
false);
2024 }
else if (function ==
"SetExtents"_L1) {
2030 qCDebug(lcAccessibilityAtspi) <<
"SetExtents is not implemented.";
2031 sendReply(connection, message,
false);
2032 }
else if (function ==
"SetPosition"_L1) {
2036 qCDebug(lcAccessibilityAtspi) <<
"SetPosition is not implemented.";
2037 sendReply(connection, message,
false);
2038 }
else if (function ==
"SetSize"_L1) {
2041 qCDebug(lcAccessibilityAtspi) <<
"SetSize is not implemented.";
2042 sendReply(connection, message,
false);
2044 qCWarning(lcAccessibilityAtspi) <<
"AtSpiAdaptor::componentInterface does not implement" << function << message.path();
2050QRect AtSpiAdaptor::getExtents(QAccessibleInterface *interface, uint coordType)
2052 return translateFromScreenCoordinates(interface, interface->rect(), coordType);
2056bool AtSpiAdaptor::actionInterface(QAccessibleInterface *interface,
const QString &function,
const QDBusMessage &message,
const QDBusConnection &connection)
2058 if (function ==
"GetNActions"_L1) {
2059 int count = QAccessibleBridgeUtils::effectiveActionNames(interface).size();
2060 sendReply(connection, message, QVariant::fromValue(QDBusVariant(QVariant::fromValue(count))));
2061 }
else if (function ==
"DoAction"_L1) {
2062 int index = message.arguments().at(0).toInt();
2063 const QStringList actionNames = QAccessibleBridgeUtils::effectiveActionNames(interface);
2064 if (index < 0 || index >= actionNames.size())
2066 const QString actionName = actionNames.at(index);
2067 bool success = QAccessibleBridgeUtils::performEffectiveAction(interface, actionName);
2068 sendReply(connection, message, success);
2069 }
else if (function ==
"GetActions"_L1) {
2070 sendReply(connection, message, QVariant::fromValue(getActions(interface)));
2071 }
else if (function ==
"GetName"_L1) {
2072 int index = message.arguments().at(0).toInt();
2073 const QStringList actionNames = QAccessibleBridgeUtils::effectiveActionNames(interface);
2074 if (index < 0 || index >= actionNames.size())
2076 sendReply(connection, message, actionNames.at(index));
2077 }
else if (function ==
"GetDescription"_L1) {
2078 int index = message.arguments().at(0).toInt();
2079 const QStringList actionNames = QAccessibleBridgeUtils::effectiveActionNames(interface);
2080 if (index < 0 || index >= actionNames.size())
2082 QString description;
2083 if (QAccessibleActionInterface *actionIface = interface->actionInterface())
2084 description = actionIface->localizedActionDescription(actionNames.at(index));
2086 description = qAccessibleLocalizedActionDescription(actionNames.at(index));
2087 sendReply(connection, message, description);
2088 }
else if (function ==
"GetKeyBinding"_L1) {
2089 int index = message.arguments().at(0).toInt();
2090 const QStringList actionNames = QAccessibleBridgeUtils::effectiveActionNames(interface);
2091 if (index < 0 || index >= actionNames.size())
2093 QStringList keyBindings;
2094 if (QAccessibleActionInterface *actionIface = interface->actionInterface())
2095 keyBindings = actionIface->keyBindingsForAction(actionNames.at(index));
2096 if (keyBindings.isEmpty()) {
2097 QString acc = interface->text(QAccessible::Accelerator);
2099 keyBindings.append(acc);
2101 if (keyBindings.size() > 0)
2102 sendReply(connection, message, keyBindings.join(u';'));
2104 sendReply(connection, message, QString());
2106 qCWarning(lcAccessibilityAtspi) <<
"AtSpiAdaptor::actionInterface does not implement" << function << message.path();
2112QSpiActionArray AtSpiAdaptor::getActions(QAccessibleInterface *interface)
const
2114 QAccessibleActionInterface *actionInterface = interface->actionInterface();
2115 QSpiActionArray actions;
2116 const QStringList actionNames = QAccessibleBridgeUtils::effectiveActionNames(interface);
2117 actions.reserve(actionNames.size());
2118 for (
const QString &actionName : actionNames) {
2121 action.name = actionName;
2122 if (actionInterface) {
2123 action.description = actionInterface->localizedActionDescription(actionName);
2124 const QStringList keyBindings = actionInterface->keyBindingsForAction(actionName);
2125 if (!keyBindings.isEmpty())
2126 action.keyBinding = keyBindings.front();
2128 action.description = qAccessibleLocalizedActionDescription(actionName);
2131 actions.append(std::move(action));
2137bool AtSpiAdaptor::textInterface(QAccessibleInterface *interface,
const QString &function,
const QDBusMessage &message,
const QDBusConnection &connection)
2139 if (!interface->textInterface())
2143 if (function ==
"GetCaretOffset"_L1) {
2144 sendReply(connection, message, QVariant::fromValue(QDBusVariant(QVariant::fromValue(interface->textInterface()->cursorPosition()))));
2145 }
else if (function ==
"GetCharacterCount"_L1) {
2146 sendReply(connection, message, QVariant::fromValue(QDBusVariant(QVariant::fromValue(interface->textInterface()->characterCount()))));
2149 }
else if (function ==
"AddSelection"_L1) {
2150 int startOffset = message.arguments().at(0).toInt();
2151 int endOffset = message.arguments().at(1).toInt();
2152 int lastSelection = interface->textInterface()->selectionCount();
2153 interface->textInterface()->setSelection(lastSelection, startOffset, endOffset);
2154 sendReply(connection, message, (interface->textInterface()->selectionCount() > lastSelection));
2155 }
else if (function ==
"GetAttributeRun"_L1) {
2156 int offset = message.arguments().at(0).toInt();
2157 bool includeDefaults = message.arguments().at(1).toBool();
2158 Q_UNUSED(includeDefaults);
2159 connection.send(message.createReply(getAttributes(interface, offset, includeDefaults)));
2160 }
else if (function ==
"GetAttributeValue"_L1) {
2161 int offset = message.arguments().at(0).toInt();
2162 QString attributeName = message.arguments().at(1).toString();
2163 connection.send(message.createReply(QVariant(getAttributeValue(interface, offset, attributeName))));
2164 }
else if (function ==
"GetAttributes"_L1) {
2165 int offset = message.arguments().at(0).toInt();
2166 connection.send(message.createReply(getAttributes(interface, offset,
true)));
2167 }
else if (function ==
"GetBoundedRanges"_L1) {
2168 int x = message.arguments().at(0).toInt();
2169 int y = message.arguments().at(1).toInt();
2170 int width = message.arguments().at(2).toInt();
2171 int height = message.arguments().at(3).toInt();
2172 uint coordType = message.arguments().at(4).toUInt();
2173 uint xClipType = message.arguments().at(5).toUInt();
2174 uint yClipType = message.arguments().at(6).toUInt();
2179 Q_UNUSED(coordType);
2180 Q_UNUSED(xClipType);
2181 Q_UNUSED(yClipType);
2182 qCDebug(lcAccessibilityAtspi) <<
"Not implemented: QSpiAdaptor::GetBoundedRanges";
2183 sendReply(connection, message, QVariant::fromValue(QSpiTextRangeList()));
2184 }
else if (function ==
"GetCharacterAtOffset"_L1) {
2185 int offset = message.arguments().at(0).toInt();
2188 const QString charString = interface->textInterface()
2189 ->textAtOffset(offset, QAccessible::CharBoundary, &start, &end);
2191 QStringIterator stringIt(charString);
2192 if (stringIt.hasNext())
2193 codePoint =
static_cast<
int>(stringIt.peekNext());
2194 sendReply(connection, message, codePoint);
2195 }
else if (function ==
"GetCharacterExtents"_L1) {
2196 int offset = message.arguments().at(0).toInt();
2197 int coordType = message.arguments().at(1).toUInt();
2198 connection.send(message.createReply(getCharacterExtents(interface, offset, coordType)));
2199 }
else if (function ==
"GetDefaultAttributeSet"_L1 || function ==
"GetDefaultAttributes"_L1) {
2202 sendReply(connection, message, QVariant::fromValue(QSpiAttributeSet()));
2203 }
else if (function ==
"GetNSelections"_L1) {
2204 sendReply(connection, message, interface->textInterface()->selectionCount());
2205 }
else if (function ==
"GetOffsetAtPoint"_L1) {
2206 qCDebug(lcAccessibilityAtspi) << message.signature();
2207 Q_ASSERT(!message.signature().isEmpty());
2208 QPoint point(message.arguments().at(0).toInt(), message.arguments().at(1).toInt());
2209 uint coordType = message.arguments().at(2).toUInt();
2210 if (!isValidCoordType(coordType))
2212 QPoint screenPos = translateToScreenCoordinates(interface, point, coordType);
2213 int offset = interface->textInterface()->offsetAtPoint(screenPos);
2214 sendReply(connection, message, offset);
2215 }
else if (function ==
"GetRangeExtents"_L1) {
2216 int startOffset = message.arguments().at(0).toInt();
2217 int endOffset = message.arguments().at(1).toInt();
2218 uint coordType = message.arguments().at(2).toUInt();
2219 connection.send(message.createReply(getRangeExtents(interface, startOffset, endOffset, coordType)));
2220 }
else if (function ==
"GetSelection"_L1) {
2221 int selectionNum = message.arguments().at(0).toInt();
2223 interface->textInterface()->selection(selectionNum, &start, &end);
2225 start = end = interface->textInterface()->cursorPosition();
2227 sel << start << end;
2228 connection.send(message.createReply(sel));
2229 }
else if (function ==
"GetStringAtOffset"_L1) {
2230 int offset = message.arguments().at(0).toInt();
2231 uint granularity = message.arguments().at(1).toUInt();
2232 if (!isValidAtspiTextGranularity(granularity))
2234 int startOffset, endOffset;
2235 QString text = interface->textInterface()->textAtOffset(offset, qAccessibleBoundaryTypeFromAtspiTextGranularity(granularity), &startOffset, &endOffset);
2237 ret << text << startOffset << endOffset;
2238 connection.send(message.createReply(ret));
2239 }
else if (function ==
"GetText"_L1) {
2240 int startOffset = message.arguments().at(0).toInt();
2241 int endOffset = message.arguments().at(1).toInt();
2242 if (endOffset == -1)
2243 endOffset = interface->textInterface()->characterCount();
2244 sendReply(connection, message, interface->textInterface()->text(startOffset, endOffset));
2245 }
else if (function ==
"GetTextAfterOffset"_L1) {
2246 int offset = message.arguments().at(0).toInt();
2247 int type = message.arguments().at(1).toUInt();
2248 int startOffset, endOffset;
2249 QString text = interface->textInterface()->textAfterOffset(offset, qAccessibleBoundaryTypeFromAtspiBoundaryType(type), &startOffset, &endOffset);
2251 ret << text << startOffset << endOffset;
2252 connection.send(message.createReply(ret));
2253 }
else if (function ==
"GetTextAtOffset"_L1) {
2254 int offset = message.arguments().at(0).toInt();
2255 int type = message.arguments().at(1).toUInt();
2256 int startOffset, endOffset;
2257 QString text = interface->textInterface()->textAtOffset(offset, qAccessibleBoundaryTypeFromAtspiBoundaryType(type), &startOffset, &endOffset);
2259 ret << text << startOffset << endOffset;
2260 connection.send(message.createReply(ret));
2261 }
else if (function ==
"GetTextBeforeOffset"_L1) {
2262 int offset = message.arguments().at(0).toInt();
2263 int type = message.arguments().at(1).toUInt();
2264 int startOffset, endOffset;
2265 QString text = interface->textInterface()->textBeforeOffset(offset, qAccessibleBoundaryTypeFromAtspiBoundaryType(type), &startOffset, &endOffset);
2267 ret << text << startOffset << endOffset;
2268 connection.send(message.createReply(ret));
2269 }
else if (function ==
"RemoveSelection"_L1) {
2270 int selectionNum = message.arguments().at(0).toInt();
2271 interface->textInterface()->removeSelection(selectionNum);
2272 sendReply(connection, message,
true);
2273 }
else if (function ==
"SetCaretOffset"_L1) {
2274 int offset = message.arguments().at(0).toInt();
2275 interface->textInterface()->setCursorPosition(offset);
2276 sendReply(connection, message,
true);
2277 }
else if (function ==
"ScrollSubstringTo"_L1) {
2278 int startOffset = message.arguments().at(0).toInt();
2279 int endOffset = message.arguments().at(1).toInt();
2281 qCInfo(lcAccessibilityAtspi) <<
"AtSpiAdaptor::ScrollSubstringTo doesn'take take scroll type into account.";
2282 interface->textInterface()->scrollToSubstring(startOffset, endOffset);
2283 sendReply(connection, message,
true);
2284 }
else if (function ==
"SetSelection"_L1) {
2285 int selectionNum = message.arguments().at(0).toInt();
2286 int startOffset = message.arguments().at(1).toInt();
2287 int endOffset = message.arguments().at(2).toInt();
2288 interface->textInterface()->setSelection(selectionNum, startOffset, endOffset);
2289 sendReply(connection, message,
true);
2291 qCWarning(lcAccessibilityAtspi) <<
"AtSpiAdaptor::textInterface does not implement" << function << message.path();
2297QAccessible::TextBoundaryType AtSpiAdaptor::qAccessibleBoundaryTypeFromAtspiBoundaryType(
int atspiTextBoundaryType)
2299 switch (atspiTextBoundaryType) {
2300 case ATSPI_TEXT_BOUNDARY_CHAR:
2301 return QAccessible::CharBoundary;
2302 case ATSPI_TEXT_BOUNDARY_WORD_START:
2303 case ATSPI_TEXT_BOUNDARY_WORD_END:
2304 return QAccessible::WordBoundary;
2305 case ATSPI_TEXT_BOUNDARY_SENTENCE_START:
2306 case ATSPI_TEXT_BOUNDARY_SENTENCE_END:
2307 return QAccessible::SentenceBoundary;
2308 case ATSPI_TEXT_BOUNDARY_LINE_START:
2309 case ATSPI_TEXT_BOUNDARY_LINE_END:
2310 return QAccessible::LineBoundary;
2312 Q_ASSERT_X(0,
"",
"Requested invalid boundary type.");
2313 return QAccessible::CharBoundary;
2316bool AtSpiAdaptor::isValidAtspiTextGranularity(uint atspiTextGranularity)
2318 if (atspiTextGranularity == ATSPI_TEXT_GRANULARITY_CHAR
2319 || atspiTextGranularity == ATSPI_TEXT_GRANULARITY_WORD
2320 || atspiTextGranularity == ATSPI_TEXT_GRANULARITY_SENTENCE
2321 || atspiTextGranularity == ATSPI_TEXT_GRANULARITY_LINE
2322 || atspiTextGranularity == ATSPI_TEXT_GRANULARITY_PARAGRAPH)
2325 qCWarning(lcAccessibilityAtspi) <<
"Unknown value" << atspiTextGranularity <<
"for AT-SPI text granularity type";
2329QAccessible::TextBoundaryType AtSpiAdaptor::qAccessibleBoundaryTypeFromAtspiTextGranularity(uint atspiTextGranularity)
2331 Q_ASSERT(isValidAtspiTextGranularity(atspiTextGranularity));
2333 switch (atspiTextGranularity) {
2334 case ATSPI_TEXT_GRANULARITY_CHAR:
2335 return QAccessible::CharBoundary;
2336 case ATSPI_TEXT_GRANULARITY_WORD:
2337 return QAccessible::WordBoundary;
2338 case ATSPI_TEXT_GRANULARITY_SENTENCE:
2339 return QAccessible::SentenceBoundary;
2340 case ATSPI_TEXT_GRANULARITY_LINE:
2341 return QAccessible::LineBoundary;
2342 case ATSPI_TEXT_GRANULARITY_PARAGRAPH:
2343 return QAccessible::ParagraphBoundary;
2345 return QAccessible::CharBoundary;
2350 struct AtSpiAttribute {
2353 AtSpiAttribute(
const QString &aName,
const QString &aValue) : name(aName), value(aValue) {}
2354 bool isNull()
const {
return name.isNull() || value.isNull(); }
2357 QString atspiColor(
const QString &ia2Color)
2360 return ia2Color.mid(4, ia2Color.size() - (4+1)).replace(u"\\,"_s, u","_s);
2363 QString atspiSize(
const QString &ia2Size)
2366 return ia2Size.left(ia2Size.size() - 2);
2369 AtSpiAttribute atspiTextAttribute(
const QString &ia2Name,
const QString &ia2Value)
2371 QString name = ia2Name;
2372 QString value = ia2Value;
2381 if (ia2Name ==
"background-color"_L1) {
2382 name = QStringLiteral(
"bg-color");
2383 value = atspiColor(value);
2384 }
else if (ia2Name ==
"font-family"_L1) {
2385 name = QStringLiteral(
"family-name");
2386 }
else if (ia2Name ==
"color"_L1) {
2387 name = QStringLiteral(
"fg-color");
2388 value = atspiColor(value);
2389 }
else if (ia2Name ==
"text-align"_L1) {
2390 name = QStringLiteral(
"justification");
2391 if (value ==
"justify"_L1) {
2392 value = QStringLiteral(
"fill");
2393 }
else if (value !=
"left"_L1 && value !=
"right"_L1 && value !=
"center"_L1) {
2394 qCDebug(lcAccessibilityAtspi) <<
"Unknown text-align attribute value \""
2395 << value <<
"\" cannot be translated to AT-SPI.";
2398 }
else if (ia2Name ==
"font-size"_L1) {
2399 name = QStringLiteral(
"size");
2400 value = atspiSize(value);
2401 }
else if (ia2Name ==
"font-style"_L1) {
2402 name = QStringLiteral(
"style");
2403 if (value !=
"normal"_L1 && value !=
"italic"_L1 && value !=
"oblique"_L1) {
2404 qCDebug(lcAccessibilityAtspi) <<
"Unknown font-style attribute value \"" << value
2405 <<
"\" cannot be translated to AT-SPI.";
2408 }
else if (ia2Name ==
"text-underline-type"_L1) {
2409 name = QStringLiteral(
"underline");
2410 if (value !=
"none"_L1 && value !=
"single"_L1 && value !=
"double"_L1) {
2411 qCDebug(lcAccessibilityAtspi) <<
"Unknown text-underline-type attribute value \""
2412 << value <<
"\" cannot be translated to AT-SPI.";
2415 }
else if (ia2Name ==
"font-weight"_L1) {
2416 name = QStringLiteral(
"weight");
2417 if (value ==
"normal"_L1)
2422 }
else if (((ia2Name ==
"text-line-through-style"_L1 || ia2Name ==
"text-line-through-type"_L1) && (ia2Value !=
"none"_L1))
2423 || (ia2Name ==
"text-line-through-text"_L1 && !ia2Value.isEmpty())) {
2427 name = QStringLiteral(
"strikethrough");
2428 value = QStringLiteral(
"true");
2429 }
else if (ia2Name ==
"text-position"_L1) {
2430 name = QStringLiteral(
"vertical-align");
2431 if (value !=
"baseline"_L1 && value !=
"super"_L1 && value !=
"sub"_L1) {
2432 qCDebug(lcAccessibilityAtspi) <<
"Unknown text-position attribute value \"" << value
2433 <<
"\" cannot be translated to AT-SPI.";
2436 }
else if (ia2Name ==
"writing-mode"_L1) {
2437 name = QStringLiteral(
"direction");
2438 if (value ==
"lr"_L1)
2439 value = QStringLiteral(
"ltr");
2440 else if (value ==
"rl"_L1)
2441 value = QStringLiteral(
"rtl");
2442 else if (value ==
"tb"_L1) {
2444 value = QStringLiteral(
"rtl");
2445 qCDebug(lcAccessibilityAtspi) <<
"writing-mode attribute value \"tb\" translated only w.r.t. horizontal direction; vertical direction ignored";
2447 qCDebug(lcAccessibilityAtspi) <<
"Unknown writing-mode attribute value \"" << value
2448 <<
"\" cannot be translated to AT-SPI.";
2451 }
else if (ia2Name ==
"language"_L1) {
2453 }
else if (ia2Name ==
"invalid"_L1) {
2460 return AtSpiAttribute(name, value);
2464QSpiAttributeSet AtSpiAdaptor::getAttributes(QAccessibleInterface *interface)
2466 QSpiAttributeSet set;
2467 QAccessibleAttributesInterface *attributesIface = interface->attributesInterface();
2468 if (!attributesIface)
2471 const QList<QAccessible::Attribute> attrKeys = attributesIface->attributeKeys();
2472 for (QAccessible::Attribute key : attrKeys) {
2473 const QVariant value = attributesIface->attributeValue(key);
2476 case QAccessible::Attribute::Custom:
2479 Q_ASSERT((value.canConvert<QHash<QString, QString>>()));
2480 const QHash<QString, QString> attrMap = value.value<QHash<QString, QString>>();
2481 for (
auto [name, val] : attrMap.asKeyValueRange())
2482 set.insert(name, val);
2485 case QAccessible::Attribute::Level:
2486 Q_ASSERT(value.canConvert<
int>());
2487 set.insert(QStringLiteral(
"level"), QString::number(value.toInt()));
2497QVariantList AtSpiAdaptor::getAttributes(QAccessibleInterface *interface,
int offset,
2498 bool includeDefaults)
2500 Q_UNUSED(includeDefaults);
2502 QSpiAttributeSet set;
2506 QString joined = interface->textInterface()->attributes(offset, &startOffset, &endOffset);
2507 const QStringList attributes = joined.split(u';', Qt::SkipEmptyParts, Qt::CaseSensitive);
2508 for (
const QString &attr : attributes) {
2509 QStringList items = attr.split(u':', Qt::SkipEmptyParts, Qt::CaseSensitive);
2510 if (items.count() == 2)
2512 AtSpiAttribute attribute = atspiTextAttribute(items[0], items[1]);
2513 if (!attribute.isNull())
2514 set[attribute.name] = attribute.value;
2519 list << QVariant::fromValue(set) << startOffset << endOffset;
2524QString AtSpiAdaptor::getAttributeValue(QAccessibleInterface *interface,
int offset,
2525 const QString &attributeName)
2528 QSpiAttributeSet map;
2532 joined = interface->textInterface()->attributes(offset, &startOffset, &endOffset);
2533 const QStringList attributes = joined.split (u';', Qt::SkipEmptyParts, Qt::CaseSensitive);
2534 for (
const QString& attr : attributes) {
2536 items = attr.split(u':', Qt::SkipEmptyParts, Qt::CaseSensitive);
2537 AtSpiAttribute attribute = atspiTextAttribute(items[0], items[1]);
2538 if (!attribute.isNull())
2539 map[attribute.name] = attribute.value;
2541 return map[attributeName];
2544QList<QVariant> AtSpiAdaptor::getCharacterExtents(QAccessibleInterface *interface,
int offset,
2547 QRect rect = interface->textInterface()->characterRect(offset);
2548 rect = translateFromScreenCoordinates(interface, rect, coordType);
2549 return QList<QVariant>() << rect.x() << rect.y() << rect.width() << rect.height();
2552QList<QVariant> AtSpiAdaptor::getRangeExtents(QAccessibleInterface *interface,
int startOffset,
2553 int endOffset, uint coordType)
2555 if (endOffset == -1)
2556 endOffset = interface->textInterface()->characterCount();
2558 QAccessibleTextInterface *textInterface = interface->textInterface();
2559 if (endOffset <= startOffset || !textInterface)
2560 return QList<QVariant>() << -1 << -1 << 0 << 0;
2562 QRect rect = textInterface->characterRect(startOffset);
2563 for (
int i=startOffset + 1; i <= endOffset; i++)
2564 rect = rect | textInterface->characterRect(i);
2566 rect = translateFromScreenCoordinates(interface, rect, coordType);
2567 return QList<QVariant>() << rect.x() << rect.y() << rect.width() << rect.height();
2570bool AtSpiAdaptor::isValidCoordType(uint coordType)
2572 if (coordType == ATSPI_COORD_TYPE_SCREEN || coordType == ATSPI_COORD_TYPE_WINDOW || coordType == ATSPI_COORD_TYPE_PARENT)
2575 qCWarning(lcAccessibilityAtspi) <<
"Unknown value" << coordType <<
"for AT-SPI coord type";
2579QRect AtSpiAdaptor::translateFromScreenCoordinates(QAccessibleInterface *interface,
const QRect &screenRect, uint targetCoordType)
2581 Q_ASSERT(isValidCoordType(targetCoordType));
2583 QAccessibleInterface *upper =
nullptr;
2584 if (targetCoordType == ATSPI_COORD_TYPE_WINDOW)
2585 upper = getWindow(interface);
2586 else if (targetCoordType == ATSPI_COORD_TYPE_PARENT)
2587 upper = interface->parent();
2589 QRect rect = screenRect;
2591 rect.translate(-upper->rect().x(), -upper->rect().y());
2596QPoint AtSpiAdaptor::translateToScreenCoordinates(QAccessibleInterface *interface,
const QPoint &pos, uint fromCoordType)
2598 Q_ASSERT(isValidCoordType(fromCoordType));
2600 QAccessibleInterface *upper =
nullptr;
2601 if (fromCoordType == ATSPI_COORD_TYPE_WINDOW)
2602 upper = getWindow(interface);
2603 else if (fromCoordType == ATSPI_COORD_TYPE_PARENT)
2604 upper = interface->parent();
2606 QPoint screenPos = pos;
2608 screenPos += upper->rect().topLeft();
2614static QString textForRange(QAccessibleInterface *accessible,
int startOffset,
int endOffset)
2616 if (QAccessibleTextInterface *textIface = accessible->textInterface()) {
2617 if (endOffset == -1)
2618 endOffset = textIface->characterCount();
2619 return textIface->text(startOffset, endOffset);
2621 QString txt = accessible->text(QAccessible::Value);
2622 if (endOffset == -1)
2623 endOffset = txt.size();
2624 return txt.mid(startOffset, endOffset - startOffset);
2627static void replaceTextFallback(QAccessibleInterface *accessible,
long startOffset,
long endOffset,
const QString &txt)
2629 QString t = textForRange(accessible, 0, -1);
2630 if (endOffset == -1)
2631 endOffset = t.size();
2632 if (endOffset - startOffset == 0)
2633 t.insert(startOffset, txt);
2635 t.replace(startOffset, endOffset - startOffset, txt);
2636 accessible->setText(QAccessible::Value, t);
2639bool AtSpiAdaptor::editableTextInterface(QAccessibleInterface *interface,
const QString &function,
const QDBusMessage &message,
const QDBusConnection &connection)
2641 if (function ==
"CopyText"_L1) {
2642#ifndef QT_NO_CLIPBOARD
2643 int startOffset = message.arguments().at(0).toInt();
2644 int endOffset = message.arguments().at(1).toInt();
2645 const QString t = textForRange(interface, startOffset, endOffset);
2646 QGuiApplication::clipboard()->setText(t);
2648 connection.send(message.createReply(
true));
2649 }
else if (function ==
"CutText"_L1) {
2650#ifndef QT_NO_CLIPBOARD
2651 int startOffset = message.arguments().at(0).toInt();
2652 int endOffset = message.arguments().at(1).toInt();
2653 const QString t = textForRange(interface, startOffset, endOffset);
2654 if (QAccessibleEditableTextInterface *editableTextIface = interface->editableTextInterface())
2655 editableTextIface->deleteText(startOffset, endOffset);
2657 replaceTextFallback(interface, startOffset, endOffset, QString());
2658 QGuiApplication::clipboard()->setText(t);
2660 connection.send(message.createReply(
true));
2661 }
else if (function ==
"DeleteText"_L1) {
2662 int startOffset = message.arguments().at(0).toInt();
2663 int endOffset = message.arguments().at(1).toInt();
2664 if (QAccessibleEditableTextInterface *editableTextIface = interface->editableTextInterface())
2665 editableTextIface->deleteText(startOffset, endOffset);
2667 replaceTextFallback(interface, startOffset, endOffset, QString());
2668 connection.send(message.createReply(
true));
2669 }
else if (function ==
"InsertText"_L1) {
2670 int position = message.arguments().at(0).toInt();
2671 QString text = message.arguments().at(1).toString();
2672 int length = message.arguments().at(2).toInt();
2673 text.resize(length);
2674 if (QAccessibleEditableTextInterface *editableTextIface = interface->editableTextInterface())
2675 editableTextIface->insertText(position, text);
2677 replaceTextFallback(interface, position, position, text);
2678 connection.send(message.createReply(
true));
2679 }
else if (function ==
"PasteText"_L1) {
2680#ifndef QT_NO_CLIPBOARD
2681 int position = message.arguments().at(0).toInt();
2682 const QString txt = QGuiApplication::clipboard()->text();
2683 if (QAccessibleEditableTextInterface *editableTextIface = interface->editableTextInterface())
2684 editableTextIface->insertText(position, txt);
2686 replaceTextFallback(interface, position, position, txt);
2688 connection.send(message.createReply(
true));
2689 }
else if (function ==
"SetTextContents"_L1) {
2690 QString newContents = message.arguments().at(0).toString();
2691 if (QAccessibleEditableTextInterface *editableTextIface = interface->editableTextInterface())
2692 editableTextIface->replaceText(0, interface->textInterface()->characterCount(), newContents);
2694 replaceTextFallback(interface, 0, -1, newContents);
2695 connection.send(message.createReply(
true));
2696 }
else if (function.isEmpty()) {
2697 connection.send(message.createReply());
2699 qCWarning(lcAccessibilityAtspi) <<
"AtSpiAdaptor::editableTextInterface does not implement" << function << message.path();
2706bool AtSpiAdaptor::valueInterface(QAccessibleInterface *interface,
const QString &function,
const QDBusMessage &message,
const QDBusConnection &connection)
2708 QAccessibleValueInterface *valueIface = interface->valueInterface();
2712 if (function ==
"SetCurrentValue"_L1) {
2713 QDBusVariant v = qvariant_cast<QDBusVariant>(message.arguments().at(2));
2714 double value = v.variant().toDouble();
2717 valueIface->setCurrentValue(value);
2718 connection.send(message.createReply());
2721 if (function ==
"GetCurrentValue"_L1)
2722 value = valueIface->currentValue();
2723 else if (function ==
"GetMaximumValue"_L1)
2724 value = valueIface->maximumValue();
2725 else if (function ==
"GetMinimumIncrement"_L1)
2726 value = valueIface->minimumStepSize();
2727 else if (function ==
"GetMinimumValue"_L1)
2728 value = valueIface->minimumValue();
2730 qCWarning(lcAccessibilityAtspi) <<
"AtSpiAdaptor::valueInterface does not implement" << function << message.path();
2733 if (!value.canConvert<
double>()) {
2734 qCWarning(lcAccessibilityAtspi) <<
"AtSpiAdaptor::valueInterface: Could not convert to double:" << function;
2739 connection.send(message.createReply(
2740 QVariant::fromValue(QDBusVariant(QVariant::fromValue(value.toDouble())))));
2746bool AtSpiAdaptor::selectionInterface(QAccessibleInterface *interface,
const QString &function,
const QDBusMessage &message,
const QDBusConnection &connection)
2748 QAccessibleSelectionInterface* selectionInterface = interface->selectionInterface();
2749 if (!selectionInterface) {
2750 qCWarning(lcAccessibilityAtspi) <<
"Could not find selection interface for: " << message.path() << interface;
2754 if (function ==
"ClearSelection"_L1 ) {
2755 connection.send(message.createReply(QVariant::fromValue((selectionInterface->clear()))));
2756 }
else if (function ==
"DeselectChild"_L1 ) {
2757 int childIndex = message.arguments().at(0).toInt();
2759 QAccessibleInterface *child = interface->child(childIndex);
2761 ret = selectionInterface->unselect(child);
2762 connection.send(message.createReply(QVariant::fromValue(ret)));
2763 }
else if (function ==
"DeselectSelectedChild"_L1 ) {
2764 int selectionIndex = message.arguments().at(0).toInt();
2766 QAccessibleInterface *selectedChild = selectionInterface->selectedItem(selectionIndex);
2768 ret = selectionInterface->unselect(selectedChild);
2769 connection.send(message.createReply(QVariant::fromValue(ret)));
2770 }
else if (function ==
"GetNSelectedChildren"_L1) {
2771 connection.send(message.createReply(QVariant::fromValue(QDBusVariant(
2772 QVariant::fromValue(selectionInterface->selectedItemCount())))));
2773 }
else if (function ==
"GetSelectedChild"_L1) {
2774 int selectionIndex = message.arguments().at(0).toInt();
2775 QSpiObjectReference ref(connection, QDBusObjectPath(pathForInterface(selectionInterface->selectedItem(selectionIndex))));
2776 connection.send(message.createReply(QVariant::fromValue(ref)));
2777 }
else if (function ==
"IsChildSelected"_L1 ) {
2778 int childIndex = message.arguments().at(0).toInt();
2780 QAccessibleInterface *child = interface->child(childIndex);
2782 ret = selectionInterface->isSelected(child);
2783 connection.send(message.createReply(QVariant::fromValue(ret)));
2784 }
else if (function ==
"SelectAll"_L1 ) {
2785 connection.send(message.createReply(QVariant::fromValue(selectionInterface->selectAll())));
2786 }
else if (function ==
"SelectChild"_L1 ) {
2787 int childIndex = message.arguments().at(0).toInt();
2789 QAccessibleInterface *child = interface->child(childIndex);
2791 ret = selectionInterface->select(child);
2792 connection.send(message.createReply(QVariant::fromValue(ret)));
2794 qCWarning(lcAccessibilityAtspi) <<
"AtSpiAdaptor::selectionInterface does not implement " << function << message.path();
2803bool AtSpiAdaptor::tableInterface(QAccessibleInterface *interface,
const QString &function,
const QDBusMessage &message,
const QDBusConnection &connection)
2805 if (!(interface->tableInterface() || interface->tableCellInterface())) {
2806 qCWarning(lcAccessibilityAtspi) <<
"Qt AtSpiAdaptor: Could not find table interface for:" << message.path() << interface;
2810 if (function ==
"GetCaption"_L1) {
2811 QAccessibleInterface * captionInterface= interface->tableInterface()->caption();
2812 if (captionInterface) {
2813 QSpiObjectReference ref = QSpiObjectReference(connection, QDBusObjectPath(pathForInterface(captionInterface)));
2814 sendReply(connection, message, QVariant::fromValue(QDBusVariant(QVariant::fromValue(ref))));
2816 sendReply(connection, message, QVariant::fromValue(QDBusVariant(QVariant::fromValue(
2817 QSpiObjectReference(connection, QDBusObjectPath(ATSPI_DBUS_PATH_NULL))))));
2819 }
else if (function ==
"GetNColumns"_L1) {
2820 connection.send(message.createReply(QVariant::fromValue(QDBusVariant(
2821 QVariant::fromValue(interface->tableInterface()->columnCount())))));
2822 }
else if (function ==
"GetNRows"_L1) {
2823 connection.send(message.createReply(QVariant::fromValue(QDBusVariant(
2824 QVariant::fromValue(interface->tableInterface()->rowCount())))));
2825 }
else if (function ==
"GetNSelectedColumns"_L1) {
2826 connection.send(message.createReply(QVariant::fromValue(QDBusVariant(
2827 QVariant::fromValue(interface->tableInterface()->selectedColumnCount())))));
2828 }
else if (function ==
"GetNSelectedRows"_L1) {
2829 connection.send(message.createReply(QVariant::fromValue(QDBusVariant(
2830 QVariant::fromValue(interface->tableInterface()->selectedRowCount())))));
2831 }
else if (function ==
"GetSummary"_L1) {
2832 QAccessibleInterface *summary = interface->tableInterface() ? interface->tableInterface()->summary() :
nullptr;
2833 QSpiObjectReference ref(connection, QDBusObjectPath(pathForInterface(summary)));
2834 connection.send(message.createReply(QVariant::fromValue(QDBusVariant(QVariant::fromValue(ref)))));
2835 }
else if (function ==
"GetAccessibleAt"_L1) {
2836 int row = message.arguments().at(0).toInt();
2837 int column = message.arguments().at(1).toInt();
2840 (row >= interface->tableInterface()->rowCount()) ||
2841 (column >= interface->tableInterface()->columnCount())) {
2842 qCWarning(lcAccessibilityAtspi) <<
"Invalid index for tableInterface GetAccessibleAt (" << row <<
"," << column <<
')';
2846 QSpiObjectReference ref;
2847 QAccessibleInterface * cell(interface->tableInterface()->cellAt(row, column));
2849 ref = QSpiObjectReference(connection, QDBusObjectPath(pathForInterface(cell)));
2851 qCWarning(lcAccessibilityAtspi) <<
"No cell interface returned for" << interface->object() << row << column;
2852 ref = QSpiObjectReference();
2854 connection.send(message.createReply(QVariant::fromValue(ref)));
2856 }
else if (function ==
"GetIndexAt"_L1) {
2857 int row = message.arguments().at(0).toInt();
2858 int column = message.arguments().at(1).toInt();
2859 QAccessibleInterface *cell = interface->tableInterface()->cellAt(row, column);
2861 qCWarning(lcAccessibilityAtspi) <<
"AtSpiAdaptor::GetIndexAt(" << row <<
',' << column <<
") did not find a cell." << interface;
2864 int index = interface->indexOfChild(cell);
2865 qCDebug(lcAccessibilityAtspi) <<
"QSpiAdaptor::GetIndexAt row:" << row <<
" col:" << column <<
" logical index:" << index;
2866 Q_ASSERT(index > 0);
2867 connection.send(message.createReply(index));
2868 }
else if ((function ==
"GetColumnAtIndex"_L1) || (function ==
"GetRowAtIndex"_L1)) {
2869 int index = message.arguments().at(0).toInt();
2872 QAccessibleInterface * cell = interface->child(index);
2874 if (function ==
"GetColumnAtIndex"_L1) {
2875 if (cell->role() == QAccessible::ColumnHeader) {
2877 }
else if (cell->role() == QAccessible::RowHeader) {
2880 if (!cell->tableCellInterface()) {
2881 qCWarning(lcAccessibilityAtspi).nospace() <<
"AtSpiAdaptor::" << function <<
" No table cell interface: " << cell;
2884 ret = cell->tableCellInterface()->columnIndex();
2887 if (cell->role() == QAccessible::ColumnHeader) {
2889 }
else if (cell->role() == QAccessible::RowHeader) {
2890 ret = index % interface->tableInterface()->columnCount();
2892 if (!cell->tableCellInterface()) {
2893 qCWarning(lcAccessibilityAtspi).nospace() <<
"AtSpiAdaptor::" << function <<
" No table cell interface: " << cell;
2896 ret = cell->tableCellInterface()->rowIndex();
2900 qCWarning(lcAccessibilityAtspi).nospace() <<
"AtSpiAdaptor::" << function <<
" No cell at index: " << index <<
" " << interface;
2904 connection.send(message.createReply(ret));
2906 }
else if (function ==
"GetColumnDescription"_L1) {
2907 int column = message.arguments().at(0).toInt();
2908 connection.send(message.createReply(interface->tableInterface()->columnDescription(column)));
2909 }
else if (function ==
"GetRowDescription"_L1) {
2910 int row = message.arguments().at(0).toInt();
2911 connection.send(message.createReply(interface->tableInterface()->rowDescription(row)));
2915 }
else if (function ==
"GetRowColumnExtentsAtIndex"_L1) {
2916 int index = message.arguments().at(0).toInt();
2917 bool success =
false;
2921 int rowExtents = -1;
2922 int colExtents = -1;
2923 bool isSelected =
false;
2925 int cols = interface->tableInterface()->columnCount();
2929 if (QAccessibleInterface *cell = interface->tableInterface()->cellAt(row, col)) {
2930 if (QAccessibleTableCellInterface *cellIface = cell->tableCellInterface()) {
2931 row = cellIface->rowIndex();
2932 col = cellIface->columnIndex();
2933 rowExtents = cellIface->rowExtent();
2934 colExtents = cellIface->columnExtent();
2935 isSelected = cellIface->isSelected();
2941 list << success << row << col << rowExtents << colExtents << isSelected;
2942 connection.send(message.createReply(list));
2944 }
else if (function ==
"GetColumnExtentAt"_L1) {
2945 int row = message.arguments().at(0).toInt();
2946 int column = message.arguments().at(1).toInt();
2947 int columnExtent = 0;
2948 if (QAccessibleInterface *cell = interface->tableInterface()->cellAt(row, column)) {
2949 if (QAccessibleTableCellInterface *cellIface = cell->tableCellInterface())
2950 columnExtent = cellIface->columnExtent();
2952 connection.send(message.createReply(columnExtent));
2954 }
else if (function ==
"GetRowExtentAt"_L1) {
2955 int row = message.arguments().at(0).toInt();
2956 int column = message.arguments().at(1).toInt();
2958 if (QAccessibleInterface *cell = interface->tableInterface()->cellAt(row, column)) {
2959 if (QAccessibleTableCellInterface *cellIface = cell->tableCellInterface())
2960 rowExtent = cellIface->rowExtent();
2962 connection.send(message.createReply(rowExtent));
2964 }
else if (function ==
"GetColumnHeader"_L1) {
2965 int column = message.arguments().at(0).toInt();
2966 QSpiObjectReference ref;
2968 QAccessibleInterface * cell(interface->tableInterface()->cellAt(0, column));
2969 if (cell && cell->tableCellInterface()) {
2970 QList<QAccessibleInterface*> header = cell->tableCellInterface()->columnHeaderCells();
2971 if (header.size() > 0) {
2972 ref = QSpiObjectReference(connection, QDBusObjectPath(pathForInterface(header.takeAt(0))));
2975 connection.send(message.createReply(QVariant::fromValue(ref)));
2977 }
else if (function ==
"GetRowHeader"_L1) {
2978 int row = message.arguments().at(0).toInt();
2979 QSpiObjectReference ref;
2980 QAccessibleInterface *cell = interface->tableInterface()->cellAt(row, 0);
2981 if (cell && cell->tableCellInterface()) {
2982 QList<QAccessibleInterface*> header = cell->tableCellInterface()->rowHeaderCells();
2983 if (header.size() > 0) {
2984 ref = QSpiObjectReference(connection, QDBusObjectPath(pathForInterface(header.takeAt(0))));
2987 connection.send(message.createReply(QVariant::fromValue(ref)));
2989 }
else if (function ==
"GetSelectedColumns"_L1) {
2990 connection.send(message.createReply(QVariant::fromValue(interface->tableInterface()->selectedColumns())));
2991 }
else if (function ==
"GetSelectedRows"_L1) {
2992 connection.send(message.createReply(QVariant::fromValue(interface->tableInterface()->selectedRows())));
2993 }
else if (function ==
"IsColumnSelected"_L1) {
2994 int column = message.arguments().at(0).toInt();
2995 connection.send(message.createReply(interface->tableInterface()->isColumnSelected(column)));
2996 }
else if (function ==
"IsRowSelected"_L1) {
2997 int row = message.arguments().at(0).toInt();
2998 connection.send(message.createReply(interface->tableInterface()->isRowSelected(row)));
2999 }
else if (function ==
"IsSelected"_L1) {
3000 int row = message.arguments().at(0).toInt();
3001 int column = message.arguments().at(1).toInt();
3002 bool selected =
false;
3003 if (QAccessibleInterface* cell = interface->tableInterface()->cellAt(row, column)) {
3004 if (QAccessibleTableCellInterface *cellIface = cell->tableCellInterface())
3005 selected = cellIface->isSelected();
3007 connection.send(message.createReply(selected));
3008 }
else if (function ==
"AddColumnSelection"_L1) {
3009 int column = message.arguments().at(0).toInt();
3010 connection.send(message.createReply(interface->tableInterface()->selectColumn(column)));
3011 }
else if (function ==
"AddRowSelection"_L1) {
3012 int row = message.arguments().at(0).toInt();
3013 connection.send(message.createReply(interface->tableInterface()->selectRow(row)));
3014 }
else if (function ==
"RemoveColumnSelection"_L1) {
3015 int column = message.arguments().at(0).toInt();
3016 connection.send(message.createReply(interface->tableInterface()->unselectColumn(column)));
3017 }
else if (function ==
"RemoveRowSelection"_L1) {
3018 int row = message.arguments().at(0).toInt();
3019 connection.send(message.createReply(interface->tableInterface()->unselectRow(row)));
3021 qCWarning(lcAccessibilityAtspi) <<
"AtSpiAdaptor::tableInterface does not implement" << function << message.path();
3028bool AtSpiAdaptor::tableCellInterface(QAccessibleInterface *interface,
const QString &function,
const QDBusMessage &message,
const QDBusConnection &connection)
3030 QAccessibleTableCellInterface* cellInterface = interface->tableCellInterface();
3031 if (!cellInterface) {
3032 qCWarning(lcAccessibilityAtspi) <<
"Could not find table cell interface for: " << message.path() << interface;
3036 if (function ==
"GetColumnHeaderCells"_L1) {
3037 QSpiObjectReferenceArray headerCells;
3038 const auto headerCellInterfaces = cellInterface->columnHeaderCells();
3039 headerCells.reserve(headerCellInterfaces.size());
3040 for (QAccessibleInterface *cell : headerCellInterfaces) {
3041 const QString childPath = pathForInterface(cell);
3042 const QSpiObjectReference ref(connection, QDBusObjectPath(childPath));
3045 connection.send(message.createReply(QVariant::fromValue(headerCells)));
3046 }
else if (function ==
"GetColumnSpan"_L1) {
3047 connection.send(message.createReply(QVariant::fromValue(QDBusVariant(
3048 QVariant::fromValue(cellInterface->columnExtent())))));
3049 }
else if (function ==
"GetPosition"_L1) {
3050 const int row = cellInterface->rowIndex();
3051 const int column = cellInterface->columnIndex();
3052 connection.send(message.createReply(QVariant::fromValue(QDBusVariant(
3053 QVariant::fromValue(QPoint(row, column))))));
3054 }
else if (function ==
"GetRowHeaderCells"_L1) {
3055 QSpiObjectReferenceArray headerCells;
3056 const auto headerCellInterfaces = cellInterface->rowHeaderCells();
3057 headerCells.reserve(headerCellInterfaces.size());
3058 for (QAccessibleInterface *cell : headerCellInterfaces) {
3059 const QString childPath = pathForInterface(cell);
3060 const QSpiObjectReference ref(connection, QDBusObjectPath(childPath));
3063 connection.send(message.createReply(QVariant::fromValue(headerCells)));
3064 }
else if (function ==
"GetRowSpan"_L1) {
3065 connection.send(message.createReply(QVariant::fromValue(QDBusVariant(
3066 QVariant::fromValue(cellInterface->rowExtent())))));
3067 }
else if (function ==
"GetRowColumnSpan"_L1) {
3069 list << cellInterface->rowIndex() << cellInterface->columnIndex() << cellInterface->rowExtent() << cellInterface->columnExtent();
3070 connection.send(message.createReply(list));
3071 }
else if (function ==
"GetTable"_L1) {
3072 QSpiObjectReference ref;
3073 QAccessibleInterface* table = cellInterface->table();
3074 if (table && table->tableInterface())
3075 ref = QSpiObjectReference(connection, QDBusObjectPath(pathForInterface(table)));
3076 connection.send(message.createReply(QVariant::fromValue(QDBusVariant(QVariant::fromValue(ref)))));
3078 qCWarning(lcAccessibilityAtspi) <<
"AtSpiAdaptor::tableCellInterface does not implement" << function << message.path();
3087#include "moc_atspiadaptor_p.cpp"