From ee516381873857e833b53b175fd3c40e4c45a5fd Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Fri, 6 May 2016 12:19:46 +0200 Subject: Windows Accessibility: Recurse up to find a window. Not all classes inheriting QAccessibleInterface implement QAccessibleInterface::window(), so, go up the hierarchy to find one that does. The window is required to be able to determine the correct scale factor for the screen when High DPI scaling is active. Fixes multimonitor issues for QtWidgets. Amends change d7a3b6145999d015997e26e12a7345f774b053f3. Task-number: QTBUG-52943 Change-Id: I81733765faee4d296bd6ea046bc2cecb018eb28d Reviewed-by: Frederik Gladhorn --- .../platforms/windows/accessible/qwindowsmsaaaccessible.cpp | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) (limited to 'src/plugins/platforms/windows/accessible') diff --git a/src/plugins/platforms/windows/accessible/qwindowsmsaaaccessible.cpp b/src/plugins/platforms/windows/accessible/qwindowsmsaaaccessible.cpp index 5ca83fa9f2..71c197a32c 100644 --- a/src/plugins/platforms/windows/accessible/qwindowsmsaaaccessible.cpp +++ b/src/plugins/platforms/windows/accessible/qwindowsmsaaaccessible.cpp @@ -470,6 +470,15 @@ HRESULT STDMETHODCALLTYPE QWindowsMsaaAccessible::Invoke(long dispIdMember, return hr; } +static const QWindow *windowOf(const QAccessibleInterface *ai) +{ + for ( ; ai; ai = ai->parent()) { + if (const QWindow *window = ai->window()) + return window; + } + return Q_NULLPTR; +} + /* IAccessible @@ -498,7 +507,7 @@ HRESULT STDMETHODCALLTYPE QWindowsMsaaAccessible::accHitTest(long xLeft, long yT if (!accessible) return E_FAIL; - const QPoint pos = QHighDpi::fromNativeLocalPosition(QPoint(xLeft, yTop), accessible->window()); + const QPoint pos = QHighDpi::fromNativeLocalPosition(QPoint(xLeft, yTop), windowOf(accessible)); QAccessibleInterface *child = accessible->childAt(pos.x(), pos.y()); if (child == 0) { // no child found, return this item if it contains the coordinates @@ -541,7 +550,7 @@ HRESULT STDMETHODCALLTYPE QWindowsMsaaAccessible::accLocation(long *pxLeft, long QAccessibleInterface *acc = childPointer(accessible, varID); if (!acc || !acc->isValid()) return E_FAIL; - const QRect rect = QHighDpi::toNativePixels(acc->rect(), accessible->window()); + const QRect rect = QHighDpi::toNativePixels(acc->rect(), windowOf(accessible)); *pxLeft = rect.x(); *pyTop = rect.y(); -- cgit v1.2.3