summaryrefslogtreecommitdiffstats
path: root/src/gui/kernel/qcursor.cpp
diff options
context:
space:
mode:
authorKari Pihkala <kari.pihkala@gmail.com>2014-08-02 09:59:18 +0300
committerJake Petroules <jake.petroules@theqtcompany.com>2015-09-06 23:19:03 +0000
commit6413ceeccff9078bc8ec2dcb63b445c031c420dd (patch)
treecdf80826edf167db9b95bf9c75a8e6e95cebc9e6 /src/gui/kernel/qcursor.cpp
parentcb12da0387458fb63a80a4f59d5ddb24d33ad59b (diff)
Fix default hotspot of a hidpi QCursor
The hotspot is defined in device independent coordinates, so the default coordinates need to be divided by device pixel ratio. Also, modify the scaling of cursor's pixmap to use SmoothTransformation to generate cleaner looking lodpi cursors from hidpi cursors. Change-Id: Ia938fd1e476e19e796f30712e23b06a5efed9964 Task-number: QTBUG-34116 Reviewed-by: Jake Petroules <jake.petroules@theqtcompany.com>
Diffstat (limited to 'src/gui/kernel/qcursor.cpp')
-rw-r--r--src/gui/kernel/qcursor.cpp10
1 files changed, 5 insertions, 5 deletions
diff --git a/src/gui/kernel/qcursor.cpp b/src/gui/kernel/qcursor.cpp
index 6ed750eda1..6b01952647 100644
--- a/src/gui/kernel/qcursor.cpp
+++ b/src/gui/kernel/qcursor.cpp
@@ -387,7 +387,7 @@ QCursor::QCursor(const QPixmap &pixmap, int hotX, int hotY)
bmm.fill(Qt::color1);
}
- d = QCursorData::setBitmap(bm, bmm, hotX, hotY);
+ d = QCursorData::setBitmap(bm, bmm, hotX, hotY, pixmap.devicePixelRatio());
d->pixmap = pixmap;
}
@@ -430,7 +430,7 @@ QCursor::QCursor(const QPixmap &pixmap, int hotX, int hotY)
QCursor::QCursor(const QBitmap &bitmap, const QBitmap &mask, int hotX, int hotY)
: d(0)
{
- d = QCursorData::setBitmap(bitmap, mask, hotX, hotY);
+ d = QCursorData::setBitmap(bitmap, mask, hotX, hotY, 1.0);
}
/*!
@@ -650,7 +650,7 @@ void QCursorData::initialize()
QCursorData::initialized = true;
}
-QCursorData *QCursorData::setBitmap(const QBitmap &bitmap, const QBitmap &mask, int hotX, int hotY)
+QCursorData *QCursorData::setBitmap(const QBitmap &bitmap, const QBitmap &mask, int hotX, int hotY, qreal devicePixelRatio)
{
if (!QCursorData::initialized)
QCursorData::initialize();
@@ -664,8 +664,8 @@ QCursorData *QCursorData::setBitmap(const QBitmap &bitmap, const QBitmap &mask,
d->bm = new QBitmap(bitmap);
d->bmm = new QBitmap(mask);
d->cshape = Qt::BitmapCursor;
- d->hx = hotX >= 0 ? hotX : bitmap.width() / 2;
- d->hy = hotY >= 0 ? hotY : bitmap.height() / 2;
+ d->hx = hotX >= 0 ? hotX : bitmap.width() / 2 / devicePixelRatio;
+ d->hy = hotY >= 0 ? hotY : bitmap.height() / 2 / devicePixelRatio;
return d;
}