[gtk/gtk-4-2: 55/91] a11y: Emit window:activate event




commit 5fc008024b50184ef6b1062ea0ca91fe8a018c62
Author: Emmanuele Bassi <ebassi gnome org>
Date:   Tue Apr 20 17:24:13 2021 +0100

    a11y: Emit window:activate event
    
    Orca uses the window:activate event type to track top levels, and avoid
    being spammed by events coming from non-focused windows.

 gtk/a11y/gtkatspicontext.c | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)
---
diff --git a/gtk/a11y/gtkatspicontext.c b/gtk/a11y/gtkatspicontext.c
index aa7d355c92..8a8a46d2c6 100644
--- a/gtk/a11y/gtkatspicontext.c
+++ b/gtk/a11y/gtkatspicontext.c
@@ -878,6 +878,22 @@ emit_focus (GtkAtSpiContext *self,
                                    NULL);
 }
 
+static void
+emit_window_activate (GtkAtSpiContext *self)
+{
+  if (self->connection == NULL)
+    return;
+
+  g_dbus_connection_emit_signal (self->connection,
+                                 NULL,
+                                 self->context_path,
+                                 "org.a11y.atspi.Event.Window",
+                                 "activate",
+                                 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,
@@ -1113,6 +1129,9 @@ gtk_at_spi_context_platform_change (GtkATContext                *ctx,
       gboolean state = gtk_accessible_get_platform_state (GTK_ACCESSIBLE (widget),
                                                           GTK_ACCESSIBLE_PLATFORM_STATE_ACTIVE);
       emit_state_changed (self, "active", state);
+
+      if (gtk_accessible_get_accessible_role (accessible) == GTK_ACCESSIBLE_ROLE_WINDOW && state)
+        emit_window_activate (self);
     }
 }
 


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