Windows QPA: Fix coordinates reported through UI Automation
Conversion to/from native screen coordinates was incorrect and could fail for non-primary screens. This could cause a control's bounding rectangle to be incorrectly reported, or a search for a control based on its position within the window to fail, causing incorrect behavior with accessibility tools and other software interacting with the application using UI Automation. Fixes: QTBUG-91459 Change-Id: I5d56584ff26d977cdd34d35af46644e32aa11e7c Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io> (cherry picked from commit 0235c0217883bc9d0ca83c7533e9c0286901bb3c) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
parent
03b3969521
commit
3bc70954ee
@ -132,22 +132,19 @@ void setVariantString(const QString &value, VARIANT *variant)
|
||||
void rectToNativeUiaRect(const QRect &rect, const QWindow *w, UiaRect *uiaRect)
|
||||
{
|
||||
if (w && uiaRect) {
|
||||
const qreal factor = QHighDpiScaling::factor(w);
|
||||
uiaRect->left = qreal(rect.x()) * factor;
|
||||
uiaRect->top = qreal(rect.y()) * factor;
|
||||
uiaRect->width = qreal(rect.width()) * factor;
|
||||
uiaRect->height = qreal(rect.height()) * factor;
|
||||
QRectF r = QHighDpi::toNativePixels(QRectF(rect), w);
|
||||
uiaRect->left =r.x();
|
||||
uiaRect->top = r.y();
|
||||
uiaRect->width = r.width();
|
||||
uiaRect->height = r.height();
|
||||
}
|
||||
}
|
||||
|
||||
// Scales a point from native coordinates, according to high dpi settings.
|
||||
void nativeUiaPointToPoint(const UiaPoint &uiaPoint, const QWindow *w, QPoint *point)
|
||||
{
|
||||
if (w && point) {
|
||||
const qreal factor = QHighDpiScaling::factor(w);
|
||||
point->setX(int(std::lround(uiaPoint.x / factor)));
|
||||
point->setY(int(std::lround(uiaPoint.y / factor)));
|
||||
}
|
||||
if (w && point)
|
||||
*point = QHighDpi::fromNativePixels(QPoint(uiaPoint.x, uiaPoint.y), w);
|
||||
}
|
||||
|
||||
// Maps an accessibility role ID to an UI Automation control type ID.
|
||||
|
Loading…
x
Reference in New Issue
Block a user