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 <aclight@gmail.com> Reviewed-by: Oliver Wolff <oliver.wolff@theqtcompany.com>bb10
parent
2a282551ac
commit
e4e62496ac
|
|
@ -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;
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue