Commit 95ceb497 authored by Emmanuele Bassi's avatar Emmanuele Bassi

a11y: Make GtkATContext realization lazier

We only realize the ATContext on the top level, which will create an
GtkAtSpiRoot object and the corresponding GtkAtSpiCache object. Whenever
an AT connects to the accessibility bus, and asks for the various
objects, all the ATContext will be realized on demand.
parent 0bde58ff
Pipeline #249074 passed with stages
in 22 minutes and 12 seconds
......@@ -2374,7 +2374,7 @@ gtk_widget_init (GTypeInstance *instance, gpointer g_class)
priv->at_context = gtk_accessible_get_at_context (GTK_ACCESSIBLE (widget));
}
static void
void
gtk_widget_realize_at_context (GtkWidget *self)
{
GtkWidgetPrivate *priv = gtk_widget_get_instance_private (self);
......@@ -2383,10 +2383,6 @@ gtk_widget_realize_at_context (GtkWidget *self)
if (priv->at_context == NULL || gtk_at_context_is_realized (priv->at_context))
return;
/* Realize the root ATContext first */
if (!GTK_IS_ROOT (self))
gtk_widget_realize_at_context (GTK_WIDGET (priv->root));
/* Reset the accessible role to its current value */
if (role == GTK_ACCESSIBLE_ROLE_WIDGET)
{
......@@ -2400,6 +2396,18 @@ gtk_widget_realize_at_context (GtkWidget *self)
gtk_at_context_realize (priv->at_context);
}
void
gtk_widget_unrealize_at_context (GtkWidget *widget)
{
GtkWidgetPrivate *priv = gtk_widget_get_instance_private (widget);
if (priv->at_context != NULL)
{
gtk_at_context_set_display (priv->at_context, gdk_display_get_default ());
gtk_at_context_unrealize (priv->at_context);
}
}
void
gtk_widget_root (GtkWidget *widget)
{
......@@ -2428,8 +2436,6 @@ gtk_widget_root (GtkWidget *widget)
if (priv->layout_manager)
gtk_layout_manager_set_root (priv->layout_manager, priv->root);
gtk_widget_realize_at_context (widget);
GTK_WIDGET_GET_CLASS (widget)->root (widget);
if (!GTK_IS_ROOT (widget))
......@@ -2454,12 +2460,6 @@ gtk_widget_unroot (GtkWidget *widget)
GTK_WIDGET_GET_CLASS (widget)->unroot (widget);
if (priv->at_context != NULL)
{
gtk_at_context_set_display (priv->at_context, gdk_display_get_default ());
gtk_at_context_unrealize (priv->at_context);
}
if (priv->context)
gtk_style_context_set_display (priv->context, gdk_display_get_default ());
......
......@@ -373,6 +373,9 @@ gboolean gtk_widget_focus_self (GtkWidget *widget,
void gtk_widget_update_orientation (GtkWidget *widget,
GtkOrientation orientation);
void gtk_widget_realize_at_context (GtkWidget *widget);
void gtk_widget_unrealize_at_context (GtkWidget *widget);
/* inline getters */
static inline GtkWidget *
......
......@@ -3806,6 +3806,8 @@ gtk_window_map (GtkWidget *widget)
if (priv->application)
gtk_application_handle_window_map (priv->application, window);
gtk_widget_realize_at_context (widget);
}
static void
......@@ -3818,6 +3820,8 @@ gtk_window_unmap (GtkWidget *widget)
GTK_WIDGET_CLASS (gtk_window_parent_class)->unmap (widget);
gdk_surface_hide (priv->surface);
gtk_widget_unrealize_at_context (widget);
if (priv->title_box != NULL)
gtk_widget_unmap (priv->title_box);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment