Commit 44dcb6d0 authored by Vlad Zahorodnii's avatar Vlad Zahorodnii
Browse files

platform/drm: Fix clipped HiDPI hardware cursors

If an output is rotated, we will compute a transform matrix for the
cursor plane to rotate its contents.

In order to compute that matrix we need the rect of the cursor in the
device-independent pixels, the scale factor and the output transform.

The problem is that we provide a rect of the cursor in the native
pixels. This may result in the cursor being partially or fully clipped.

CCBUG: 424589
(cherry picked from commit c8eeefbd)
parent ff4a0d97
......@@ -148,6 +148,11 @@ QRect Cursor::geometry() const
return QRect(m_pos - hotspot(), image().size());
QRect Cursor::rect() const
return QRect(QPoint(0, 0), image().size() / image().devicePixelRatio());
QPoint Cursor::pos()
......@@ -163,6 +163,7 @@ public:
QImage image() const { return m_image; }
QPoint hotspot() const { return m_hotspot; }
QRect geometry() const;
QRect rect() const;
void updateCursor(const QImage &image, const QPoint &hotspot);
void markAsRendered() {
......@@ -134,7 +134,8 @@ void DrmOutput::updateCursor()
if (m_deleted) {
QImage cursorImage = Cursors::self()->currentCursor()->image();
const Cursor *cursor = Cursors::self()->currentCursor();
const QImage cursorImage = cursor->image();
if (cursorImage.isNull()) {
......@@ -144,14 +145,14 @@ void DrmOutput::updateCursor()
QPainter p;
p.setWorldTransform(logicalToNativeMatrix(cursorImage.rect(), scale(), transform()).toTransform());
p.setWorldTransform(logicalToNativeMatrix(cursor->rect(), scale(), transform()).toTransform());
p.drawImage(QPoint(0, 0), cursorImage);
void DrmOutput::moveCursor(Cursor* cursor, const QPoint &globalPos)
const QMatrix4x4 hotspotMatrix = logicalToNativeMatrix(cursor->image().rect(), scale(), transform());
const QMatrix4x4 hotspotMatrix = logicalToNativeMatrix(cursor->rect(), scale(), transform());
const QMatrix4x4 monitorMatrix = logicalToNativeMatrix(geometry(), scale(), transform());
QPoint pos =;
......@@ -568,8 +568,7 @@ void SceneOpenGL2::paintCursor(const QRegion &rendered)
// figure out which part of the cursor needs to be repainted
const QPoint cursorPos = cursor->pos() - cursor->hotspot();
const qreal scale = cursor->image().devicePixelRatio();
const QRect cursorRect(QPoint(0, 0), cursor->image().size() / scale);
const QRect cursorRect = cursor->rect();
QRegion region;
for (const QRect &rect : rendered) {
region |= rect.translated(-cursorPos).intersected(cursorRect);
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment