diff options
author | Matthias Clasen <mclasen@redhat.com> | 2021-04-22 11:04:30 +0000 |
---|---|---|
committer | Matthias Clasen <mclasen@redhat.com> | 2021-04-22 11:04:30 +0000 |
commit | dcb5a7427571e75b67e800250d847bf0b5e31814 (patch) | |
tree | e99071c4e80d8a87d5ad6d72948fa18aa265aba8 | |
parent | 8f70f1449dc59b97d08b266c1ec1b0dac9564b02 (diff) | |
parent | b24fedda49ac647e581b8743d3824bcbc554e438 (diff) | |
download | gtk+-dcb5a7427571e75b67e800250d847bf0b5e31814.tar.gz |
Merge branch 'a11y-debug' into 'master'
Some a11y improvements
See merge request GNOME/gtk!3455
-rw-r--r-- | gtk/a11y/gtkatspicache.c | 54 | ||||
-rw-r--r-- | gtk/a11y/gtkatspicacheprivate.h | 3 | ||||
-rw-r--r-- | gtk/a11y/gtkatspicontext.c | 68 | ||||
-rw-r--r-- | gtk/a11y/gtkatspiroot.c | 2 | ||||
-rw-r--r-- | gtk/a11y/gtkatspitext.c | 5 | ||||
-rw-r--r-- | gtk/gtkatcontext.c | 3 | ||||
-rw-r--r-- | gtk/gtkatcontextprivate.h | 2 | ||||
-rw-r--r-- | gtk/gtkentry.c | 2 | ||||
-rw-r--r-- | gtk/gtknotebook.c | 3 | ||||
-rw-r--r-- | gtk/gtkpasswordentry.c | 2 | ||||
-rw-r--r-- | gtk/gtksearchentry.c | 2 | ||||
-rw-r--r-- | gtk/gtkspinbutton.c | 2 | ||||
-rw-r--r-- | gtk/gtkstackswitcher.c | 4 | ||||
-rw-r--r-- | gtk/gtktestatcontext.c | 3 | ||||
-rw-r--r-- | gtk/gtktreeexpander.c | 17 | ||||
-rw-r--r-- | gtk/gtkwidget.c | 22 | ||||
-rw-r--r-- | gtk/gtkwindow.c | 34 |
17 files changed, 206 insertions, 22 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 @@ -145,6 +149,36 @@ collect_object (GtkAtSpiCache *self, } 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/gtkatspicontext.c b/gtk/a11y/gtkatspicontext.c index 3ee0bcb35c..7c5e967145 100644 --- a/gtk/a11y/gtkatspicontext.c +++ b/gtk/a11y/gtkatspicontext.c @@ -25,7 +25,6 @@ #include "gtkaccessibleprivate.h" #include "gtkatspiactionprivate.h" -#include "gtkatspicacheprivate.h" #include "gtkatspieditabletextprivate.h" #include "gtkatspiprivate.h" #include "gtkatspirootprivate.h" @@ -91,9 +90,6 @@ struct _GtkAtSpiContext /* The root object, used as a entry point */ GtkAtSpiRoot *root; - /* The cache object, used to retrieve ATContexts */ - GtkAtSpiCache *cache; - /* The address for the ATSPI accessibility bus */ char *bus_address; @@ -154,6 +150,13 @@ collect_states (GtkAtSpiContext *self, set_atspi_state (&states, ATSPI_STATE_VISIBLE); + if (ctx->accessible_role == GTK_ACCESSIBLE_ROLE_WINDOW) + { + set_atspi_state (&states, ATSPI_STATE_SHOWING); + if (gtk_accessible_get_platform_state (accessible, GTK_ACCESSIBLE_PLATFORM_STATE_ACTIVE)) + set_atspi_state (&states, ATSPI_STATE_ACTIVE); + } + if (ctx->accessible_role == GTK_ACCESSIBLE_ROLE_TEXT_BOX || ctx->accessible_role == GTK_ACCESSIBLE_ROLE_SEARCH_BOX || ctx->accessible_role == GTK_ACCESSIBLE_ROLE_SPIN_BUTTON) @@ -862,6 +865,43 @@ emit_children_changed (GtkAtSpiContext *self, } 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 +emit_window_event (GtkAtSpiContext *self, + const char *event_type) +{ + if (self->connection == NULL) + return; + + g_dbus_connection_emit_signal (self->connection, + NULL, + self->context_path, + "org.a11y.atspi.Event.Window", + event_type, + 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, GtkAccessiblePropertyChange changed_properties, @@ -892,6 +932,7 @@ gtk_at_spi_context_state_change (GtkATContext *ctx, if (GTK_IS_ROOT (accessible)) { gtk_at_spi_root_child_changed (self->root, change, accessible); + emit_state_changed (self, "showing", gtk_boolean_accessible_value_get (value)); } else { @@ -1087,6 +1128,25 @@ 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) + { + gboolean state = gtk_accessible_get_platform_state (GTK_ACCESSIBLE (widget), + GTK_ACCESSIBLE_PLATFORM_STATE_ACTIVE); + emit_state_changed (self, "active", state); + + /* Orca tracks the window:activate and window:deactivate events on top + * levels to decide whether to track other AT-SPI events + */ + if (gtk_accessible_get_accessible_role (accessible) == GTK_ACCESSIBLE_ROLE_WINDOW) + { + if (state) + emit_window_event (self, "activate"); + else + emit_window_event (self, "deactivate"); + } } } 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) diff --git a/gtk/a11y/gtkatspitext.c b/gtk/a11y/gtkatspitext.c index 7cf08fdf06..44a5605716 100644 --- a/gtk/a11y/gtkatspitext.c +++ b/gtk/a11y/gtkatspitext.c @@ -1326,9 +1326,12 @@ update_selection (TextChanged *changed, int selection_bound) { gboolean caret_moved, bound_moved; + gboolean had_selection, has_selection; caret_moved = cursor_position != changed->cursor_position; bound_moved = selection_bound != changed->selection_bound; + had_selection = changed->cursor_position != changed->selection_bound; + has_selection = cursor_position != selection_bound; if (!caret_moved && !bound_moved) return; @@ -1339,7 +1342,7 @@ update_selection (TextChanged *changed, if (caret_moved) changed->selection_changed (changed->data, "text-caret-moved", changed->cursor_position); - if (caret_moved || bound_moved) + if (had_selection || has_selection) changed->selection_changed (changed->data, "text-selection-changed", 0); } diff --git a/gtk/gtkatcontext.c b/gtk/gtkatcontext.c index 83c9be2a87..709e0f063f 100644 --- a/gtk/gtkatcontext.c +++ b/gtk/gtkatcontext.c @@ -1172,8 +1172,7 @@ void gtk_at_context_platform_changed (GtkATContext *self, GtkAccessiblePlatformChange change) { - if (!self->realized) - return; + gtk_at_context_realize (self); GTK_AT_CONTEXT_GET_CLASS (self)->platform_change (self, change); } diff --git a/gtk/gtkatcontextprivate.h b/gtk/gtkatcontextprivate.h index d9678cbea5..c05c04948f 100644 --- a/gtk/gtkatcontextprivate.h +++ b/gtk/gtkatcontextprivate.h @@ -83,11 +83,13 @@ typedef enum { typedef enum { GTK_ACCESSIBLE_PLATFORM_STATE_FOCUSABLE, GTK_ACCESSIBLE_PLATFORM_STATE_FOCUSED, + GTK_ACCESSIBLE_PLATFORM_STATE_ACTIVE } GtkAccessiblePlatformState; typedef enum { GTK_ACCESSIBLE_PLATFORM_CHANGE_FOCUSABLE = 1 << GTK_ACCESSIBLE_PLATFORM_STATE_FOCUSABLE, GTK_ACCESSIBLE_PLATFORM_CHANGE_FOCUSED = 1 << GTK_ACCESSIBLE_PLATFORM_STATE_FOCUSED, + GTK_ACCESSIBLE_PLATFORM_CHANGE_ACTIVE = 1 << GTK_ACCESSIBLE_PLATFORM_STATE_ACTIVE, } GtkAccessiblePlatformChange; typedef enum { diff --git a/gtk/gtkentry.c b/gtk/gtkentry.c index 8a1262bf14..e5a4de8255 100644 --- a/gtk/gtkentry.c +++ b/gtk/gtkentry.c @@ -351,6 +351,8 @@ gtk_entry_accessible_get_platform_state (GtkAccessible *self, return gtk_widget_get_focusable (GTK_WIDGET (priv->text)); case GTK_ACCESSIBLE_PLATFORM_STATE_FOCUSED: return gtk_widget_has_focus (GTK_WIDGET (priv->text)); + case GTK_ACCESSIBLE_PLATFORM_STATE_ACTIVE: + return FALSE; default: g_assert_not_reached (); } diff --git a/gtk/gtknotebook.c b/gtk/gtknotebook.c index 380cd51e5e..aa89cf6067 100644 --- a/gtk/gtknotebook.c +++ b/gtk/gtknotebook.c @@ -5461,6 +5461,9 @@ gtk_notebook_real_switch_page (GtkNotebook *notebook, gtk_widget_set_state_flags (page->tab_widget, GTK_STATE_FLAG_CHECKED, FALSE); gtk_widget_set_visible (notebook->header_widget, notebook->show_tabs); + if (gtk_widget_get_realized (GTK_WIDGET (notebook))) + gtk_widget_realize_at_context (notebook->cur_page->tab_widget); + gtk_accessible_update_state (GTK_ACCESSIBLE (notebook->cur_page->tab_widget), GTK_ACCESSIBLE_STATE_SELECTED, TRUE, -1); diff --git a/gtk/gtkpasswordentry.c b/gtk/gtkpasswordentry.c index 8096299fb5..32eacc865b 100644 --- a/gtk/gtkpasswordentry.c +++ b/gtk/gtkpasswordentry.c @@ -532,6 +532,8 @@ gtk_password_entry_accessible_get_platform_state (GtkAccessible *se return gtk_widget_get_focusable (GTK_WIDGET (entry->entry)); case GTK_ACCESSIBLE_PLATFORM_STATE_FOCUSED: return gtk_widget_has_focus (GTK_WIDGET (entry->entry)); + case GTK_ACCESSIBLE_PLATFORM_STATE_ACTIVE: + return FALSE; default: g_assert_not_reached (); } diff --git a/gtk/gtksearchentry.c b/gtk/gtksearchentry.c index 64827efdf4..255bd018e5 100644 --- a/gtk/gtksearchentry.c +++ b/gtk/gtksearchentry.c @@ -475,6 +475,8 @@ gtk_search_entry_accessible_get_platform_state (GtkAccessible *self return gtk_widget_get_focusable (GTK_WIDGET (entry->entry)); case GTK_ACCESSIBLE_PLATFORM_STATE_FOCUSED: return gtk_widget_has_focus (GTK_WIDGET (entry->entry)); + case GTK_ACCESSIBLE_PLATFORM_STATE_ACTIVE: + return FALSE; default: g_assert_not_reached (); } diff --git a/gtk/gtkspinbutton.c b/gtk/gtkspinbutton.c index 6030261cd4..344f8870e6 100644 --- a/gtk/gtkspinbutton.c +++ b/gtk/gtkspinbutton.c @@ -633,6 +633,8 @@ gtk_spin_button_accessible_get_platform_state (GtkAccessible *self, return gtk_widget_get_focusable (spin_button->entry); case GTK_ACCESSIBLE_PLATFORM_STATE_FOCUSED: return gtk_widget_has_focus (spin_button->entry); + case GTK_ACCESSIBLE_PLATFORM_STATE_ACTIVE: + return FALSE; default: g_assert_not_reached (); } diff --git a/gtk/gtkstackswitcher.c b/gtk/gtkstackswitcher.c index e0896a74f0..7ce0efb109 100644 --- a/gtk/gtkstackswitcher.c +++ b/gtk/gtkstackswitcher.c @@ -154,6 +154,10 @@ rebuild_child (GtkWidget *self, gtk_widget_set_halign (GTK_WIDGET (button_child), GTK_ALIGN_CENTER); gtk_button_set_child (GTK_BUTTON (self), button_child); } + + gtk_accessible_update_property (GTK_ACCESSIBLE (self), + GTK_ACCESSIBLE_PROPERTY_LABEL, title, + -1); } static void diff --git a/gtk/gtktestatcontext.c b/gtk/gtktestatcontext.c index a093fe6222..e8f3754ea9 100644 --- a/gtk/gtktestatcontext.c +++ b/gtk/gtktestatcontext.c @@ -96,6 +96,9 @@ gtk_test_at_context_platform_change (GtkATContext *self, if (changed_platform & GTK_ACCESSIBLE_PLATFORM_CHANGE_FOCUSED) g_print ("*** focused = %d\n", gtk_accessible_get_platform_state (accessible, GTK_ACCESSIBLE_PLATFORM_STATE_FOCUSED)); + if (changed_platform & GTK_ACCESSIBLE_PLATFORM_CHANGE_ACTIVE) + g_print ("*** active = %d\n", + gtk_accessible_get_platform_state (accessible, GTK_ACCESSIBLE_PLATFORM_STATE_ACTIVE)); } } diff --git a/gtk/gtktreeexpander.c b/gtk/gtktreeexpander.c index 8bad1f5e5b..4ebc072236 100644 --- a/gtk/gtktreeexpander.c +++ b/gtk/gtktreeexpander.c @@ -151,6 +151,8 @@ gtk_tree_expander_update_for_list_row (GtkTreeExpander *self) gtk_widget_unparent (child); } self->expander = NULL; + + gtk_accessible_reset_state (GTK_ACCESSIBLE (self), GTK_ACCESSIBLE_STATE_EXPANDED); } else { @@ -192,22 +194,19 @@ gtk_tree_expander_update_for_list_row (GtkTreeExpander *self) gtk_accessible_update_property (GTK_ACCESSIBLE (self->expander), GTK_ACCESSIBLE_PROPERTY_LABEL, _("Expand"), -1); - gtk_accessible_update_relation (GTK_ACCESSIBLE (self->expander), - GTK_ACCESSIBLE_RELATION_LABELLED_BY, self->child, NULL, - -1); } if (gtk_tree_list_row_get_expanded (self->list_row)) { gtk_widget_set_state_flags (self->expander, GTK_STATE_FLAG_CHECKED, FALSE); - gtk_accessible_update_state (GTK_ACCESSIBLE (self->expander), + gtk_accessible_update_state (GTK_ACCESSIBLE (self), GTK_ACCESSIBLE_STATE_EXPANDED, TRUE, -1); } else { gtk_widget_unset_state_flags (self->expander, GTK_STATE_FLAG_CHECKED); - gtk_accessible_update_state (GTK_ACCESSIBLE (self->expander), + gtk_accessible_update_state (GTK_ACCESSIBLE (self), GTK_ACCESSIBLE_STATE_EXPANDED, FALSE, -1); } @@ -725,6 +724,14 @@ gtk_tree_expander_set_child (GtkTreeExpander *self, { self->child = child; gtk_widget_set_parent (child, GTK_WIDGET (self)); + + gtk_accessible_update_relation (GTK_ACCESSIBLE (self), + GTK_ACCESSIBLE_RELATION_LABELLED_BY, self->child, NULL, + -1); + } + else + { + gtk_accessible_reset_relation (GTK_ACCESSIBLE (self), GTK_ACCESSIBLE_RELATION_LABELLED_BY); } g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_CHILD]); diff --git a/gtk/gtkwidget.c b/gtk/gtkwidget.c index 3f641a6d08..b141179450 100644 --- a/gtk/gtkwidget.c +++ b/gtk/gtkwidget.c @@ -74,6 +74,7 @@ #include "gtkwidgetpaintableprivate.h" #include "gtkwindowgroup.h" #include "gtkwindowprivate.h" +#include "gtktestatcontextprivate.h" #include "inspector/window.h" @@ -2449,13 +2450,13 @@ gtk_widget_init (GTypeInstance *instance, gpointer g_class) priv->at_context = gtk_accessible_get_at_context (GTK_ACCESSIBLE (widget)); } -void -gtk_widget_realize_at_context (GtkWidget *self) +static void +gtk_widget_root_at_context (GtkWidget *self) { GtkWidgetPrivate *priv = gtk_widget_get_instance_private (self); GtkAccessibleRole role = priv->accessible_role; - if (priv->at_context == NULL || gtk_at_context_is_realized (priv->at_context)) + if (priv->at_context == NULL) return; /* Reset the accessible role to its current value */ @@ -2468,6 +2469,17 @@ gtk_widget_realize_at_context (GtkWidget *self) gtk_at_context_set_accessible_role (priv->at_context, role); gtk_at_context_set_display (priv->at_context, gtk_root_get_display (priv->root)); +} + +void +gtk_widget_realize_at_context (GtkWidget *self) +{ + GtkWidgetPrivate *priv = gtk_widget_get_instance_private (self); + + if (priv->at_context == NULL || gtk_at_context_is_realized (priv->at_context)) + return; + + gtk_widget_root_at_context (self); gtk_at_context_realize (priv->at_context); } @@ -2511,6 +2523,8 @@ gtk_widget_root (GtkWidget *widget) if (priv->layout_manager) gtk_layout_manager_set_root (priv->layout_manager, priv->root); + gtk_widget_root_at_context (widget); + GTK_WIDGET_GET_CLASS (widget)->root (widget); if (!GTK_IS_ROOT (widget)) @@ -8492,6 +8506,8 @@ gtk_widget_accessible_get_platform_state (GtkAccessible *self, return gtk_widget_get_focusable (GTK_WIDGET (self)); case GTK_ACCESSIBLE_PLATFORM_STATE_FOCUSED: return gtk_widget_has_focus (GTK_WIDGET (self)); + case GTK_ACCESSIBLE_PLATFORM_STATE_ACTIVE: + return FALSE; default: g_assert_not_reached (); } diff --git a/gtk/gtkwindow.c b/gtk/gtkwindow.c index 17beb19fa3..b8ea6e3e21 100644 --- a/gtk/gtkwindow.c +++ b/gtk/gtkwindow.c @@ -26,6 +26,7 @@ #include "gtkwindowprivate.h" +#include "gtkaccessibleprivate.h" #include "gtkaccelgroupprivate.h" #include "gtkactionable.h" #include "gtkapplicationprivate.h" @@ -479,6 +480,9 @@ static void gtk_window_shortcut_manager_interface_init (GtkShor static void gtk_window_root_interface_init (GtkRootInterface *iface); static void gtk_window_native_interface_init (GtkNativeInterface *iface); +static void gtk_window_accessible_interface_init (GtkAccessibleInterface *iface); + + static void ensure_state_flag_backdrop (GtkWidget *widget); static void unset_titlebar (GtkWindow *window); @@ -493,6 +497,8 @@ gtk_window_update_csd_size (GtkWindow *window, G_DEFINE_TYPE_WITH_CODE (GtkWindow, gtk_window, GTK_TYPE_WIDGET, G_ADD_PRIVATE (GtkWindow) + G_IMPLEMENT_INTERFACE (GTK_TYPE_ACCESSIBLE, + gtk_window_accessible_interface_init) G_IMPLEMENT_INTERFACE (GTK_TYPE_BUILDABLE, gtk_window_buildable_interface_init) G_IMPLEMENT_INTERFACE (GTK_TYPE_NATIVE, @@ -502,6 +508,32 @@ G_DEFINE_TYPE_WITH_CODE (GtkWindow, gtk_window, GTK_TYPE_WIDGET, G_IMPLEMENT_INTERFACE (GTK_TYPE_ROOT, gtk_window_root_interface_init)) +static GtkAccessibleInterface *parent_accessible_iface; + +static gboolean +gtk_window_accessible_get_platform_state (GtkAccessible *self, + GtkAccessiblePlatformState state) +{ + switch (state) + { + case GTK_ACCESSIBLE_PLATFORM_STATE_FOCUSABLE: + case GTK_ACCESSIBLE_PLATFORM_STATE_FOCUSED: + return parent_accessible_iface->get_platform_state (self, state); + case GTK_ACCESSIBLE_PLATFORM_STATE_ACTIVE: + return gtk_window_is_active (GTK_WINDOW (self)); + default: + g_assert_not_reached (); + } +} + +static void +gtk_window_accessible_interface_init (GtkAccessibleInterface *iface) +{ + parent_accessible_iface = g_type_interface_peek_parent (iface); + iface->get_at_context = parent_accessible_iface->get_at_context; + iface->get_platform_state = gtk_window_accessible_get_platform_state; +} + static void add_tab_bindings (GtkWidgetClass *widget_class, GdkModifierType modifiers, @@ -5828,6 +5860,8 @@ _gtk_window_set_is_active (GtkWindow *window, g_object_unref (focus); } + gtk_accessible_platform_changed (GTK_ACCESSIBLE (window), GTK_ACCESSIBLE_PLATFORM_CHANGE_ACTIVE); + g_object_notify_by_pspec (G_OBJECT (window), window_props[PROP_IS_ACTIVE]); } |