atcontext: Realize child if parent is realized

When an unrealized GtkATContext (that doesn't come from a GtkWidget) is
attached to a realized parent, nothing happens. That's because, while
GtkWidget is able to realize itself at the appropriate times, that may
not be true for non-widget accessibles.

Realize the child AT context if the parent is realized, when manually
attaching the AT context to a parent.
This commit is contained in:
Georges Basile Stavracas Neto 2024-01-25 09:12:25 -03:00
parent 7e9c18c16e
commit 140ad373f7

View File

@ -484,6 +484,9 @@ gtk_at_context_get_accessible_parent (GtkATContext *self)
return self->accessible_parent;
}
static GtkATContext * get_parent_context (GtkATContext *self);
/*< private >
* gtk_at_context_set_accessible_parent:
* @self: a `GtkAtContext`
@ -505,8 +508,16 @@ gtk_at_context_set_accessible_parent (GtkATContext *self,
self->accessible_parent = parent;
if (self->accessible_parent != NULL)
g_object_add_weak_pointer (G_OBJECT (self->accessible_parent),
(gpointer *) &self->accessible_parent);
{
GtkATContext *parent_context = NULL;
g_object_add_weak_pointer (G_OBJECT (self->accessible_parent),
(gpointer *) &self->accessible_parent);
parent_context = get_parent_context (self);
if (parent_context && parent_context->realized)
gtk_at_context_realize (self);
}
}
}