diff options
author | Emmanuele Bassi <ebassi@gmail.com> | 2020-11-19 16:37:58 +0000 |
---|---|---|
committer | Emmanuele Bassi <ebassi@gmail.com> | 2020-11-19 16:37:58 +0000 |
commit | 8482b956d697e74d62a968586e7a7a3c7ed03ec6 (patch) | |
tree | 49f4eb180886e4ddfba10ff8f49beef712f09106 | |
parent | 562c7b1ff35e3813b5290cec53118cd8a82b5bd3 (diff) | |
parent | a4c3bee4a12c8cda983a87018dae79100c161bda (diff) | |
download | gtk+-8482b956d697e74d62a968586e7a7a3c7ed03ec6.tar.gz |
Merge branch 'ebassi/for-master' into 'master'
Ebassi/for master
See merge request GNOME/gtk!2867
-rw-r--r-- | demos/gtk-demo/gtkfishbowl.c | 5 | ||||
-rw-r--r-- | gtk/a11y/gtkatspicache.c | 68 | ||||
-rw-r--r-- | gtk/a11y/gtkatspiroot.c | 9 | ||||
-rw-r--r-- | gtk/gtkaccessible.c | 6 |
4 files changed, 49 insertions, 39 deletions
diff --git a/demos/gtk-demo/gtkfishbowl.c b/demos/gtk-demo/gtkfishbowl.c index dd33486e15..e0ee9037e6 100644 --- a/demos/gtk-demo/gtkfishbowl.c +++ b/demos/gtk-demo/gtkfishbowl.c @@ -179,6 +179,9 @@ gtk_fishbowl_add (GtkFishbowl *fishbowl, child_info->dy = new_speed (); gtk_widget_set_parent (widget, GTK_WIDGET (fishbowl)); + gtk_accessible_update_state (GTK_ACCESSIBLE (widget), + GTK_ACCESSIBLE_STATE_HIDDEN, TRUE, + -1); g_hash_table_insert (priv->children, widget, child_info); priv->count++; @@ -342,6 +345,8 @@ gtk_fishbowl_class_init (GtkFishbowlClass *klass) G_PARAM_READWRITE); g_object_class_install_properties (object_class, NUM_PROPERTIES, props); + + gtk_widget_class_set_accessible_role (widget_class, GTK_ACCESSIBLE_ROLE_PRESENTATION); } guint diff --git a/gtk/a11y/gtkatspicache.c b/gtk/a11y/gtkatspicache.c index 31172d2cb6..10736341e5 100644 --- a/gtk/a11y/gtkatspicache.c +++ b/gtk/a11y/gtkatspicache.c @@ -176,6 +176,18 @@ static void emit_add_accessible (GtkAtSpiCache *self, GtkAtSpiContext *context) { + GtkATContext *at_context = GTK_AT_CONTEXT (context); + + /* If the context is hidden, we don't need to update the cache */ + if (gtk_at_context_has_accessible_state (at_context, GTK_ACCESSIBLE_STATE_HIDDEN)) + { + GtkAccessibleValue *is_hidden = + gtk_at_context_get_accessible_state (at_context, GTK_ACCESSIBLE_STATE_HIDDEN); + + if (gtk_boolean_accessible_value_get (is_hidden)) + return; + } + GVariantBuilder builder = G_VARIANT_BUILDER_INIT (G_VARIANT_TYPE ("(" ITEM_SIGNATURE ")")); collect_object (self, &builder, context); @@ -185,20 +197,35 @@ emit_add_accessible (GtkAtSpiCache *self, self->cache_path, "org.a11y.atspi.Cache", "AddAccessible", - g_variant_builder_end (&builder), + g_variant_new ("(@(" ITEM_SIGNATURE "))", + g_variant_builder_end (&builder)), NULL); } static void -emit_remove_accessible (GtkAtSpiCache *self, - GVariant *ref) +emit_remove_accessible (GtkAtSpiCache *self, + GtkAtSpiContext *context) { + GtkATContext *at_context = GTK_AT_CONTEXT (context); + + /* If the context is hidden, we don't need to update the cache */ + if (gtk_at_context_has_accessible_state (at_context, GTK_ACCESSIBLE_STATE_HIDDEN)) + { + GtkAccessibleValue *is_hidden = + gtk_at_context_get_accessible_state (at_context, GTK_ACCESSIBLE_STATE_HIDDEN); + + if (gtk_boolean_accessible_value_get (is_hidden)) + return; + } + + GVariant *ref = gtk_at_spi_context_to_ref (context); + g_dbus_connection_emit_signal (self->connection, NULL, self->cache_path, "org.a11y.atspi.Cache", "RemoveAccessible", - ref, + g_variant_new ("(@(so))", ref), NULL); } @@ -324,29 +351,6 @@ gtk_at_spi_cache_new (GDBusConnection *connection, NULL); } -static void -context_weak_unref (gpointer data, - GObject *stale_context) -{ - GtkAtSpiCache *self = data; - - const char *path = g_hash_table_lookup (self->contexts_to_path, stale_context); - if (path == NULL) - return; - - /* By the time we get here, the context has already been dropped, - * so we need to generate the reference ourselves - */ - emit_remove_accessible (self, g_variant_new ("(so)", - g_dbus_connection_get_unique_name (self->connection), - path)); - - GTK_NOTE (A11Y, g_message ("Removing stale context '%s' from cache", path)); - - g_hash_table_remove (self->contexts_by_path, path); - g_hash_table_remove (self->contexts_to_path, stale_context); -} - void gtk_at_spi_cache_add_context (GtkAtSpiCache *self, GtkAtSpiContext *context) @@ -361,15 +365,13 @@ gtk_at_spi_cache_add_context (GtkAtSpiCache *self, if (g_hash_table_contains (self->contexts_by_path, path)) return; - g_object_weak_ref (G_OBJECT (context), context_weak_unref, self); - char *path_key = g_strdup (path); g_hash_table_insert (self->contexts_by_path, path_key, context); g_hash_table_insert (self->contexts_to_path, context, path_key); - emit_add_accessible (self, context); - GTK_NOTE (A11Y, g_message ("Adding context '%s' to cache", path_key)); + + emit_add_accessible (self, context); } void @@ -383,9 +385,7 @@ gtk_at_spi_cache_remove_context (GtkAtSpiCache *self, if (!g_hash_table_contains (self->contexts_by_path, path)) return; - emit_remove_accessible (self, gtk_at_spi_context_to_ref (context)); - - g_object_weak_unref (G_OBJECT (context), context_weak_unref, self); + emit_remove_accessible (self, context); /* The order is important: the value in contexts_by_path is the * key in contexts_to_path diff --git a/gtk/a11y/gtkatspiroot.c b/gtk/a11y/gtkatspiroot.c index 31afbe2316..48c9e60676 100644 --- a/gtk/a11y/gtkatspiroot.c +++ b/gtk/a11y/gtkatspiroot.c @@ -349,8 +349,9 @@ handle_accessible_method (GDBusConnection *connection, { GVariantBuilder builder = G_VARIANT_BUILDER_INIT (G_VARIANT_TYPE ("as")); - g_variant_builder_add (&builder, "s", "org.a11y.atspi.Accessible"); - g_variant_builder_add (&builder, "s", "org.a11y.atspi.Application"); + g_variant_builder_add (&builder, "s", atspi_accessible_interface.name); + g_variant_builder_add (&builder, "s", atspi_application_interface.name); + g_dbus_method_invocation_return_value (invocation, g_variant_new ("(as)", &builder)); } } @@ -664,8 +665,10 @@ gtk_at_spi_root_constructed (GObject *gobject) } else { + const char *program_name = g_get_prgname (); + self->base_path = g_strconcat ("/org/gtk/application/", - g_get_prgname (), + program_name != NULL ? program_name : "unknown", "/a11y", NULL); diff --git a/gtk/gtkaccessible.c b/gtk/gtkaccessible.c index 991bc02756..ed89fa9714 100644 --- a/gtk/gtkaccessible.c +++ b/gtk/gtkaccessible.c @@ -756,14 +756,16 @@ gtk_accessible_bounds_changed (GtkAccessible *self) gboolean gtk_accessible_should_present (GtkAccessible *self) { + GtkAccessibleRole role; GtkATContext *context; if (GTK_IS_WIDGET (self) && !gtk_widget_get_visible (GTK_WIDGET (self))) return FALSE; - if (gtk_accessible_get_accessible_role (self) == GTK_ACCESSIBLE_ROLE_NONE || - gtk_accessible_get_accessible_role (self) == GTK_ACCESSIBLE_ROLE_PRESENTATION) + role = gtk_accessible_get_accessible_role (self); + if (role == GTK_ACCESSIBLE_ROLE_NONE || + role == GTK_ACCESSIBLE_ROLE_PRESENTATION) return FALSE; context = gtk_accessible_get_at_context (self); |