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
This commit is contained in:
Martin Gräßlin 2016-06-28 08:33:47 +02:00
parent 7adf69dece
commit 736d99fc6a
2 changed files with 6 additions and 7 deletions

View file

@ -85,8 +85,10 @@ void Platform::setSoftWareCursor(bool set)
m_softWareCursor = set; m_softWareCursor = set;
if (m_softWareCursor) { if (m_softWareCursor) {
connect(Cursor::self(), &Cursor::posChanged, this, &Platform::triggerCursorRepaint); connect(Cursor::self(), &Cursor::posChanged, this, &Platform::triggerCursorRepaint);
connect(this, &Platform::cursorChanged, this, &Platform::triggerCursorRepaint);
} else { } else {
disconnect(Cursor::self(), &Cursor::posChanged, this, &Platform::triggerCursorRepaint); 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()) { if (!Compositor::self()) {
return; return;
} }
const QPoint &hotSpot = softwareCursorHotspot(); Compositor::self()->addRepaint(m_cursor.lastRenderedGeometry);
const QSize &size = softwareCursor().size(); Compositor::self()->addRepaint(QRect(Cursor::pos() - softwareCursorHotspot(), softwareCursor().size()));
Compositor::self()->addRepaint(m_cursor.lastRenderedPosition.x() - hotSpot.x(),
m_cursor.lastRenderedPosition.y() - hotSpot.y(),
size.width(), size.height());
} }
void Platform::markCursorAsRendered() void Platform::markCursorAsRendered()
{ {
if (m_softWareCursor) { if (m_softWareCursor) {
m_cursor.lastRenderedPosition = Cursor::pos(); m_cursor.lastRenderedGeometry = QRect(Cursor::pos() - softwareCursorHotspot(), softwareCursor().size());
} }
if (input()->pointer()) { if (input()->pointer()) {
input()->pointer()->markCursorAsRendered(); input()->pointer()->markCursorAsRendered();

View file

@ -222,7 +222,7 @@ private:
void triggerCursorRepaint(); void triggerCursorRepaint();
bool m_softWareCursor = false; bool m_softWareCursor = false;
struct { struct {
QPoint lastRenderedPosition; QRect lastRenderedGeometry;
} m_cursor; } m_cursor;
bool m_handlesOutputs = false; bool m_handlesOutputs = false;
bool m_ready = false; bool m_ready = false;