From e4e62496ac62deab0e8f6ae9f064cf153b31d2fa Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Fri, 1 Apr 2016 15:31:16 +0200 Subject: Windows QPA: Scale hotspot of custom cursors correctly. Separate factors in QWindowsCursor::createPixmapCursor() and apply factor to the hotspot. Task-number: QTBUG-52276 Change-Id: Ia5a5db39ddc2bc4215a23ff8625431af9b4a76d8 Reviewed-by: Adam Light Reviewed-by: Oliver Wolff --- src/plugins/platforms/windows/qwindowscursor.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/plugins/platforms/windows/qwindowscursor.cpp b/src/plugins/platforms/windows/qwindowscursor.cpp index cda741c226..844fe23517 100644 --- a/src/plugins/platforms/windows/qwindowscursor.cpp +++ b/src/plugins/platforms/windows/qwindowscursor.cpp @@ -97,9 +97,9 @@ QWindowsPixmapCursorCacheKey::QWindowsPixmapCursorCacheKey(const QCursor &c) HCURSOR QWindowsCursor::createPixmapCursor(QPixmap pixmap, const QPoint &hotSpot, qreal scaleFactor) { HCURSOR cur = 0; - scaleFactor /= pixmap.devicePixelRatioF(); - if (!qFuzzyCompare(scaleFactor, 1)) { - pixmap = pixmap.scaled((scaleFactor * QSizeF(pixmap.size())).toSize(), + const qreal pixmapScaleFactor = scaleFactor / pixmap.devicePixelRatioF(); + if (!qFuzzyCompare(pixmapScaleFactor, 1)) { + pixmap = pixmap.scaled((pixmapScaleFactor * QSizeF(pixmap.size())).toSize(), Qt::KeepAspectRatio, Qt::SmoothTransformation); } QBitmap mask = pixmap.mask(); @@ -113,8 +113,8 @@ HCURSOR QWindowsCursor::createPixmapCursor(QPixmap pixmap, const QPoint &hotSpot ICONINFO ii; ii.fIcon = 0; - ii.xHotspot = DWORD(hotSpot.x()); - ii.yHotspot = DWORD(hotSpot.y()); + ii.xHotspot = DWORD(qRound(hotSpot.x() * scaleFactor)); + ii.yHotspot = DWORD(qRound(hotSpot.y() * scaleFactor)); ii.hbmMask = im; ii.hbmColor = ic; -- cgit v1.2.3