a11y: Pass on platform changes

Add an enum for 'platform changes' to the at context
change notification mechanism. This will let us pass
along things that ARIA considers 'platform state' such
as focus or editability. The difference between the
platform state and other ARIA states is that we don't
keep the platform state separately in the at context
- backends are expected to just query the widgets.

This is just about avoiding notify listeners for
change notification.
This commit is contained in:
Matthias Clasen 2020-10-12 13:05:43 -04:00
parent 578c8b5068
commit b5ee73d299
7 changed files with 44 additions and 3 deletions

View File

@ -644,6 +644,7 @@ gtk_at_spi_context_state_change (GtkATContext *ctx,
GtkAccessibleStateChange changed_states, GtkAccessibleStateChange changed_states,
GtkAccessiblePropertyChange changed_properties, GtkAccessiblePropertyChange changed_properties,
GtkAccessibleRelationChange changed_relations, GtkAccessibleRelationChange changed_relations,
GtkAccessiblePlatformChange changed_platform,
GtkAccessibleAttributeSet *states, GtkAccessibleAttributeSet *states,
GtkAccessibleAttributeSet *properties, GtkAccessibleAttributeSet *properties,
GtkAccessibleAttributeSet *relations) GtkAccessibleAttributeSet *relations)

View File

@ -636,3 +636,16 @@ gtk_accessible_role_to_name (GtkAccessibleRole role,
return role_names[role]; return role_names[role];
} }
void
gtk_accessible_platform_changed (GtkAccessible *self,
GtkAccessiblePlatformChange change)
{
GtkATContext *context = gtk_accessible_get_at_context (self);
if (context == NULL)
return;
gtk_at_context_platform_changed (context, change);
gtk_at_context_update (context);
}

View File

@ -20,7 +20,7 @@
#pragma once #pragma once
#include "gtkaccessibleprivate.h" #include "gtkaccessible.h"
#include "gtkaccessiblevalueprivate.h" #include "gtkaccessiblevalueprivate.h"
G_BEGIN_DECLS G_BEGIN_DECLS

View File

@ -21,7 +21,7 @@
#pragma once #pragma once
#include "gtkaccessible.h" #include "gtkaccessible.h"
#include "gtkatcontext.h" #include "gtkatcontextprivate.h"
G_BEGIN_DECLS G_BEGIN_DECLS
@ -37,4 +37,7 @@ GtkATContext * gtk_accessible_get_at_context (GtkAccessible *self);
const char * gtk_accessible_role_to_name (GtkAccessibleRole role, const char * gtk_accessible_role_to_name (GtkAccessibleRole role,
const char *domain); const char *domain);
void gtk_accessible_platform_changed (GtkAccessible *self,
GtkAccessiblePlatformChange change);
G_END_DECLS G_END_DECLS

View File

