macOS: Use originating view as drag source when dragging multiple items

We're already tracking the last view along with the last event, so
use that instead of always assuming the drag started from the window's
content view.

Fixes: QTBUG-102584
Pick-to: 6.2 6.3
Change-Id: Ibe8506b0f91ecdfe6e7fe91e17c129b4d7552880
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
Reviewed-by: <stefan.wastl@native-instruments.de>
This commit is contained in:
Stefan Wastl 2022-04-25 14:21:27 +02:00 committed by Tor Arne Vestbø
parent 0248838ee0
commit 1fbd8c282e

View File

@ -175,13 +175,11 @@ bool QCocoaDrag::maybeDragMultipleItems()
const QMacAutoReleasePool pool;
NSWindow *theWindow = [m_lastEvent window];
Q_ASSERT(theWindow);
if (![theWindow.contentView respondsToSelector:@selector(draggingSession:sourceOperationMaskForDraggingContext:)])
NSView *view = m_lastView ? m_lastView : m_lastEvent.window.contentView;
if (![view respondsToSelector:@selector(draggingSession:sourceOperationMaskForDraggingContext:)])
return false;
auto *sourceView = static_cast<NSView<NSDraggingSource>*>(theWindow.contentView);
auto *sourceView = static_cast<NSView<NSDraggingSource>*>(view);
const auto &qtUrls = m_drag->mimeData()->urls();
NSPasteboard *dragBoard = [NSPasteboard pasteboardWithName:NSPasteboardNameDrag];