a11y atspi: translate coords for GetOffsetAtPoint the right way

The coordinate type for "GetOffsetAtPoint" describes the
coordinate type of the input coordinates and
`QAccessibleTextInterface::offsetAtPoint` expects the
coordinates in screen coordinates.

Therefore, if window-relative coordinates are given,
the screen coordinates of the window need to be added
(not subtracted) to the window-relative coordinates of the point
in order to calculate the screen coordinates of the point.

Fixes: QTBUG-105281
Change-Id: I5517335c0c0d6a47b8c45c7e4f8f8b5a91f0fcd7
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
(cherry picked from commit fa0e24b641ad241195cab24d008fed6e68983944)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
Michael Weghorn 2022-08-01 14:18:05 +02:00 committed by Qt Cherry-pick Bot
parent 3e12229c67
commit 858e08a101

View File

@ -1804,7 +1804,7 @@ bool AtSpiAdaptor::textInterface(QAccessibleInterface *interface, const QString
uint coordType = message.arguments().at(2).toUInt();
if (coordType == ATSPI_COORD_TYPE_WINDOW) {
QWindow *win = interface->window();
point -= QPoint(win->x(), win->y());
point += QPoint(win->x(), win->y());
}
int offset = interface->textInterface()->offsetAtPoint(point);
sendReply(connection, message, offset);