a11y: Avoid spurious selection changed events

Only send selection-changed events when we either
had a non-empty selection before, or have one now.

This should help orca speak the right things, and
not the wrong things.

Related: #3549
This commit is contained in:
Matthias Clasen 2021-04-20 13:23:56 -04:00
parent 639932ad8a
commit b97d0a3940

View File

@ -1326,9 +1326,12 @@ update_selection (TextChanged *changed,
int selection_bound)
{
gboolean caret_moved, bound_moved;
gboolean had_selection, has_selection;
caret_moved = cursor_position != changed->cursor_position;
bound_moved = selection_bound != changed->selection_bound;
had_selection = changed->cursor_position != changed->selection_bound;
has_selection = cursor_position != selection_bound;
if (!caret_moved && !bound_moved)
return;
@ -1339,7 +1342,7 @@ update_selection (TextChanged *changed,
if (caret_moved)
changed->selection_changed (changed->data, "text-caret-moved", changed->cursor_position);
if (caret_moved || bound_moved)
if (had_selection || has_selection)
changed->selection_changed (changed->data, "text-selection-changed", 0);
}