summaryrefslogtreecommitdiffstats
path: root/src/plugins/platforms/cocoa/qcocoacursor.mm
diff options
context:
space:
mode:
Diffstat (limited to 'src/plugins/platforms/cocoa/qcocoacursor.mm')
-rw-r--r--src/plugins/platforms/cocoa/qcocoacursor.mm18
1 files changed, 16 insertions, 2 deletions
diff --git a/src/plugins/platforms/cocoa/qcocoacursor.mm b/src/plugins/platforms/cocoa/qcocoacursor.mm
index 13f6423701..592bfc8e50 100644
--- a/src/plugins/platforms/cocoa/qcocoacursor.mm
+++ b/src/plugins/platforms/cocoa/qcocoacursor.mm
@@ -308,8 +308,22 @@ NSCursor *QCocoaCursor::createCursorFromBitmap(const QBitmap *bitmap, const QBit
NSCursor *QCocoaCursor::createCursorFromPixmap(const QPixmap pixmap, const QPoint hotspot)
{
- NSPoint hotSpot = NSMakePoint(hotspot.x(), hotspot.y());
- NSImage *nsimage = static_cast<NSImage *>(qt_mac_create_nsimage(pixmap));
+ NSPoint hotSpot = NSMakePoint(hotspot.x() / pixmap.devicePixelRatio(),
+ hotspot.y() / pixmap.devicePixelRatio());
+ NSImage *nsimage;
+ if (pixmap.devicePixelRatio() > 1.0) {
+ QSize layoutSize = pixmap.size() / pixmap.devicePixelRatio();
+ QPixmap scaledPixmap = pixmap.scaled(layoutSize);
+ nsimage = static_cast<NSImage *>(qt_mac_create_nsimage(scaledPixmap));
+ CGImageRef cgImage = qt_mac_toCGImage(pixmap.toImage());
+ NSBitmapImageRep *imageRep = [[NSBitmapImageRep alloc] initWithCGImage:cgImage];
+ [nsimage addRepresentation:imageRep];
+ [imageRep release];
+ CGImageRelease(cgImage);
+ } else {
+ nsimage = static_cast<NSImage *>(qt_mac_create_nsimage(pixmap));
+ }
+
NSCursor *nsCursor = [[NSCursor alloc] initWithImage:nsimage hotSpot: hotSpot];
[nsimage release];
return nsCursor;