From 947df4e63ec9ef74de81f95eacc994a440874cbd Mon Sep 17 00:00:00 2001 From: Andre de la Rocha Date: Mon, 23 Jul 2018 18:07:30 +0200 Subject: Windows: Fix invisible element being included in the UI Automation tree When an element is not visible then it should not be shown in the element tree at all when using tools like Inspect. Also, the IsOffscreen property was hardcoded to false instead of reflecting the actual object offscreen state. Task-number: QTBUG-69537 Change-Id: If6e8a4685c0505ee2b99dfbb8bf2b5d0f4112b1e Reviewed-by: Friedemann Kleint --- .../uiautomation/qwindowsuiamainprovider.cpp | 67 +++++++++++++++------- 1 file changed, 45 insertions(+), 22 deletions(-) (limited to 'src/plugins/platforms/windows') diff --git a/src/plugins/platforms/windows/uiautomation/qwindowsuiamainprovider.cpp b/src/plugins/platforms/windows/uiautomation/qwindowsuiamainprovider.cpp index 46f73f81a0..e36006c103 100644 --- a/src/plugins/platforms/windows/uiautomation/qwindowsuiamainprovider.cpp +++ b/src/plugins/platforms/windows/uiautomation/qwindowsuiamainprovider.cpp @@ -364,7 +364,7 @@ HRESULT QWindowsUiaMainProvider::GetPropertyValue(PROPERTYID idProp, VARIANT *pR setVariantBool(accessible->state().focusable, pRetVal); break; case UIA_IsOffscreenPropertyId: - setVariantBool(false, pRetVal); + setVariantBool(accessible->state().offscreen, pRetVal); break; case UIA_IsContentElementPropertyId: setVariantBool(true, pRetVal); @@ -454,30 +454,53 @@ HRESULT QWindowsUiaMainProvider::Navigate(NavigateDirection direction, IRawEleme QAccessibleInterface *targetacc = nullptr; - switch (direction) { - case NavigateDirection_Parent: - targetacc = accessible->parent(); - if (targetacc && (targetacc->role() == QAccessible::Application)) { - targetacc = nullptr; // The app's children are considered top level objects. - } - break; - case NavigateDirection_FirstChild: - targetacc = accessible->child(0); - break; - case NavigateDirection_LastChild: - targetacc = accessible->child(accessible->childCount() - 1); - break; - case NavigateDirection_NextSibling: - case NavigateDirection_PreviousSibling: + if (direction == NavigateDirection_Parent) { if (QAccessibleInterface *parent = accessible->parent()) { - if (parent->isValid()) { - int index = parent->indexOfChild(accessible); - index += (direction == NavigateDirection_NextSibling) ? 1 : -1; - if (index >= 0 && index < parent->childCount()) - targetacc = parent->child(index); + // The Application's children are considered top level objects. + if (parent->isValid() && parent->role() != QAccessible::Application) { + targetacc = parent; + } + } + } else { + QAccessibleInterface *parent = nullptr; + int index = 0; + int incr = 1; + switch (direction) { + case NavigateDirection_FirstChild: + parent = accessible; + index = 0; + incr = 1; + break; + case NavigateDirection_LastChild: + parent = accessible; + index = accessible->childCount() - 1; + incr = -1; + break; + case NavigateDirection_NextSibling: + if ((parent = accessible->parent())) + index = parent->indexOfChild(accessible) + 1; + incr = 1; + break; + case NavigateDirection_PreviousSibling: + if ((parent = accessible->parent())) + index = parent->indexOfChild(accessible) - 1; + incr = -1; + break; + default: + Q_UNREACHABLE(); + break; + } + + if (parent && parent->isValid()) { + for (int count = parent->childCount(); index >= 0 && index < count; index += incr) { + if (QAccessibleInterface *child = parent->child(index)) { + if (child->isValid() && !child->state().invisible) { + targetacc = child; + break; + } + } } } - break; } if (targetacc) -- cgit v1.2.3 From 708fa860bc877995256f08cd55bf1421d510e5f3 Mon Sep 17 00:00:00 2001 From: Romain Pokrzywka Date: Mon, 23 Jul 2018 16:28:35 -0500 Subject: Windows QPA: Fix tablet event coords delay for tablets in pen mode Now that the mouse mode check is only done once for the first event after the TabletEnterProximityEvent, the m_oldGlobalPosF member has lost its purpose and should be removed. Worse, its value was used instead of currentGlobalPosF when in pen mode, resulting in an unnecessary 1-frame delay in the reported positions in the tablet events. Task-number: QTBUG-36937 Change-Id: I6bd2db57898850a65088d9bb41fbfbd96eac54f5 Reviewed-by: Friedemann Kleint --- src/plugins/platforms/windows/qwindowstabletsupport.cpp | 9 +++------ src/plugins/platforms/windows/qwindowstabletsupport.h | 1 - 2 files changed, 3 insertions(+), 7 deletions(-) (limited to 'src/plugins/platforms/windows') diff --git a/src/plugins/platforms/windows/qwindowstabletsupport.cpp b/src/plugins/platforms/windows/qwindowstabletsupport.cpp index 280519d39d..6acb62ad8f 100644 --- a/src/plugins/platforms/windows/qwindowstabletsupport.cpp +++ b/src/plugins/platforms/windows/qwindowstabletsupport.cpp @@ -489,11 +489,8 @@ bool QWindowsTabletSupport::translateTabletPacketEvent() const int z = currentDevice == QTabletEvent::FourDMouse ? int(packet.pkZ) : 0; - // This code is to delay the tablet data one cycle to sync with the mouse location. - QPointF globalPosF = m_oldGlobalPosF; - const QPointF currentGlobalPosF = + QPointF globalPosF = m_devices.at(m_currentDevice).scaleCoordinates(packet.pkX, packet.pkY, virtualDesktopArea); - m_oldGlobalPosF = currentGlobalPosF; QWindow *target = QGuiApplicationPrivate::tabletDevicePoint(uniqueId).target; // Pass to window that grabbed it. @@ -501,10 +498,10 @@ bool QWindowsTabletSupport::translateTabletPacketEvent() const QPoint mouseLocation = QWindowsCursor::mousePosition(); if (m_state == PenProximity) { m_state = PenDown; - m_mode = (mouseLocation - currentGlobalPosF).manhattanLength() > m_absoluteRange + m_mode = (mouseLocation - globalPosF).manhattanLength() > m_absoluteRange ? MouseMode : PenMode; qCDebug(lcQpaTablet) << __FUNCTION__ << "mode=" << m_mode << "pen:" - << currentGlobalPosF << "mouse:" << mouseLocation; + << globalPosF << "mouse:" << mouseLocation; } if (m_mode == MouseMode) globalPosF = mouseLocation; diff --git a/src/plugins/platforms/windows/qwindowstabletsupport.h b/src/plugins/platforms/windows/qwindowstabletsupport.h index 340818c3f7..9379dd72d6 100644 --- a/src/plugins/platforms/windows/qwindowstabletsupport.h +++ b/src/plugins/platforms/windows/qwindowstabletsupport.h @@ -149,7 +149,6 @@ private: bool m_tiltSupport; QVector m_devices; int m_currentDevice; - QPointF m_oldGlobalPosF; Mode m_mode = PenMode; State m_state = PenUp; }; -- cgit v1.2.3