From fafdb171e0c317ee8f871dc7b504d3713d5860eb Mon Sep 17 00:00:00 2001 From: Frederik Gladhorn Date: Tue, 3 Jan 2017 18:00:05 +0100 Subject: Accessibility macOS: fix parentElement MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Try to return the immediate parent first, nothing else makes sense. The original code relied on the window pointer usually being nullptr, which is not reliable. Make sure to check the validity of the handle returned, since it's possible to have the platform window being nullptr. It's not quite clear to me how to end up with a null window though. Task-number: QTBUG-52304 Change-Id: Id3e70cdab980fb0a86cebbb7c10d824d8a7dd80b Reviewed-by: Jan Arve Sæther --- .../platforms/cocoa/qcocoaaccessibilityelement.mm | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) (limited to 'src/plugins/platforms/cocoa') diff --git a/src/plugins/platforms/cocoa/qcocoaaccessibilityelement.mm b/src/plugins/platforms/cocoa/qcocoaaccessibilityelement.mm index 97bd402b73..982c98976b 100644 --- a/src/plugins/platforms/cocoa/qcocoaaccessibilityelement.mm +++ b/src/plugins/platforms/cocoa/qcocoaaccessibilityelement.mm @@ -235,19 +235,19 @@ static void convertLineOffset(QAccessibleTextInterface *text, int *line, int *of if (!iface || !iface->isValid()) return nil; - if (QWindow *window = iface->window()) { - QCocoaWindow *win = static_cast(window->handle()); - return qnsview_cast(win->view()); + if (QAccessibleInterface *parent = iface->parent()) { + QAccessible::Id parentId = QAccessible::uniqueId(parent); + return [QMacAccessibilityElement elementWithId: parentId]; } - QAccessibleInterface *parent = iface->parent(); - if (!parent) { - qWarning() << "INVALID PARENT FOR INTERFACE: " << iface; - return nil; + if (QWindow *window = iface->window()) { + QPlatformWindow *platformWindow = window->handle(); + if (platformWindow) { + QCocoaWindow *win = static_cast(platformWindow); + return qnsview_cast(win->view()); + } } - - QAccessible::Id parentId = QAccessible::uniqueId(parent); - return [QMacAccessibilityElement elementWithId: parentId]; + return nil; } -- cgit v1.2.3 From d330ae0da27f54ede10dabdc937bfb570ac244cb Mon Sep 17 00:00:00 2001 From: Frederik Gladhorn Date: Wed, 4 Jan 2017 23:23:42 +0100 Subject: Accessibility macOS: check for valid interfaces MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit There are a few places that did not check if the returned interface is valid. Task-number: QTBUG-52536 Change-Id: I56ca0952fec0b44dfd4b3991aa94554e9c829642 Reviewed-by: Jan Arve Sæther --- src/plugins/platforms/cocoa/qcocoaaccessibilityelement.mm | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'src/plugins/platforms/cocoa') diff --git a/src/plugins/platforms/cocoa/qcocoaaccessibilityelement.mm b/src/plugins/platforms/cocoa/qcocoaaccessibilityelement.mm index 982c98976b..e743dd56bf 100644 --- a/src/plugins/platforms/cocoa/qcocoaaccessibilityelement.mm +++ b/src/plugins/platforms/cocoa/qcocoaaccessibilityelement.mm @@ -537,7 +537,7 @@ static void convertLineOffset(QAccessibleTextInterface *text, int *line, int *of - (void)accessibilityPerformAction:(NSString *)action { QAccessibleInterface *iface = QAccessible::accessibleInterface(axid); - if (iface) { + if (iface && iface->isValid()) { const QString qtAction = QCocoaAccessible::translateAction(action, iface); QAccessibleBridgeUtils::performEffectiveAction(iface, qtAction); } @@ -562,16 +562,16 @@ static void convertLineOffset(QAccessibleTextInterface *text, int *line, int *of int y = qt_mac_flipYCoordinate(point.y); QAccessibleInterface *childInterface = iface->childAt(point.x, y); // No child found, meaning we hit this element. - if (!childInterface) + if (!childInterface || !childInterface->isValid()) return NSAccessibilityUnignoredAncestor(self); // find the deepest child at the point QAccessibleInterface *childOfChildInterface = 0; do { childOfChildInterface = childInterface->childAt(point.x, y); - if (childOfChildInterface) + if (childOfChildInterface && childOfChildInterface->isValid()) childInterface = childOfChildInterface; - } while (childOfChildInterface); + } while (childOfChildInterface && childOfChildInterface->isValid()); QAccessible::Id childId = QAccessible::uniqueId(childInterface); // hit a child, forward to child accessible interface. @@ -590,7 +590,7 @@ static void convertLineOffset(QAccessibleTextInterface *text, int *line, int *of } QAccessibleInterface *childInterface = iface->focusChild(); - if (childInterface) { + if (childInterface && childInterface->isValid()) { QAccessible::Id childAxid = QAccessible::uniqueId(childInterface); QMacAccessibilityElement *accessibleElement = [QMacAccessibilityElement elementWithId:childAxid]; return NSAccessibilityUnignoredAncestor(accessibleElement); -- cgit v1.2.3 From 25b00c88b6fda2eecd9ff566ab44974136dabf51 Mon Sep 17 00:00:00 2001 From: Andy Shaw Date: Tue, 10 Jan 2017 10:56:34 +0100 Subject: cocoa: Account for getting a keyboard using input methods correctly MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When a keyboard is using an input method then the layout for it needs to be retrieved with TISCopyInputMethodKeyboardLayoutOverride(). For cases where it is not using an input method this will return null and in that case we can use the original approach as before. Task-number: QTBUG-53804 Task-number: QTBUG-57934 Change-Id: I6283785bf002602113e208bb38d5eb2a9a7ceb36 Reviewed-by: Tor Arne Vestbø --- src/plugins/platforms/cocoa/qcocoakeymapper.mm | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'src/plugins/platforms/cocoa') diff --git a/src/plugins/platforms/cocoa/qcocoakeymapper.mm b/src/plugins/platforms/cocoa/qcocoakeymapper.mm index e7952ae1f6..1ef7f11011 100644 --- a/src/plugins/platforms/cocoa/qcocoakeymapper.mm +++ b/src/plugins/platforms/cocoa/qcocoakeymapper.mm @@ -366,7 +366,9 @@ Qt::KeyboardModifiers QCocoaKeyMapper::queryKeyboardModifiers() bool QCocoaKeyMapper::updateKeyboard() { const UCKeyboardLayout *uchrData = 0; - QCFType source = TISCopyCurrentKeyboardInputSource(); + QCFType source = TISCopyInputMethodKeyboardLayoutOverride(); + if (!source) + source = TISCopyCurrentKeyboardInputSource(); if (keyboard_mode != NullMode && source == currentInputSource) { return false; } -- cgit v1.2.3 From 63baad4a3d39feb53dc52a9ff2270f6d06bf34fa Mon Sep 17 00:00:00 2001 From: Oleg Yadrov Date: Tue, 10 Jan 2017 13:03:42 -0800 Subject: macOS: convey correct mouse coordinates on drag release Task-number: QTBUG-57129 Change-Id: I6eb60c35bfaf63199d0f637bf2d579fadab0a644 Reviewed-by: Gabriel de Dietrich --- src/plugins/platforms/cocoa/qnsview.mm | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src/plugins/platforms/cocoa') diff --git a/src/plugins/platforms/cocoa/qnsview.mm b/src/plugins/platforms/cocoa/qnsview.mm index a63bc4d570..ba91d3e40e 100644 --- a/src/plugins/platforms/cocoa/qnsview.mm +++ b/src/plugins/platforms/cocoa/qnsview.mm @@ -2193,7 +2193,8 @@ static QPoint mapWindowCoordinates(QWindow *source, QWindow *target, QPoint poin } NSPoint windowPoint = [self.window convertRectFromScreen:NSMakeRect(screenPoint.x, screenPoint.y, 1, 1)].origin; - QPoint qtWindowPoint(windowPoint.x, windowPoint.y); + NSPoint nsViewPoint = [self convertPoint: windowPoint fromView: nil]; // NSView/QWindow coordinates + QPoint qtWindowPoint(nsViewPoint.x, nsViewPoint.y); QPoint qtScreenPoint = QPoint(screenPoint.x, qt_mac_flipYCoordinate(screenPoint.y)); -- cgit v1.2.3 From 3edeb5c909a4ec62440e2075b9d49ec256a1ba68 Mon Sep 17 00:00:00 2001 From: Oleg Yadrov Date: Wed, 18 Jan 2017 11:09:37 -0800 Subject: Cocoa: fix regression preventing windows from showing up The regression was introduced by 593ab638609 which fixed another bug related to window modality. To determine whether the window needs to be (made key and ordered front) or just (ordered front), instead of calling currentModalSession() which might change internal state of event dispatcher we just check if cocoaModalSessionStack is empty or not. Task-number: QTBUG-57991 Task-number: QTBUG-56166 Change-Id: I6c4f92860d8c93decd44e572af1690ed7be6f1f0 Reviewed-by: Timur Pocheptsov --- src/plugins/platforms/cocoa/qcocoawindow.mm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/plugins/platforms/cocoa') diff --git a/src/plugins/platforms/cocoa/qcocoawindow.mm b/src/plugins/platforms/cocoa/qcocoawindow.mm index 602da0a175..40666772c5 100644 --- a/src/plugins/platforms/cocoa/qcocoawindow.mm +++ b/src/plugins/platforms/cocoa/qcocoawindow.mm @@ -695,7 +695,7 @@ void QCocoaWindow::setVisible(bool visible) if (cocoaEventDispatcher) cocoaEventDispatcherPrivate = static_cast(QObjectPrivate::get(cocoaEventDispatcher)); - if (!(cocoaEventDispatcherPrivate && cocoaEventDispatcherPrivate->currentModalSession())) + if (cocoaEventDispatcherPrivate && cocoaEventDispatcherPrivate->cocoaModalSessionStack.isEmpty()) [m_nsWindow makeKeyAndOrderFront:nil]; else [m_nsWindow orderFront:nil]; -- cgit v1.2.3 From 4d49f94060e20c5e47a587cc630a40718d91e62c Mon Sep 17 00:00:00 2001 From: Oleg Yadrov Date: Thu, 19 Jan 2017 14:25:12 -0800 Subject: Cocoa: fix bug when left mouse button release event delivered as right The regression was introduced during refactoring by 820e69d6c and the initial change that added this logic is adc3ef97d. This condition had become redundant and wrong after refactoring because m_sendUpAsRightButton flag is set in the proper way in QNSView::mouseDown() which later calls QNSView::handleMouseEvent() anyway. Task-number: QTBUG-58219 Change-Id: I1951cf4067af6f0c1837c1c15b8a09dfe7939493 Reviewed-by: Timur Pocheptsov Reviewed-by: Pavol Markovic --- src/plugins/platforms/cocoa/qnsview.mm | 3 --- 1 file changed, 3 deletions(-) (limited to 'src/plugins/platforms/cocoa') diff --git a/src/plugins/platforms/cocoa/qnsview.mm b/src/plugins/platforms/cocoa/qnsview.mm index ba91d3e40e..970ce9e785 100644 --- a/src/plugins/platforms/cocoa/qnsview.mm +++ b/src/plugins/platforms/cocoa/qnsview.mm @@ -853,9 +853,6 @@ static bool _q_dontOverrideCtrlLMB = false; if (masked) return false; - if (button == Qt::RightButton) - m_sendUpAsRightButton = true; - m_buttons |= button; [self handleMouseEvent:theEvent]; -- cgit v1.2.3 From 1b1686d194731d940a40112635647536ac8ee676 Mon Sep 17 00:00:00 2001 From: Alexandru Croitor Date: Tue, 22 Nov 2016 15:35:24 +0100 Subject: Fix mouse extra button mapping on macOS MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Previously extra mouse buttons apart from left, right and middle buttons, were mapped incorrectly with an offset of -1. This resulted in the first extra button being recognized as the middle button, the second extra button as the first extra button, etc. Fix consists in using a binary shift with proper offset to create the corresponding Qt::MouseButton value. [ChangeLog][macOS] Fixed extra mouse buttons to be mapped to correct Qt::MouseButton values. Change-Id: I9e6084586cd4737a172b7706a805211f0edff749 Reviewed-by: Tor Arne Vestbø --- src/plugins/platforms/cocoa/qcocoahelpers.mm | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) (limited to 'src/plugins/platforms/cocoa') diff --git a/src/plugins/platforms/cocoa/qcocoahelpers.mm b/src/plugins/platforms/cocoa/qcocoahelpers.mm index 01fbb7bad2..3ab6b641fa 100644 --- a/src/plugins/platforms/cocoa/qcocoahelpers.mm +++ b/src/plugins/platforms/cocoa/qcocoahelpers.mm @@ -281,16 +281,8 @@ NSRect qt_mac_flipRect(const QRect &rect) Qt::MouseButton cocoaButton2QtButton(NSInteger buttonNum) { - if (buttonNum == 0) - return Qt::LeftButton; - if (buttonNum == 1) - return Qt::RightButton; - if (buttonNum == 2) - return Qt::MiddleButton; - if (buttonNum >= 3 && buttonNum <= 31) { // handle XButton1 and higher via logical shift - return Qt::MouseButton(uint(Qt::MiddleButton) << (buttonNum - 3)); - } - // else error: buttonNum too high, or negative + if (buttonNum >= 0 && buttonNum <= 31) + return Qt::MouseButton(1 << buttonNum); return Qt::NoButton; } -- cgit v1.2.3