[gtk/a11y-debug] a11y: Emit focus events



commit ae83b799848c45632a713477a38b36e940982488
Author: Matthias Clasen <mclasen redhat com>
Date:   Mon Apr 19 21:29:17 2021 -0400

    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 9891a4da69..c15c4d37b9 100644
--- a/gtk/a11y/gtkatspicontext.c
+++ b/gtk/a11y/gtkatspicontext.c
@@ -864,6 +864,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,
@@ -1091,6 +1109,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)


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]