diff options
author | Frederik Gladhorn <frederik.gladhorn@qt.io> | 2017-02-05 10:48:44 +0100 |
---|---|---|
committer | Frederik Gladhorn <frederik.gladhorn@qt.io> | 2017-02-07 11:50:19 +0000 |
commit | ee348975654bb5f659370118dcf7b4bb494add87 (patch) | |
tree | 4be6bf9c3badd27f080dc09abe74d0b57e72a50e /src/plugins | |
parent | e9686b3718c396333c368e14cda48f407276c106 (diff) |
Fix regression preventing VoiceOver following the keyboard focus
In fafdb171e0c317ee8f871dc7b504d3713d5860eb a potential nullptr deref
was fixed, but it changed the hierarchy of accessible objects.
The new hierarchy would prefer to send a parent object that represents
the application, but macOS needs the window to be in the hierarchy for
VoiceOver to behave as expected.
Tweak it so that we give the window as parent again, not the app.
Change-Id: I5f7f59b07d0966c8bcf96968e4ed65eba9e05be6
Reviewed-by: Jan Arve Sæther <jan-arve.saether@qt.io>
Diffstat (limited to 'src/plugins')
-rw-r--r-- | src/plugins/platforms/cocoa/qcocoaaccessibilityelement.mm | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/src/plugins/platforms/cocoa/qcocoaaccessibilityelement.mm b/src/plugins/platforms/cocoa/qcocoaaccessibilityelement.mm index e743dd56bf..6001a845e8 100644 --- a/src/plugins/platforms/cocoa/qcocoaaccessibilityelement.mm +++ b/src/plugins/platforms/cocoa/qcocoaaccessibilityelement.mm @@ -235,9 +235,16 @@ static void convertLineOffset(QAccessibleTextInterface *text, int *line, int *of if (!iface || !iface->isValid()) return nil; + // macOS expects that the hierarchy is: + // App -> Window -> Children + // We don't actually have the window reflected properly in QAccessibility. + // Check if the parent is the application and then instead return the native window. + if (QAccessibleInterface *parent = iface->parent()) { - QAccessible::Id parentId = QAccessible::uniqueId(parent); - return [QMacAccessibilityElement elementWithId: parentId]; + if (parent->role() != QAccessible::Application) { + QAccessible::Id parentId = QAccessible::uniqueId(parent); + return [QMacAccessibilityElement elementWithId: parentId]; + } } if (QWindow *window = iface->window()) { |