From 736d99fc6a8e0a1b09f34de6da02a0fbb83e79c3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Gr=C3=A4=C3=9Flin?= Date: Tue, 28 Jun 2016 08:33:47 +0200 Subject: [PATCH] Properly trigger repaint for sofware cursor Summary: When the cursor changes the old and the new cursor geometry needs to be repainted. Also when the cursor image changes a repaint of old and new geometry is needed. To support this the current cursor geometry is tracked instead of just the cursor position. From the cursor position it's not possible to get to the cursor geometry once the cursor image or hotspot changes, thus the complete geometry needs tracking. CCBUG: 356328 Reviewers: #kwin, #plasma_on_wayland Subscribers: plasma-devel, kwin Tags: #plasma_on_wayland, #kwin Differential Revision: https://phabricator.kde.org/D2023 --- platform.cpp | 11 +++++------ platform.h | 2 +- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/platform.cpp b/platform.cpp index 83d444f80c..78eb41c38b 100644 --- a/platform.cpp +++ b/platform.cpp @@ -85,8 +85,10 @@ void Platform::setSoftWareCursor(bool set) m_softWareCursor = set; if (m_softWareCursor) { connect(Cursor::self(), &Cursor::posChanged, this, &Platform::triggerCursorRepaint); + connect(this, &Platform::cursorChanged, this, &Platform::triggerCursorRepaint); } else { disconnect(Cursor::self(), &Cursor::posChanged, this, &Platform::triggerCursorRepaint); + disconnect(this, &Platform::cursorChanged, this, &Platform::triggerCursorRepaint); } } @@ -95,17 +97,14 @@ void Platform::triggerCursorRepaint() if (!Compositor::self()) { return; } - const QPoint &hotSpot = softwareCursorHotspot(); - const QSize &size = softwareCursor().size(); - Compositor::self()->addRepaint(m_cursor.lastRenderedPosition.x() - hotSpot.x(), - m_cursor.lastRenderedPosition.y() - hotSpot.y(), - size.width(), size.height()); + Compositor::self()->addRepaint(m_cursor.lastRenderedGeometry); + Compositor::self()->addRepaint(QRect(Cursor::pos() - softwareCursorHotspot(), softwareCursor().size())); } void Platform::markCursorAsRendered() { if (m_softWareCursor) { - m_cursor.lastRenderedPosition = Cursor::pos(); + m_cursor.lastRenderedGeometry = QRect(Cursor::pos() - softwareCursorHotspot(), softwareCursor().size()); } if (input()->pointer()) { input()->pointer()->markCursorAsRendered(); diff --git a/platform.h b/platform.h index 9254d38932..d6ea45a49b 100644 --- a/platform.h +++ b/platform.h @@ -222,7 +222,7 @@ private: void triggerCursorRepaint(); bool m_softWareCursor = false; struct { - QPoint lastRenderedPosition; + QRect lastRenderedGeometry; } m_cursor; bool m_handlesOutputs = false; bool m_ready = false;