a11y: Actually set accessible roles

With most context realization happening inside
GtkAtspiContext in response to D-Bus calls, the
code in gtk_widget_realize_at_context that sets
the role is not executed for most accessibles,
causing them to be stuck with the 'filler' role
that makes orca ignore them.

To fix this, split gtk_widget_realize_at_context
into the actual context realization (getting on
the bus) and the setting of widget-specific
properties, and do the latter part when the
widget is rooted.

This makes accerciser report proper roles for
entries and buttons. Orca still has an issue
with getting the hierarchy populated.
This commit is contained in:
Matthias Clasen
2021-04-17 19:02:53 -04:00
parent 0441101786
commit 1926d91e1d

View File

@@ -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))