diff options
author | Emmanuele Bassi <ebassi@gnome.org> | 2020-10-21 15:37:57 +0100 |
---|---|---|
committer | Emmanuele Bassi <ebassi@gnome.org> | 2020-10-21 15:37:57 +0100 |
commit | e45dd771dbf4f3bb20f5269e08f55e3b1e7e9d9a (patch) | |
tree | 2d787a93c921149ce859c4aee0593003a1b1b224 /gtk/a11y | |
parent | 698cbee1fbe3e8d30c20effe3de14bca13fa4fec (diff) | |
download | gtk+-e45dd771dbf4f3bb20f5269e08f55e3b1e7e9d9a.tar.gz |
a11y: Emit ChildrenChanged for toplevel list changes
GtkAtSpiRoot is not a context, which means it needs to emit
ChildrenChanged events by itself whenever a toplevel is added to, or
removed from, the list of toplevels.
Diffstat (limited to 'gtk/a11y')
-rw-r--r-- | gtk/a11y/gtkatspiroot.c | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/gtk/a11y/gtkatspiroot.c b/gtk/a11y/gtkatspiroot.c index 75290623ea..8c35fb6a29 100644 --- a/gtk/a11y/gtkatspiroot.c +++ b/gtk/a11y/gtkatspiroot.c @@ -406,6 +406,46 @@ static const GDBusInterfaceVTable root_accessible_vtable = { }; static void +root_toplevels__items_changed (GtkAtSpiRoot *self, + guint position, + guint removed, + guint added, + GListModel *toplevels) +{ + GtkWidget *window = g_list_model_get_item (self->toplevels, position); + GVariant *window_ref = NULL; + + if (window == NULL) + { + window_ref = gtk_at_spi_null_ref (); + } + else + { + GtkATContext *context = gtk_accessible_get_at_context (GTK_ACCESSIBLE (window)); + + window_ref = gtk_at_spi_context_to_ref (GTK_AT_SPI_CONTEXT (context)); + } + + if (added == 1 && removed == 0) + gtk_at_spi_emit_children_changed (self->connection, + self->root_path, + GTK_ACCESSIBLE_CHILD_STATE_ADDED, + position, + gtk_at_spi_root_to_ref (self), + window_ref); + else if (removed == 1 && added == 0) + gtk_at_spi_emit_children_changed (self->connection, + self->root_path, + GTK_ACCESSIBLE_CHILD_STATE_REMOVED, + position, + gtk_at_spi_root_to_ref (self), + window_ref); + + if (window != NULL) + g_object_unref (window); +} + +static void on_registration_reply (GObject *gobject, GAsyncResult *result, gpointer user_data) @@ -439,6 +479,9 @@ on_registration_reply (GObject *gobject, /* Monitor the top levels */ self->toplevels = gtk_window_get_toplevels (); + g_signal_connect_swapped (self->toplevels, "items-changed", + G_CALLBACK (root_toplevels__items_changed), + self); } static void |