diff options
Diffstat (limited to 'src/plugins/platforms/cocoa')
-rw-r--r-- | src/plugins/platforms/cocoa/qcocoacursor.mm | 37 | ||||
-rw-r--r-- | src/plugins/platforms/cocoa/qcocoafiledialoghelper.mm | 7 | ||||
-rw-r--r-- | src/plugins/platforms/cocoa/qcocoascreen.mm | 6 | ||||
-rw-r--r-- | src/plugins/platforms/cocoa/qnsview_mouse.mm | 16 | ||||
-rw-r--r-- | src/plugins/platforms/cocoa/qnsview_tablet.mm | 7 |
5 files changed, 59 insertions, 14 deletions
diff --git a/src/plugins/platforms/cocoa/qcocoacursor.mm b/src/plugins/platforms/cocoa/qcocoacursor.mm index 8ca72ec619..c963ff937c 100644 --- a/src/plugins/platforms/cocoa/qcocoacursor.mm +++ b/src/plugins/platforms/cocoa/qcocoacursor.mm @@ -45,6 +45,15 @@ #include <QtGui/QBitmap> +#if !defined(QT_APPLE_NO_PRIVATE_APIS) +@interface NSCursor() ++ (id)_windowResizeNorthWestSouthEastCursor; ++ (id)_windowResizeNorthEastSouthWestCursor; ++ (id)_windowResizeNorthSouthCursor; ++ (id)_windowResizeEastWestCursor; +@end +#endif // QT_APPLE_NO_PRIVATE_APIS + QT_BEGIN_NAMESPACE QCocoaCursor::QCocoaCursor() @@ -116,7 +125,7 @@ NSCursor *QCocoaCursor::convertCursor(QCursor *cursor) return nil; const Qt::CursorShape newShape = cursor->shape(); - NSCursor *cocoaCursor; + NSCursor *cocoaCursor = nil; // Check for a suitable built-in NSCursor first: switch (newShape) { @@ -157,7 +166,29 @@ NSCursor *QCocoaCursor::convertCursor(QCursor *cursor) case Qt::DragLinkCursor: cocoaCursor = [NSCursor dragLinkCursor]; break; - default : { +#if !defined(QT_APPLE_NO_PRIVATE_APIS) + case Qt::SizeVerCursor: + if ([NSCursor respondsToSelector:@selector(_windowResizeNorthSouthCursor)]) + cocoaCursor = [NSCursor _windowResizeNorthSouthCursor]; + break; + case Qt::SizeHorCursor: + if ([NSCursor respondsToSelector:@selector(_windowResizeEastWestCursor)]) + cocoaCursor = [NSCursor _windowResizeEastWestCursor]; + break; + case Qt::SizeBDiagCursor: + if ([NSCursor respondsToSelector:@selector(_windowResizeNorthEastSouthWestCursor)]) + cocoaCursor = [NSCursor _windowResizeNorthEastSouthWestCursor]; + break; + case Qt::SizeFDiagCursor: + if ([NSCursor respondsToSelector:@selector(_windowResizeNorthWestSouthEastCursor)]) + cocoaCursor = [NSCursor _windowResizeNorthWestSouthEastCursor]; + break; +#endif // QT_APPLE_NO_PRIVATE_APIS + default: + break; + } + + if (!cocoaCursor) { // No suitable OS cursor exist, use cursors provided // by Qt for the rest. Check for a cached cursor: cocoaCursor = m_cursors.value(newShape); @@ -172,8 +203,6 @@ NSCursor *QCocoaCursor::convertCursor(QCursor *cursor) m_cursors.insert(newShape, cocoaCursor); } - - break; } } return cocoaCursor; } diff --git a/src/plugins/platforms/cocoa/qcocoafiledialoghelper.mm b/src/plugins/platforms/cocoa/qcocoafiledialoghelper.mm index 5dac9b9a91..7c3f69b408 100644 --- a/src/plugins/platforms/cocoa/qcocoafiledialoghelper.mm +++ b/src/plugins/platforms/cocoa/qcocoafiledialoghelper.mm @@ -292,7 +292,12 @@ static QString strippedText(QString s) } } - QString qtFileName = QFileInfo(QString::fromNSString(filename)).fileName(); + // Treat symbolic links and aliases to directories like directories + QFileInfo fileInfo(QString::fromNSString(filename)); + if (fileInfo.isSymLink() && QFileInfo(fileInfo.symLinkTarget()).isDir()) + return YES; + + QString qtFileName = fileInfo.fileName(); // No filter means accept everything bool nameMatches = mSelectedNameFilter->isEmpty(); // Check if the current file name filter accepts the file: diff --git a/src/plugins/platforms/cocoa/qcocoascreen.mm b/src/plugins/platforms/cocoa/qcocoascreen.mm index 581ea01fcc..c03c191376 100644 --- a/src/plugins/platforms/cocoa/qcocoascreen.mm +++ b/src/plugins/platforms/cocoa/qcocoascreen.mm @@ -230,13 +230,13 @@ static QString displayName(CGDirectDisplayID displayID) NSDictionary *info = [(__bridge NSDictionary*)IODisplayCreateInfoDictionary( display, kIODisplayOnlyPreferredName) autorelease]; - if ([[info objectForKey:@kDisplayVendorID] longValue] != CGDisplayVendorNumber(displayID)) + if ([[info objectForKey:@kDisplayVendorID] unsignedIntValue] != CGDisplayVendorNumber(displayID)) continue; - if ([[info objectForKey:@kDisplayProductID] longValue] != CGDisplayModelNumber(displayID)) + if ([[info objectForKey:@kDisplayProductID] unsignedIntValue] != CGDisplayModelNumber(displayID)) continue; - if ([[info objectForKey:@kDisplaySerialNumber] longValue] != CGDisplaySerialNumber(displayID)) + if ([[info objectForKey:@kDisplaySerialNumber] unsignedIntValue] != CGDisplaySerialNumber(displayID)) continue; NSDictionary *localizedNames = [info objectForKey:@kDisplayProductName]; diff --git a/src/plugins/platforms/cocoa/qnsview_mouse.mm b/src/plugins/platforms/cocoa/qnsview_mouse.mm index ef80a47e0f..73995639aa 100644 --- a/src/plugins/platforms/cocoa/qnsview_mouse.mm +++ b/src/plugins/platforms/cocoa/qnsview_mouse.mm @@ -678,7 +678,11 @@ } } else if (theEvent.momentumPhase == NSEventPhaseBegan) { Q_ASSERT(!pixelDelta.isNull() && !angleDelta.isNull()); - phase = Qt::ScrollUpdate; // Send as update, it has a delta + // If we missed finding a momentum NSEventPhaseBegan when the non-momentum + // phase ended we need to treat this as a scroll begin, to not confuse client + // code. Otherwise we treat it as a continuation of the existing scroll. + phase = m_scrolling ? Qt::ScrollUpdate : Qt::ScrollBegin; + m_scrolling = true; } else if (theEvent.momentumPhase == NSEventPhaseChanged) { phase = Qt::ScrollMomentum; } else if (theEvent.phase == NSEventPhaseCancelled @@ -690,6 +694,16 @@ Q_ASSERT(theEvent.momentumPhase != NSEventPhaseStationary); } + // Sanitize deltas for events that should not result in scrolling. + // On macOS 12.1 this phase has been observed to report deltas. + if (theEvent.phase == NSEventPhaseCancelled) { + if (!pixelDelta.isNull() || !angleDelta.isNull()) { + qCInfo(lcQpaMouse) << "Ignoring unexpected delta for" << theEvent; + pixelDelta = QPoint(); + angleDelta = QPoint(); + } + } + // Prevent keyboard modifier state from changing during scroll event streams. // A two-finger trackpad flick generates a stream of scroll events. We want // the keyboard modifier state to be the state at the beginning of the diff --git a/src/plugins/platforms/cocoa/qnsview_tablet.mm b/src/plugins/platforms/cocoa/qnsview_tablet.mm index ba1fa55892..f365403502 100644 --- a/src/plugins/platforms/cocoa/qnsview_tablet.mm +++ b/src/plugins/platforms/cocoa/qnsview_tablet.mm @@ -148,9 +148,6 @@ static QTabletEvent::TabletDevice wacomTabletDevice(NSEvent *theEvent) device = QTabletEvent::Stylus; } else { switch (bits & 0x0F06) { - case 0x0802: - device = QTabletEvent::Stylus; - break; case 0x0902: device = QTabletEvent::Airbrush; break; @@ -163,8 +160,8 @@ static QTabletEvent::TabletDevice wacomTabletDevice(NSEvent *theEvent) case 0x0804: device = QTabletEvent::RotationStylus; break; - default: - device = QTabletEvent::NoDevice; + default: // usually 0x0802, but 0 on iPad sidecar with Apple Pencil + device = QTabletEvent::Stylus; } } return device; |