a11y atspi: Fix input variant type for Text's GetOffsetAtPoint

Trying to use the AT-SPI Text GetOffsetAtPoint method
didn't work.

For example, trying to use it from Accerciser's IPython
console with the gtk4-demo Hypertext example, would
give this error:

    In [45]: acc.queryText().getOffsetAtPoint(59, 21, pyatspi.XY_WINDOW)
    ---------------------------------------------------------------------------
    Error                                     Traceback (most recent call last)
    Cell In[45], line 1
    ----> 1 acc.queryText().getOffsetAtPoint(59, 21, pyatspi.XY_WINDOW)

    File /usr/lib/python3/dist-packages/pyatspi/text.py:346, in Text.getOffsetAtPoint(self, x, y, coordType)
        331 def getOffsetAtPoint(self, x, y, coordType):
        332         """
        333         Get the offset of the character at a given onscreen coordinate.
        334         The coordinate system used to interpret x and y is determined
       (...)
        344         -1 if the point is outside the bounds of any glyph.
        345         """
    --> 346         return Atspi.Text.get_offset_at_point(self.obj, x, y, coordType)

    Error: atspi_error: Unsupported coordinate space (1)

and the gtk4-demo output would show the actual problem:

    (gtk4-demo:562820): GLib-CRITICAL **: 13:14:10.862: the GVariant format string '(i&s)' has a type of '(is)' but the given value has a type of '(iiu)'

    (gtk4-demo:562820): GLib-CRITICAL **: 13:14:10.863: g_variant_get: assertion 'valid_format_string (format_string, TRUE, value)' failed

Specify the proper type, which gets us one step further at least.
This commit is contained in:
Michael Weghorn 2024-04-04 13:14:56 +02:00
parent c01782b0a9
commit 2cc241732d

View File

@ -290,7 +290,7 @@ accessible_text_handle_method (GDBusConnection *connection,
graphene_point_t p;
unsigned int offset;
g_variant_get (parameters, "(i&s)", &x, &y, &coords_type);
g_variant_get (parameters, "(iiu)", &x, &y, &coords_type);
if (coords_type != ATSPI_COORD_TYPE_WINDOW)
{