[gtk/a11y-debug: 9/11] a11y: Add the root object to the cache




commit 9fbd11e1be721953758b6154178d03d04bbfe54b
Author: Matthias Clasen <mclasen redhat com>
Date:   Sat Apr 17 15:21:41 2021 -0400

    a11y: Add the root object to the cache
    
    Not 100% sure this is necessary, but maybe it helps
    to get orca up to speed.

 gtk/a11y/gtkatspicache.c        | 54 +++++++++++++++++++++++++++++++++++++----
 gtk/a11y/gtkatspicacheprivate.h |  3 ++-
 gtk/a11y/gtkatspiroot.c         |  2 +-
 3 files changed, 52 insertions(+), 7 deletions(-)
---
diff --git a/gtk/a11y/gtkatspicache.c b/gtk/a11y/gtkatspicache.c
index 9e3b22b281..6e85c5663f 100644
--- a/gtk/a11y/gtkatspicache.c
+++ b/gtk/a11y/gtkatspicache.c
@@ -27,6 +27,8 @@
 #include "gtkatspiutilsprivate.h"
 #include "gtkdebug.h"
 
+#include "a11y/atspi/atspi-accessible.h"
+#include "a11y/atspi/atspi-application.h"
 #include "a11y/atspi/atspi-cache.h"
 
 /* Cached item:
@@ -61,6 +63,8 @@ struct _GtkAtSpiCache
 
   /* Re-entrancy guard */
   gboolean in_get_items;
+
+  GtkAtSpiRoot *root;
 };
 
 enum
@@ -144,6 +148,36 @@ collect_object (GtkAtSpiCache   *self,
   g_variant_builder_add (builder, "@au", gtk_at_spi_context_get_states (context));
 }
 
+static void
+collect_root (GtkAtSpiCache   *self,
+              GVariantBuilder *builder)
+{
+  g_variant_builder_add (builder, "@(so)", gtk_at_spi_root_to_ref (self->root));
+  g_variant_builder_add (builder, "@(so)", gtk_at_spi_root_to_ref (self->root));
+
+  g_variant_builder_add (builder, "@(so)", gtk_at_spi_null_ref ());
+
+  g_variant_builder_add (builder, "i", -1);
+  g_variant_builder_add (builder, "i", 0);
+
+  GVariantBuilder interfaces = G_VARIANT_BUILDER_INIT (G_VARIANT_TYPE ("as"));
+
+  g_variant_builder_add (&interfaces, "s", atspi_accessible_interface.name);
+  g_variant_builder_add (&interfaces, "s", atspi_application_interface.name);
+  g_variant_builder_add (builder, "@as", g_variant_builder_end (&interfaces));
+
+  g_variant_builder_add (builder, "s", g_get_prgname () ? g_get_prgname () : "Unnamed");
+
+  g_variant_builder_add (builder, "u", ATSPI_ROLE_APPLICATION);
+
+  g_variant_builder_add (builder, "s", g_get_application_name () ? g_get_application_name () : "No 
description");
+
+  GVariantBuilder states = G_VARIANT_BUILDER_INIT (G_VARIANT_TYPE ("au"));
+  g_variant_builder_add (&states, "u", 0);
+  g_variant_builder_add (&states, "u", 0);
+  g_variant_builder_add (builder, "@au", g_variant_builder_end (&states));
+}
+
 static void
 collect_cached_objects (GtkAtSpiCache   *self,
                         GVariantBuilder *builder)
@@ -160,6 +194,10 @@ collect_cached_objects (GtkAtSpiCache   *self,
   while (g_hash_table_iter_next (&iter, &key_p, &value_p))
     g_hash_table_add (collection, value_p);
 
+  g_variant_builder_open (builder, G_VARIANT_TYPE ("(" ITEM_SIGNATURE ")"));
+  collect_root (self, builder);
+  g_variant_builder_close (builder);
+
   g_hash_table_iter_init (&iter, collection);
   while (g_hash_table_iter_next (&iter, &key_p, &value_p))
     {
@@ -355,15 +393,21 @@ gtk_at_spi_cache_init (GtkAtSpiCache *self)
 
 GtkAtSpiCache *
 gtk_at_spi_cache_new (GDBusConnection *connection,
-                      const char *cache_path)
+                      const char      *cache_path,
+                      GtkAtSpiRoot    *root)
 {
+  GtkAtSpiCache *cache;
+
   g_return_val_if_fail (G_IS_DBUS_CONNECTION (connection), NULL);
   g_return_val_if_fail (cache_path != NULL, NULL);
 
-  return g_object_new (GTK_TYPE_AT_SPI_CACHE,
-                       "connection", connection,
-                       "cache-path", cache_path,
-                       NULL);
+  cache = g_object_new (GTK_TYPE_AT_SPI_CACHE,
+                        "connection", connection,
+                        "cache-path", cache_path,
+                        NULL);
+  cache->root = root;
+
+  return cache;
 }
 
 void
diff --git a/gtk/a11y/gtkatspicacheprivate.h b/gtk/a11y/gtkatspicacheprivate.h
index 63f797ce5a..85fecdcd5c 100644
--- a/gtk/a11y/gtkatspicacheprivate.h
+++ b/gtk/a11y/gtkatspicacheprivate.h
@@ -31,7 +31,8 @@ G_DECLARE_FINAL_TYPE (GtkAtSpiCache, gtk_at_spi_cache, GTK, AT_SPI_CACHE, GObjec
 
 GtkAtSpiCache *
 gtk_at_spi_cache_new (GDBusConnection *connection,
-                      const char *cache_path);
+                      const char      *cache_path,
+                      GtkAtSpiRoot    *root);
 
 void
 gtk_at_spi_cache_add_context (GtkAtSpiCache *self,
diff --git a/gtk/a11y/gtkatspiroot.c b/gtk/a11y/gtkatspiroot.c
index 0b3e5044d4..1deafba927 100644
--- a/gtk/a11y/gtkatspiroot.c
+++ b/gtk/a11y/gtkatspiroot.c
@@ -503,7 +503,7 @@ on_registration_reply (GObject      *gobject,
     }
 
   /* Register the cache object */
-  self->cache = gtk_at_spi_cache_new (self->connection, ATSPI_CACHE_PATH);
+  self->cache = gtk_at_spi_cache_new (self->connection, ATSPI_CACHE_PATH, self);
 
   /* Drain the list of queued GtkAtSpiContexts, and add them to the cache */
   if (self->queued_contexts != NULL)


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