diff --git a/src/scene/cursoritem.cpp b/src/scene/cursoritem.cpp index 014f5516a1..160d408208 100644 --- a/src/scene/cursoritem.cpp +++ b/src/scene/cursoritem.cpp @@ -31,13 +31,13 @@ void CursorItem::refresh() { const CursorSource *source = Cursors::self()->currentCursor()->source(); if (auto surfaceSource = qobject_cast(source)) { - setSurface(surfaceSource->surface()); + setSurface(surfaceSource->surface(), surfaceSource->hotspot()); } else if (auto shapeSource = qobject_cast(source)) { - setImage(shapeSource->image()); + setImage(shapeSource->image(), shapeSource->hotspot()); } } -void CursorItem::setSurface(SurfaceInterface *surface) +void CursorItem::setSurface(SurfaceInterface *surface, const QPointF &hotspot) { m_imageItem.reset(); @@ -48,9 +48,12 @@ void CursorItem::setSurface(SurfaceInterface *surface) m_surfaceItem.reset(); } } + if (m_surfaceItem) { + m_surfaceItem->setPosition(-hotspot); + } } -void CursorItem::setImage(const QImage &image) +void CursorItem::setImage(const QImage &image, const QPointF &hotspot) { m_surfaceItem.reset(); @@ -58,6 +61,7 @@ void CursorItem::setImage(const QImage &image) m_imageItem = scene()->renderer()->createImageItem(scene(), this); } m_imageItem->setImage(image); + m_imageItem->setPosition(-hotspot); m_imageItem->setSize(image.size() / image.devicePixelRatio()); } diff --git a/src/scene/cursoritem.h b/src/scene/cursoritem.h index ca934c1107..22650ceb5a 100644 --- a/src/scene/cursoritem.h +++ b/src/scene/cursoritem.h @@ -25,8 +25,8 @@ public: private: void refresh(); - void setSurface(SurfaceInterface *surface); - void setImage(const QImage &image); + void setSurface(SurfaceInterface *surface, const QPointF &hotspot); + void setImage(const QImage &image, const QPointF &hotspot); std::unique_ptr m_imageItem; std::unique_ptr m_surfaceItem; diff --git a/src/scene/cursorscene.cpp b/src/scene/cursorscene.cpp index 49a118e9f3..912e5caf1d 100644 --- a/src/scene/cursorscene.cpp +++ b/src/scene/cursorscene.cpp @@ -55,7 +55,7 @@ void CursorScene::postPaint() void CursorScene::paint(const RenderTarget &renderTarget, const QRegion ®ion) { - RenderViewport viewport(QRectF(QPointF(), QSizeF(renderTarget.size()) / m_paintedOutput->scale()), m_paintedOutput->scale(), renderTarget); + RenderViewport viewport(QRectF(geometry().topLeft(), QSizeF(renderTarget.size()) / m_paintedOutput->scale()), m_paintedOutput->scale(), renderTarget); m_renderer->beginFrame(renderTarget, viewport); m_renderer->renderBackground(renderTarget, viewport, region); m_renderer->renderItem(renderTarget, viewport, m_rootItem.get(), 0, region, WindowPaintData{});