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>
This commit is contained in:
parent
4bab1b0d7c
commit
c127fc83ad
@ -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];
|
||||
|
Loading…
Reference in New Issue
Block a user