From c1e68f6044a9242e359d2f0c9cf41db05a87f235 Mon Sep 17 00:00:00 2001 From: Matthias Clasen Date: Mon, 19 Apr 2021 21:29:17 -0400 Subject: [PATCH] a11y: Emit focus events Orca relies on these to keep track of the focus location, ignoring the focused state. With this change, orca can once again speak text in entries as I type. --- gtk/a11y/gtkatspicontext.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/gtk/a11y/gtkatspicontext.c b/gtk/a11y/gtkatspicontext.c index a5e6727aab..aa7d355c92 100644 --- a/gtk/a11y/gtkatspicontext.c +++ b/gtk/a11y/gtkatspicontext.c @@ -860,6 +860,24 @@ emit_children_changed (GtkAtSpiContext *self, context_ref); } +static void +emit_focus (GtkAtSpiContext *self, + gboolean focus_in) +{ + if (self->connection == NULL) + return; + + if (focus_in) + g_dbus_connection_emit_signal (self->connection, + NULL, + self->context_path, + "org.a11y.atspi.Event.Focus", + "Focus", + g_variant_new ("(siiva{sv})", + "", 0, 0, g_variant_new_string ("0"), NULL), + NULL); +} + static void gtk_at_spi_context_state_change (GtkATContext *ctx, GtkAccessibleStateChange changed_states, @@ -1087,6 +1105,7 @@ gtk_at_spi_context_platform_change (GtkATContext *ctx, gboolean state = gtk_accessible_get_platform_state (GTK_ACCESSIBLE (widget), GTK_ACCESSIBLE_PLATFORM_STATE_FOCUSED); emit_state_changed (self, "focused", state); + emit_focus (self, state); } if (changed_platform & GTK_ACCESSIBLE_PLATFORM_CHANGE_ACTIVE)