From 67c3999e02d2961e32cf9e6adae20e86f45d84d9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tor=20Arne=20Vestb=C3=B8?= Date: Mon, 9 Mar 2020 19:23:39 +0100 Subject: [PATCH] macOS: Pass on QCursor pixmap with original scale There's no need to scale the cursor down to 1x, since we're now passing the correct device pixel ratio on to the NSImage by setting its size. Letting macOS deal with the scaling produces a higher resolution cursor. Change-Id: Icdb3d59998f9a32094c2973c3b222cf22b6398ac Reviewed-by: Timur Pocheptsov --- src/plugins/platforms/cocoa/qcocoacursor.mm | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) diff --git a/src/plugins/platforms/cocoa/qcocoacursor.mm b/src/plugins/platforms/cocoa/qcocoacursor.mm index 658a7670f0..c10ada1ada 100644 --- a/src/plugins/platforms/cocoa/qcocoacursor.mm +++ b/src/plugins/platforms/cocoa/qcocoacursor.mm @@ -335,17 +335,8 @@ 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; - if (pixmap.devicePixelRatio() > 1.0) { - QSize layoutSize = pixmap.size() / pixmap.devicePixelRatio(); - QPixmap scaledPixmap = pixmap.scaled(layoutSize, Qt::IgnoreAspectRatio, Qt::SmoothTransformation); - scaledPixmap.setDevicePixelRatio(1.0); - nsimage = [NSImage imageFromQImage:scaledPixmap.toImage()]; - } else { - nsimage = [NSImage imageFromQImage:pixmap.toImage()]; - } - - return [[NSCursor alloc] initWithImage:nsimage hotSpot:hotSpot]; + auto *image = [NSImage imageFromQImage:pixmap.toImage()]; + return [[NSCursor alloc] initWithImage:image hotSpot:hotSpot]; } QT_END_NAMESPACE