Cocoa: Support high-dpi DnD pixmaps.

Set the NSImage size (which is in points/device
independent pixels) to inform Cocoa DnD about the
intended image visual size.

Change-Id: I6fadd77f4e0173e8e9773725fab3b35f70a055ff
Task-id: QTBUG-44179
Reviewed-by: Andy Shaw <andy.shaw@theqtcompany.com>
This commit is contained in:
Morten Johan Sørvig 2015-04-17 12:32:35 +02:00
parent e08fe31f55
commit 5dbf8756ef

View File

@ -120,7 +120,9 @@ Qt::DropAction QCocoaDrag::drag(QDrag *o)
QPoint hotSpot = m_drag->hotSpot();
QPixmap pm = dragPixmap(m_drag, hotSpot);
QSize pmDeviceIndependentSize = pm.size() / pm.devicePixelRatio();
NSImage *nsimage = qt_mac_create_nsimage(pm);
[nsimage setSize : qt_mac_toNSSize(pmDeviceIndependentSize)];
QMacPasteboard dragBoard((CFStringRef) NSDragPboard, QMacInternalPasteboardMime::MIME_DND);
m_drag->mimeData()->setData(QLatin1String("application/x-qt-mime-type-name"), QByteArray("dummy"));
@ -130,7 +132,7 @@ Qt::DropAction QCocoaDrag::drag(QDrag *o)
NSWindow *theWindow = [m_lastEvent window];
Q_ASSERT(theWindow != nil);
event_location.x -= hotSpot.x();
CGFloat flippedY = pm.height() - hotSpot.y();
CGFloat flippedY = pmDeviceIndependentSize.height() - hotSpot.y();
event_location.y -= flippedY;
NSSize mouseOffset_unused = NSMakeSize(0.0, 0.0);
NSPasteboard *pboard = [NSPasteboard pasteboardWithName:NSDragPboard];