From 2cc42ecc1220428d1c4fc19e9c85f89c1f5da4cf Mon Sep 17 00:00:00 2001 From: David Edmundson Date: Sat, 23 Jun 2018 18:14:50 +0100 Subject: [PATCH] DRM cursor scaling Summary: We pass the buffer scale of the cursor through QImage::devicePixelRatio. When copying the cursor with QPainter use Qt's in-built functionality to handle resizing the cursor pixmap as necessary to match the screen. As we're now resizing the cursor, the hotspot needs translating from logical to device co-ordinates. Test Plan: Used with associated patches Reviewers: #kwin, graesslin Reviewed By: #kwin, graesslin Subscribers: graesslin, kwin Tags: #kwin Differential Revision: https://phabricator.kde.org/D13605 --- plugins/platforms/drm/drm_output.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/plugins/platforms/drm/drm_output.cpp b/plugins/platforms/drm/drm_output.cpp index de7d511283..ac2cfa194e 100644 --- a/plugins/platforms/drm/drm_output.cpp +++ b/plugins/platforms/drm/drm_output.cpp @@ -132,6 +132,8 @@ void DrmOutput::updateCursor() m_hasNewCursor = true; QImage *c = m_cursor[m_cursorIndex]->image(); c->fill(Qt::transparent); + c->setDevicePixelRatio(m_scale); + QPainter p; p.begin(c); if (m_orientation == Qt::InvertedLandscapeOrientation) { @@ -158,6 +160,7 @@ void DrmOutput::moveCursor(const QPoint &globalPos) hotspotMatrix.rotate(180.0f, 0.0f, 0.0f, 1.0f); hotspotMatrix.translate(-cursorSize.width()/2.0, -cursorSize.height()/2.0); } + hotspotMatrix.scale(m_scale); matrix.scale(m_scale); matrix.translate(-m_globalPos.x(), -m_globalPos.y()); const QPoint p = matrix.map(globalPos) - hotspotMatrix.map(m_backend->softwareCursorHotspot());