Skip to content

interface_view: Skip updating text that's already up-to-date

Accerciser allows to update the text of an a11y object via the EditableText AT-SPI interface by typing in the GtkTextView displaying the current text in the "Text" section of the interface view.

This triggers the corresponding object:text-changed events in the application, which is again processed by Accerciser.

Since the text in the text view already gets updated when modifying the text there, it should not be modified again when those events are retrieved. There is a mechanism to skip the expected events (s. self.outgoing_calls) that works when the application sends object:text-changed events that directly match the call on the corresponding method of the EditableText interface in Accerciser. (E.g. if EditableText.deleteText(1, 5) gets called, an object:text-changed:delete event with the same indices received for the same object shortly afterwards is ignored.)

This seems to work well for Gtk widgets.

However, Qt widgets don't generally do that, but e.g. the QWidgetLineControl sends an object:text-changed:delete for the whole previous text and then an object:text-changed:insert event with the whole new text if both are non-empty. (s. https://code.qt.io/cgit/qt/qtbase.git/tree/src/widgets/widgets/qwidgetlinecontrol.cpp?id=5093e517b924074ab6e63658c87237be315a17e6#n731 )

This resulted in the event being processed and the text update was applied in the text view on top of the manual change, resulting in duplicate changes and the text there no longer matching the actual text in the a11y object for which the text was modified.

To prevent cases like this, first check whether the current text of the a11y object and the current text in the text view already match, and skip processing the event in that case as well.

Screencast demonstrating the behavior with the Qt sample application (qtbase/examples/network/network-chat/network-chat).

Without the change in place:

2023-09-29_screencast_accerciser_qt_text_update_unmodified_master

With the change in place:

2023-09-29_screencast_accerciser_qt_text_update_with_change_in_place

Merge request reports