diff --git a/pointer_input.cpp b/pointer_input.cpp index 64d7558312..a2dfdac05e 100644 --- a/pointer_input.cpp +++ b/pointer_input.cpp @@ -51,6 +51,7 @@ along with this program. If not, see . #include #include +#include // Wayland #include @@ -1221,6 +1222,7 @@ void CursorImage::updateDragCursor() if (auto dragIcon = ddi->icon()) { if (auto buffer = dragIcon->buffer()) { additionalIcon = buffer->data().copy(); + additionalIcon.setOffset(dragIcon->offset()); } } } @@ -1253,7 +1255,32 @@ void CursorImage::updateDragCursor() return; } m_drag.cursor.hotSpot = c->hotspot(); - m_drag.cursor.image = buffer->data().copy(); + + if (additionalIcon.isNull()) { + m_drag.cursor.image = buffer->data().copy(); + } else { + QRect cursorRect = buffer->data().rect(); + QRect iconRect = additionalIcon.rect(); + + if (-m_drag.cursor.hotSpot.x() < additionalIcon.offset().x()) { + iconRect.moveLeft(m_drag.cursor.hotSpot.x() - additionalIcon.offset().x()); + } else { + cursorRect.moveLeft(-additionalIcon.offset().x() - m_drag.cursor.hotSpot.x()); + } + if (-m_drag.cursor.hotSpot.y() < additionalIcon.offset().y()) { + iconRect.moveTop(m_drag.cursor.hotSpot.y() - additionalIcon.offset().y()); + } else { + cursorRect.moveTop(-additionalIcon.offset().y() - m_drag.cursor.hotSpot.y()); + } + + m_drag.cursor.image = QImage(cursorRect.united(iconRect).size(), QImage::Format_ARGB32_Premultiplied); + m_drag.cursor.image.fill(Qt::transparent); + QPainter p(&m_drag.cursor.image); + p.drawImage(iconRect, additionalIcon); + p.drawImage(cursorRect, buffer->data()); + p.end(); + } + if (needsEmit) { emit changed(); }