summaryrefslogtreecommitdiffstats
path: root/src/plugins/platforms/cocoa
diff options
context:
space:
mode:
authorFrederik Christiani <frederik@vikingsoftware.com>2018-04-25 14:28:45 +0200
committerFrederik Juul Christiani <frederik@vikingsoftware.com>2018-04-26 08:56:32 +0000
commitc127fc83adef427f62cc38f3e1afc0041ac9dfe5 (patch)
tree76f855bdb6069abdf43f9f2b600e1c2acb182a18 /src/plugins/platforms/cocoa
parent4bab1b0d7c2462ee9c5369c949b45bc4dedc1194 (diff)
Show high DPI custom cursor on macOS
Set the devicePixelRatio to 1 on the scaled down pixmap. A scaled down version of the high DPI pixmap is added to the NSCursor in addition to the high DPI one, but the devicePixelRatio must be set correctly on the smaller of the two for macOS to pick the right image to use on a high resolution display (retina). This change also fixes the problem that only a high DPI custom cursor with a hotspot in the upper left quadrant is applied by macOS. I suspect that the NSCursor was discarded by macOS, because the hotspot was outside the device independent bounds of the smaller scaled image. Task-number: QTBUG-52211 Change-Id: I7e552e8f62f5255dd3786da44b2f619f6790c37a Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
Diffstat (limited to 'src/plugins/platforms/cocoa')
-rw-r--r--src/plugins/platforms/cocoa/qcocoacursor.mm1
1 files changed, 1 insertions, 0 deletions
diff --git a/src/plugins/platforms/cocoa/qcocoacursor.mm b/src/plugins/platforms/cocoa/qcocoacursor.mm
index c021128e4c..8c98dc69f7 100644
--- a/src/plugins/platforms/cocoa/qcocoacursor.mm
+++ b/src/plugins/platforms/cocoa/qcocoacursor.mm
@@ -314,6 +314,7 @@ NSCursor *QCocoaCursor::createCursorFromPixmap(const QPixmap pixmap, const QPoin
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 = static_cast<NSImage *>(qt_mac_create_nsimage(scaledPixmap));
CGImageRef cgImage = qt_mac_toCGImage(pixmap.toImage());
NSBitmapImageRep *imageRep = [[NSBitmapImageRep alloc] initWithCGImage:cgImage];