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
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>
(cherry picked from commit 1fbd8c282e2eb293cdcb1f0ff097ff9548be975d)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
Stefan Wastl 2022-04-25 14:21:27 +02:00 committed by Qt Cherry-pick Bot
parent d0acf48865
commit ebc8d70ab1

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];