diff options
author | Timur Pocheptsov <timur.pocheptsov@qt.io> | 2020-04-22 12:00:01 +0200 |
---|---|---|
committer | Timur Pocheptsov <timur.pocheptsov@qt.io> | 2020-05-08 18:10:35 +0200 |
commit | 8481a9fc974a1f1dd44a9f82decb18fe2290689f (patch) | |
tree | c77ee86c162fc806a47392f77491ae7b387c682a /src/plugins/platforms/cocoa/qnsview_dragging.mm | |
parent | 7cb4c50e73cf611cf9e888013de7ae6f5ab481c7 (diff) |
QCocoaDrag - avoid using the deprecated API if possible
The -dragImage stopped to work in 10.14 first with change in behavior
documented and the new API (AppKit) proposed/advised. Then after
some update the old behavior was restored and D&D for multiple
URLs was working again without us having to change anything.
In 10.15 it's not working anymore and we have to properly fix
it and switch to the API advised. The new API is non-blocking,
but QCocoaDrag::drag is expected to be blocking so we have to
add a nested event loop to emulate the old behavior. Dragging
image is a bit problematic (the exception is thrown because
number of images (1) and number of items in NSPasteboard
are not equal): creating separate images for different
drag items looks really messy. So ... we use the same image
again and again with the same frame.
Fixes: QTBUG-71939
Change-Id: I02c2a10eab280cf4a55513adaf29c22fff934c01
Pick-to: 5.15
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
Diffstat (limited to 'src/plugins/platforms/cocoa/qnsview_dragging.mm')
-rw-r--r-- | src/plugins/platforms/cocoa/qnsview_dragging.mm | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/src/plugins/platforms/cocoa/qnsview_dragging.mm b/src/plugins/platforms/cocoa/qnsview_dragging.mm index 2e88b6a08f..44ffc87f7a 100644 --- a/src/plugins/platforms/cocoa/qnsview_dragging.mm +++ b/src/plugins/platforms/cocoa/qnsview_dragging.mm @@ -231,6 +231,10 @@ static QPoint mapWindowCoordinates(QWindow *source, QWindow *target, QPoint poin if (!target) return; + auto *nativeDrag = QCocoaIntegration::instance()->drag(); + Q_ASSERT(nativeDrag); + nativeDrag->exitDragLoop(); + QPoint windowPoint = QPointF::fromCGPoint([self convertPoint:sender.draggingLocation fromView:nil]).toPoint(); qCDebug(lcQpaMouse) << QEvent::DragLeave << self << "at" << windowPoint; @@ -289,7 +293,10 @@ static QPoint mapWindowCoordinates(QWindow *source, QWindow *target, QPoint poin if (!target) return; - QCocoaIntegration::instance()->drag(); + QCocoaDrag* nativeDrag = QCocoaIntegration::instance()->drag(); + Q_ASSERT(nativeDrag); + nativeDrag->exitDragLoop(); + nativeDrag->setAcceptedAction(qt_mac_mapNSDragOperation(operation)); // Qt starts drag-and-drop on a mouse button press event. Cococa in // this case won't send the matching release event, so we have to |