Commit c06c2347 authored by Martin Flöser's avatar Martin Flöser

[platforms/drm] Properly adjust cursor position on a rotated output

Summary:
This change refactors the way how the cursor position on a screen is
calculated. It is changed to a matrix multiplication with the
adjustments for the rotated screen just being additional steps added to
the matrix.

With this calculation I got correct positions for all variants of
scaled, rotated and differently positioned outputs.

Reviewers: #kwin, #plasma

Subscribers: plasma-devel, kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D8627
parent 26cdfd31
......@@ -43,6 +43,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include <KLocalizedString>
#include <KSharedConfig>
// Qt
#include <QMatrix4x4>
#include <QCryptographicHash>
// drm
#include <xf86drm.h>
......@@ -104,7 +105,15 @@ void DrmOutput::showCursor(DrmDumbBuffer *c)
void DrmOutput::moveCursor(const QPoint &globalPos)
{
const QPoint p = ((globalPos - m_globalPos) * m_scale) - m_backend->softwareCursorHotspot();
QMatrix4x4 matrix;
if (m_orientation == Qt::InvertedLandscapeOrientation) {
matrix.translate(pixelSize().width() /2, pixelSize().height() / 2);
matrix.rotate(180.0f, 0.0f, 0.0f, 1.0f);
matrix.translate(-pixelSize().width() /2, -pixelSize().height() / 2);
}
matrix.scale(m_scale);
matrix.translate(-m_globalPos.x(), -m_globalPos.y());
const QPoint p = matrix.map(globalPos) - m_backend->softwareCursorHotspot();
drmModeMoveCursor(m_backend->fd(), m_crtc->id(), p.x(), p.y());
}
......
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