@ -36,6 +36,7 @@
#include "gtkatcontextprivate.h" #include "gtkatcontextprivate.h"
#include "gtkaccessiblevalueprivate.h" #include "gtkaccessiblevalueprivate.h"
#include "gtkaccessibleprivate.h"
#include "gtkdebug.h" #include "gtkdebug.h"
#include "gtktestatcontextprivate.h" #include "gtktestatcontextprivate.h"
#include "gtktypebuiltins.h" #include "gtktypebuiltins.h"
@ -137,6 +138,7 @@ gtk_at_context_real_state_change (GtkATContext *self,
GtkAccessibleStateChange changed_states, GtkAccessibleStateChange changed_states,
GtkAccessiblePropertyChange changed_properties, GtkAccessiblePropertyChange changed_properties,
GtkAccessibleRelationChange changed_relations, GtkAccessibleRelationChange changed_relations,
GtkAccessiblePlatformChange changed_platform,
GtkAccessibleAttributeSet *states, GtkAccessibleAttributeSet *states,
GtkAccessibleAttributeSet *properties, GtkAccessibleAttributeSet *properties,
GtkAccessibleAttributeSet *relations) GtkAccessibleAttributeSet *relations)
@ -505,7 +507,8 @@ gtk_at_context_update (GtkATContext *self)
/* There's no point in notifying of state changes if there weren't any */ /* There's no point in notifying of state changes if there weren't any */
if (self->updated_properties == 0 && if (self->updated_properties == 0 &&
self->updated_relations == 0 && self->updated_relations == 0 &&
self->updated_states == 0) self->updated_states == 0 &&
self->updated_platform == 0)
return; return;
GtkAccessibleStateChange changed_states = GtkAccessibleStateChange changed_states =
@ -517,12 +520,14 @@ gtk_at_context_update (GtkATContext *self)
GTK_AT_CONTEXT_GET_CLASS (self)->state_change (self, GTK_AT_CONTEXT_GET_CLASS (self)->state_change (self,
changed_states, changed_properties, changed_relations, changed_states, changed_properties, changed_relations,
self->updated_platform,
self->states, self->properties, self->relations); self->states, self->properties, self->relations);
g_signal_emit (self, obj_signals[STATE_CHANGE], 0); g_signal_emit (self, obj_signals[STATE_CHANGE], 0);
self->updated_properties = 0; self->updated_properties = 0;
self->updated_relations = 0; self->updated_relations = 0;
self->updated_states = 0; self->updated_states = 0;
self->updated_platform = 0;
} }
/*< private > /*< private >
@ -806,3 +811,10 @@ gtk_at_context_get_label (GtkATContext *self)
return g_strdup ("widget"); return g_strdup ("widget");
} }
void
gtk_at_context_platform_changed (GtkATContext *self,
GtkAccessiblePlatformChange change)
{
self->updated_platform |= change;
}

View File

@ -80,6 +80,11 @@ typedef enum {
GTK_ACCESSIBLE_STATE_CHANGE_SELECTED = 1 << GTK_ACCESSIBLE_STATE_SELECTED GTK_ACCESSIBLE_STATE_CHANGE_SELECTED = 1 << GTK_ACCESSIBLE_STATE_SELECTED
} GtkAccessibleStateChange; } GtkAccessibleStateChange;
typedef enum {
GTK_ACCESSIBLE_PLATFORM_CHANGE_FOCUSABLE = 1 << 0,
GTK_ACCESSIBLE_PLATFORM_CHANGE_FOCUSED = 1 << 1,
} GtkAccessiblePlatformChange;
struct _GtkATContext struct _GtkATContext
{ {
GObject parent_instance; GObject parent_instance;
@ -95,6 +100,7 @@ struct _GtkATContext
GtkAccessibleStateChange updated_states; GtkAccessibleStateChange updated_states;
GtkAccessiblePropertyChange updated_properties; GtkAccessiblePropertyChange updated_properties;
GtkAccessibleRelationChange updated_relations; GtkAccessibleRelationChange updated_relations;
GtkAccessiblePlatformChange updated_platform;
}; };
struct _GtkATContextClass struct _GtkATContextClass
@ -105,6 +111,7 @@ struct _GtkATContextClass
GtkAccessibleStateChange changed_states, GtkAccessibleStateChange changed_states,
GtkAccessiblePropertyChange changed_properties, GtkAccessiblePropertyChange changed_properties,
GtkAccessibleRelationChange changed_relations, GtkAccessibleRelationChange changed_relations,
GtkAccessiblePlatformChange changed_platform,
GtkAccessibleAttributeSet *states, GtkAccessibleAttributeSet *states,
GtkAccessibleAttributeSet *properties, GtkAccessibleAttributeSet *properties,
GtkAccessibleAttributeSet *relations); GtkAccessibleAttributeSet *relations);
@ -138,6 +145,9 @@ GtkAccessibleValue * gtk_at_context_get_accessible_relation (GtkATContext
char * gtk_at_context_get_label (GtkATContext *self); char * gtk_at_context_get_label (GtkATContext *self);
void gtk_at_context_platform_changed (GtkATContext *self,
GtkAccessiblePlatformChange change);
const char * gtk_accessible_property_get_attribute_name (GtkAccessibleProperty property); const char * gtk_accessible_property_get_attribute_name (GtkAccessibleProperty property);
const char * gtk_accessible_relation_get_attribute_name (GtkAccessibleRelation relation); const char * gtk_accessible_relation_get_attribute_name (GtkAccessibleRelation relation);
const char * gtk_accessible_state_get_attribute_name (GtkAccessibleState state); const char * gtk_accessible_state_get_attribute_name (GtkAccessibleState state);

View File

@ -23,6 +23,7 @@
#include "gtktestatcontextprivate.h" #include "gtktestatcontextprivate.h"
#include "gtkatcontextprivate.h" #include "gtkatcontextprivate.h"
#include "gtkaccessibleprivate.h"
#include "gtkdebug.h" #include "gtkdebug.h"
#include "gtkenums.h" #include "gtkenums.h"
#include "gtkprivate.h" #include "gtkprivate.h"
@ -45,6 +46,7 @@ gtk_test_at_context_state_change (GtkATContext *self,
GtkAccessibleStateChange changed_states, GtkAccessibleStateChange changed_states,
GtkAccessiblePropertyChange changed_properties, GtkAccessiblePropertyChange changed_properties,
GtkAccessibleRelationChange changed_relations, GtkAccessibleRelationChange changed_relations,
GtkAccessiblePlatformChange changed_platform,
GtkAccessibleAttributeSet *states, GtkAccessibleAttributeSet *states,
GtkAccessibleAttributeSet *properties, GtkAccessibleAttributeSet *properties,
GtkAccessibleAttributeSet *relations) GtkAccessibleAttributeSet *relations)