From 1fbd8c282e2eb293cdcb1f0ff097ff9548be975d Mon Sep 17 00:00:00 2001 From: Stefan Wastl Date: Mon, 25 Apr 2022 14:21:27 +0200 Subject: [PATCH] macOS: Use originating view as drag source when dragging multiple items MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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ø Reviewed-by: Timur Pocheptsov Reviewed-by: --- src/plugins/platforms/cocoa/qcocoadrag.mm | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/plugins/platforms/cocoa/qcocoadrag.mm b/src/plugins/platforms/cocoa/qcocoadrag.mm index f681981d34..fa073e5e29 100644 --- a/src/plugins/platforms/cocoa/qcocoadrag.mm +++ b/src/plugins/platforms/cocoa/qcocoadrag.mm @@ -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*>(theWindow.contentView); + auto *sourceView = static_cast*>(view); const auto &qtUrls = m_drag->mimeData()->urls(); NSPasteboard *dragBoard = [NSPasteboard pasteboardWithName:NSPasteboardNameDrag];