From 1ff17f1a7ef5657c8c547bab7065b78633881d0b Mon Sep 17 00:00:00 2001 From: Michael Weghorn Date: Thu, 15 Feb 2024 17:57:56 +0100 Subject: [PATCH] a11y: Ensure accessible queried by GetAccessibleAtPoint is realized In the the handling of the "GetAccessibleAtPoint" AT-SPI Component method, make sure that the context of the accessible at the given point is realized so that a reference can be returned. Otherwise, the called `gtk_at_spi_context_to_ref` will return a null ref instead. The same is already done in the handling for other AT-SPI methods, (s. "GetRelationSet", "GetChildren", "GetChildAtIndex" in gtk/a11y/gtkatspicontext.c). With this in place, an accessible will be returned. It's not necessarily the one that's really at the requested location, but that's a different issue that will be addressed in a separate commit. With this in place, example from issue #6448 now gives this result when using Accerciser's IPython console: In [16]: acc.queryComponent().getExtents(pyatspi.WINDOW_COORDS) Out[16]: [0, 0, 800, 600] In [17]: acc.queryComponent().getAccessibleAtPoint(50, 50, pyatspi.WINDOW_COORDS) Out[17]: In [18]: acc.queryComponent().getAccessibleAtPoint(50, 50, pyatspi.WINDOW_COORDS).queryComponent().getExtents(pyatspi.WINDOW_COORDS) Out[18]: [683, 1, 111, 49] -> an accessible is returned now, but its rectangle starts at X coordinate 683, so the requested point (50, 50) is not in its bounding box. Issue: #6448 --- gtk/a11y/gtkatspicomponent.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/gtk/a11y/gtkatspicomponent.c b/gtk/a11y/gtkatspicomponent.c index 720bd0c619..292243cf5e 100644 --- a/gtk/a11y/gtkatspicomponent.c +++ b/gtk/a11y/gtkatspicomponent.c @@ -233,6 +233,9 @@ component_handle_method (GDBusConnection *connection, GtkATContext *context = gtk_accessible_get_at_context (child); GtkAtSpiContext *ctx = GTK_AT_SPI_CONTEXT (context); + /* Realize the ATContext in order to get its ref */ + gtk_at_context_realize (context); + g_dbus_method_invocation_return_value (invocation, g_variant_new ("(@(so))", gtk_at_spi_context_to_ref (ctx))); g_object_unref (context);