[gtk/gtk-4-2: 50/91] a11y: Actually set accessible roles




commit 1926d91e1d9d6811f3e9896bf2fdc88ba8f6e03e
Author: Matthias Clasen <mclasen redhat com>
Date:   Sat Apr 17 19:02:53 2021 -0400

    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.

 gtk/gtkwidget.c | 20 +++++++++++++++++---
 1 file changed, 17 insertions(+), 3 deletions(-)
---
diff --git a/gtk/gtkwidget.c b/gtk/gtkwidget.c
index b9088cd3ef..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))


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]