From 73ca3dbf490b33159ba66e936bcb11fbcd03e886 Mon Sep 17 00:00:00 2001 From: Frederik Gladhorn Date: Mon, 20 May 2019 12:18:03 +0200 Subject: Windows Accessibility: window should be focusable MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fixes: QTBUG-75001 Change-Id: Iac67b9bba70317f8d28ac2d355d584417d1ffebf Reviewed-by: André de la Rocha --- .../uiautomation/qwindowsuiamainprovider.cpp | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 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 d34e363484..a427e553f0 100644 --- a/src/plugins/platforms/windows/uiautomation/qwindowsuiamainprovider.cpp +++ b/src/plugins/platforms/windows/uiautomation/qwindowsuiamainprovider.cpp @@ -358,8 +358,7 @@ HRESULT QWindowsUiaMainProvider::GetPropertyValue(PROPERTYID idProp, VARIANT *pR if (!accessible) return UIA_E_ELEMENTNOTAVAILABLE; - bool clientTopLevel = (accessible->role() == QAccessible::Client) - && accessible->parent() && (accessible->parent()->role() == QAccessible::Application); + bool topLevelWindow = accessible->parent() && (accessible->parent()->role() == QAccessible::Application); switch (idProp) { case UIA_ProcessIdPropertyId: @@ -385,7 +384,7 @@ HRESULT QWindowsUiaMainProvider::GetPropertyValue(PROPERTYID idProp, VARIANT *pR setVariantString(QStringLiteral("Qt"), pRetVal); break; case UIA_ControlTypePropertyId: - if (clientTopLevel) { + if (topLevelWindow) { // Reports a top-level widget as a window, instead of "custom". setVariantI4(UIA_WindowControlTypeId, pRetVal); } else { @@ -397,10 +396,20 @@ HRESULT QWindowsUiaMainProvider::GetPropertyValue(PROPERTYID idProp, VARIANT *pR setVariantString(accessible->text(QAccessible::Help), pRetVal); break; case UIA_HasKeyboardFocusPropertyId: - setVariantBool(accessible->state().focused, pRetVal); + if (topLevelWindow) { + // Windows set the active state to true when they are focused + setVariantBool(accessible->state().active, pRetVal); + } else { + setVariantBool(accessible->state().focused, pRetVal); + } break; case UIA_IsKeyboardFocusablePropertyId: - setVariantBool(accessible->state().focusable, pRetVal); + if (topLevelWindow) { + // Windows should always be focusable + setVariantBool(true, pRetVal); + } else { + setVariantBool(accessible->state().focusable, pRetVal); + } break; case UIA_IsOffscreenPropertyId: setVariantBool(accessible->state().offscreen, pRetVal); @@ -430,7 +439,7 @@ HRESULT QWindowsUiaMainProvider::GetPropertyValue(PROPERTYID idProp, VARIANT *pR break; case UIA_NamePropertyId: { QString name = accessible->text(QAccessible::Name); - if (name.isEmpty() && clientTopLevel) + if (name.isEmpty() && topLevelWindow) name = QCoreApplication::applicationName(); setVariantString(name, pRetVal); break; -- cgit v1.2.3