Set correct DPR on wayland cursors received from remote buffers

Summary:
It will then be renderered appropriately when painting to the output
buffer.

Test Plan: Updated unit test, plus used with other relevant patches

Reviewers: #kwin, graesslin

Reviewed By: #kwin, graesslin

Subscribers: kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D13606
This commit is contained in:
David Edmundson 2018-06-23 18:17:51 +01:00
parent 6bdfea6d2f
commit 1761b75b55
2 changed files with 14 additions and 0 deletions

View file

@ -882,6 +882,19 @@ void PointerInputTest::testCursorImage()
QTRY_COMPARE(p->cursorImage(), blue); QTRY_COMPARE(p->cursorImage(), blue);
QCOMPARE(p->cursorHotSpot(), QPoint(6, 6)); QCOMPARE(p->cursorHotSpot(), QPoint(6, 6));
// scaled cursor
QImage blueScaled = QImage(QSize(20, 20), QImage::Format_ARGB32_Premultiplied);
blueScaled.fill(Qt::blue);
auto bs = Test::waylandShmPool()->createBuffer(blueScaled);
cursorSurface->attachBuffer(bs);
cursorSurface->setScale(2);
cursorSurface->damage(QRect(0, 0, 20, 20));
cursorSurface->commit();
QVERIFY(cursorRenderedSpy.wait());
QTRY_COMPARE(p->cursorImage(), blueScaled);
QCOMPARE(p->cursorImage().devicePixelRatio(), 2.0);
QCOMPARE(p->cursorHotSpot(), QPoint(6, 6)); //surface-local (so not changed)
// hide the cursor // hide the cursor
pointer->setCursor(nullptr); pointer->setCursor(nullptr);
Test::flushWaylandConnection(); Test::flushWaylandConnection();

View file

@ -1063,6 +1063,7 @@ void CursorImage::updateServerCursor()
} }
m_serverCursor.hotSpot = c->hotspot(); m_serverCursor.hotSpot = c->hotspot();
m_serverCursor.image = buffer->data().copy(); m_serverCursor.image = buffer->data().copy();
m_serverCursor.image.setDevicePixelRatio(cursorSurface->scale());
if (needsEmit) { if (needsEmit) {
emit changed(); emit changed();
} }