summaryrefslogtreecommitdiffstats
path: root/pkgs/development/libraries/qt-5/5.15/qtbase.patch.d/macos-sdk-10.12/0004-Revert-QCocoaDrag-avoid-using-the-deprecated-API-if-.patch
diff options
context:
space:
mode:
Diffstat (limited to 'pkgs/development/libraries/qt-5/5.15/qtbase.patch.d/macos-sdk-10.12/0004-Revert-QCocoaDrag-avoid-using-the-deprecated-API-if-.patch')
-rw-r--r--pkgs/development/libraries/qt-5/5.15/qtbase.patch.d/macos-sdk-10.12/0004-Revert-QCocoaDrag-avoid-using-the-deprecated-API-if-.patch192
1 files changed, 192 insertions, 0 deletions
diff --git a/pkgs/development/libraries/qt-5/5.15/qtbase.patch.d/macos-sdk-10.12/0004-Revert-QCocoaDrag-avoid-using-the-deprecated-API-if-.patch b/pkgs/development/libraries/qt-5/5.15/qtbase.patch.d/macos-sdk-10.12/0004-Revert-QCocoaDrag-avoid-using-the-deprecated-API-if-.patch
new file mode 100644
index 000000000000..7b568a91943f
--- /dev/null
+++ b/pkgs/development/libraries/qt-5/5.15/qtbase.patch.d/macos-sdk-10.12/0004-Revert-QCocoaDrag-avoid-using-the-deprecated-API-if-.patch
@@ -0,0 +1,192 @@
+From d5c155a9f3ff38e28ac073f6df43175724ebc290 Mon Sep 17 00:00:00 2001
+From: Dmitry Kalinkin <dmitry.kalinkin@gmail.com>
+Date: Mon, 7 Dec 2020 12:32:34 -0500
+Subject: [PATCH 4/6] Revert "QCocoaDrag - avoid using the deprecated API if
+ possible"
+
+This reverts commit 8481a9fc974a1f1dd44a9f82decb18fe2290689f.
+---
+ src/plugins/platforms/cocoa/qcocoadrag.h | 6 --
+ src/plugins/platforms/cocoa/qcocoadrag.mm | 90 -------------------
+ .../platforms/cocoa/qnsview_dragging.mm | 9 +-
+ 3 files changed, 1 insertion(+), 104 deletions(-)
+
+diff --git a/src/plugins/platforms/cocoa/qcocoadrag.h b/src/plugins/platforms/cocoa/qcocoadrag.h
+index 975741c270..5a5b985c6e 100644
+--- a/src/plugins/platforms/cocoa/qcocoadrag.h
++++ b/src/plugins/platforms/cocoa/qcocoadrag.h
+@@ -48,8 +48,6 @@
+ #include <QtGui/private/qdnd_p.h>
+ #include <QtGui/private/qinternalmimedata_p.h>
+
+-#include <QtCore/qeventloop.h>
+-
+ QT_BEGIN_NAMESPACE
+
+ class QCocoaDrag : public QPlatformDrag
+@@ -71,15 +69,11 @@ public:
+ void setLastMouseEvent(NSEvent *event, NSView *view);
+
+ void setAcceptedAction(Qt::DropAction act);
+- void exitDragLoop();
+ private:
+ QDrag *m_drag;
+ NSEvent *m_lastEvent;
+ NSView *m_lastView;
+ Qt::DropAction m_executed_drop_action;
+- QEventLoop internalDragLoop;
+-
+- bool maybeDragMultipleItems();
+
+ QPixmap dragPixmap(QDrag *drag, QPoint &hotSpot) const;
+ };
+diff --git a/src/plugins/platforms/cocoa/qcocoadrag.mm b/src/plugins/platforms/cocoa/qcocoadrag.mm
+index ab6863a432..b4a16ab912 100644
+--- a/src/plugins/platforms/cocoa/qcocoadrag.mm
++++ b/src/plugins/platforms/cocoa/qcocoadrag.mm
+@@ -44,9 +44,6 @@
+ #include <QtWidgets/qwidget.h>
+ #endif
+ #include <QtGui/private/qcoregraphics_p.h>
+-#include <QtCore/qsysinfo.h>
+-
+-#include <vector>
+
+ QT_BEGIN_NAMESPACE
+
+@@ -131,9 +128,6 @@ Qt::DropAction QCocoaDrag::drag(QDrag *o)
+ m_drag = o;
+ m_executed_drop_action = Qt::IgnoreAction;
+
+- if (maybeDragMultipleItems())
+- return m_executed_drop_action;
+-
+ QPoint hotSpot = m_drag->hotSpot();
+ QPixmap pm = dragPixmap(m_drag, hotSpot);
+ NSImage *dragImage = [NSImage imageFromQImage:pm.toImage()];
+@@ -164,95 +158,11 @@ Qt::DropAction QCocoaDrag::drag(QDrag *o)
+ return m_executed_drop_action;
+ }
+
+-bool QCocoaDrag::maybeDragMultipleItems()
+-{
+- Q_ASSERT(m_drag && m_drag->mimeData());
+- Q_ASSERT(m_executed_drop_action == Qt::IgnoreAction);
+-
+- if (QOperatingSystemVersion::current() < QOperatingSystemVersion::MacOSMojave) {
+- // -dragImage: stopped working in 10.14 first.
+- return false;
+- }
+-
+- const QMacAutoReleasePool pool;
+-
+- NSWindow *theWindow = [m_lastEvent window];
+- Q_ASSERT(theWindow);
+-
+- if (![theWindow.contentView respondsToSelector:@selector(draggingSession:sourceOperationMaskForDraggingContext:)])
+- return false;
+-
+- auto *sourceView = static_cast<NSView<NSDraggingSource>*>(theWindow.contentView);
+-
+- const auto &qtUrls = m_drag->mimeData()->urls();
+- NSPasteboard *dragBoard = [NSPasteboard pasteboardWithName:NSPasteboardNameDrag];
+-
+- if (int(dragBoard.pasteboardItems.count) == 1 && qtUrls.size() <= 1) {
+- // Good old -dragImage: works perfectly for this ...
+- return false;
+- }
+-
+- std::vector<NSPasteboardItem *> nonUrls;
+- for (NSPasteboardItem *item in dragBoard.pasteboardItems) {
+- bool isUrl = false;
+- for (NSPasteboardType type in item.types) {
+- using NSStringRef = NSString *;
+- if ([type isEqualToString:NSStringRef(kUTTypeFileURL)]) {
+- isUrl = true;
+- break;
+- }
+- }
+-
+- if (!isUrl)
+- nonUrls.push_back(item);
+- }
+-
+- QPoint hotSpot = m_drag->hotSpot();
+- const auto pixmap = dragPixmap(m_drag, hotSpot);
+- NSImage *dragImage = [NSImage imageFromQImage:pixmap.toImage()];
+- Q_ASSERT(dragImage);
+-
+- NSMutableArray<NSDraggingItem *> *dragItems = [[[NSMutableArray alloc] init] autorelease];
+- const NSPoint itemLocation = m_drag->hotSpot().toCGPoint();
+- // 0. We start from URLs, which can be actually in a list (thus technically
+- // only ONE item in the pasteboard. The fact it's only one does not help, we are
+- // still getting an exception because of the number of items/images mismatch ...
+- for (const auto &qtUrl : qtUrls) {
+- NSURL *nsUrl = qtUrl.toNSURL();
+- auto *newItem = [[[NSDraggingItem alloc] initWithPasteboardWriter:nsUrl] autorelease];
+- const NSRect itemFrame = NSMakeRect(itemLocation.x, itemLocation.y,
+- dragImage.size.width,
+- dragImage.size.height);
+- [newItem setDraggingFrame:itemFrame contents:dragImage];
+- [dragItems addObject:newItem];
+- }
+- // 1. Repeat for non-url items, if any:
+- for (auto *pbItem : nonUrls) {
+- auto *newItem = [[[NSDraggingItem alloc] initWithPasteboardWriter:pbItem] autorelease];
+- const NSRect itemFrame = NSMakeRect(itemLocation.x, itemLocation.y,
+- dragImage.size.width,
+- dragImage.size.height);
+- [newItem setDraggingFrame:itemFrame contents:dragImage];
+- [dragItems addObject:newItem];
+- }
+-
+- [sourceView beginDraggingSessionWithItems:dragItems event:m_lastEvent source:sourceView];
+- internalDragLoop.exec();
+- return true;
+-}
+-
+ void QCocoaDrag::setAcceptedAction(Qt::DropAction act)
+ {
+ m_executed_drop_action = act;
+ }
+
+-void QCocoaDrag::exitDragLoop()
+-{
+- if (internalDragLoop.isRunning())
+- internalDragLoop.exit();
+-}
+-
+-
+ QPixmap QCocoaDrag::dragPixmap(QDrag *drag, QPoint &hotSpot) const
+ {
+ const QMimeData* data = drag->mimeData();
+diff --git a/src/plugins/platforms/cocoa/qnsview_dragging.mm b/src/plugins/platforms/cocoa/qnsview_dragging.mm
+index 978d73f7d9..463e3c5579 100644
+--- a/src/plugins/platforms/cocoa/qnsview_dragging.mm
++++ b/src/plugins/platforms/cocoa/qnsview_dragging.mm
+@@ -232,10 +232,6 @@ 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;
+@@ -294,10 +290,7 @@ static QPoint mapWindowCoordinates(QWindow *source, QWindow *target, QPoint poin
+ if (!target)
+ return;
+
+- QCocoaDrag* nativeDrag = QCocoaIntegration::instance()->drag();
+- Q_ASSERT(nativeDrag);
+- nativeDrag->exitDragLoop();
+- nativeDrag->setAcceptedAction(qt_mac_mapNSDragOperation(operation));
++ QCocoaIntegration::instance()->drag();
+
+ // 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
+--
+2.21.0
+