a11y: Handle HIDDEN state changes

Hidden elements are not presented in the accessible
tree, so when then HIDDEN state changes, we should
emit child-added or -removed signals.

This commit does not yet handle all cases (HIDDEN
toplevels or hidden stack pages are not handled),
but it should cover the common case.
This commit is contained in:
Matthias Clasen 2020-10-24 11:14:18 -04:00
parent 374a451eeb
commit b12992c1cb

View File

@ -34,7 +34,6 @@
#include "gtkatspiutilsprivate.h"
#include "gtkatspivalueprivate.h"
#include "gtkatspicomponentprivate.h"
#include "a11y/atspi/atspi-accessible.h"
#include "a11y/atspi/atspi-action.h"
#include "a11y/atspi/atspi-editabletext.h"
@ -848,6 +847,29 @@ gtk_at_spi_context_state_change (GtkATContext *ctx,
if (!gtk_widget_get_realized (widget))
return;
if (changed_states & GTK_ACCESSIBLE_STATE_CHANGE_HIDDEN)
{
GtkWidget *parent;
gboolean hidden;
value = gtk_accessible_attribute_set_get_value (states, GTK_ACCESSIBLE_STATE_HIDDEN);
hidden = gtk_boolean_accessible_value_get (value);
parent = gtk_widget_get_parent (widget);
if (parent)
{
if (GTK_IS_STACK (parent))
g_warning ("Setting GTK_ACCESSIBLE_STATE_HIDDEN on stack children is not supported");
else
gtk_at_context_child_changed (gtk_accessible_get_at_context (GTK_ACCESSIBLE (parent)),
hidden ? GTK_ACCESSIBLE_CHILD_CHANGE_REMOVED
: GTK_ACCESSIBLE_CHILD_CHANGE_ADDED,
GTK_ACCESSIBLE (widget));
}
else
g_warning ("Setting GTK_ACCESSIBLE_STATE_HIDDEN on toplevels is not supported");
}
if (changed_states & GTK_ACCESSIBLE_STATE_CHANGE_BUSY)
{
value = gtk_accessible_attribute_set_get_value (states, GTK_ACCESSIBLE_STATE_BUSY);