scene: Fix animated software cursor not updating

The Item schedules repaints per scene delegate. Currently, there are no
any attached scene delegates when using software cursor, which results in
it freezing as soon as it stops moving.

The issue is addressed by using SceneDelegate instead of RenderLayerDelegate.

The proposed code is not great, but on the other hand, the plan is to
embed the software cursor in the workspace scene if needed.

BUG: 490440
This commit is contained in:
Vlad Zahorodnii 2024-09-06 19:46:07 +03:00
parent 8b95810e17
commit 21691fe570
6 changed files with 15 additions and 15 deletions

View file

@ -416,9 +416,9 @@ void WaylandCompositor::addOutput(Output *output)
auto cursorLayer = new RenderLayer(output->renderLoop()); auto cursorLayer = new RenderLayer(output->renderLoop());
cursorLayer->setVisible(false); cursorLayer->setVisible(false);
if (m_backend->compositingType() == OpenGLCompositing) { if (m_backend->compositingType() == OpenGLCompositing) {
cursorLayer->setDelegate(std::make_unique<CursorDelegateOpenGL>(output)); cursorLayer->setDelegate(std::make_unique<CursorDelegateOpenGL>(m_cursorScene.get(), output));
} else { } else {
cursorLayer->setDelegate(std::make_unique<CursorDelegateQPainter>(output)); cursorLayer->setDelegate(std::make_unique<CursorDelegateQPainter>(m_cursorScene.get(), output));
} }
cursorLayer->setParent(workspaceLayer); cursorLayer->setParent(workspaceLayer);
cursorLayer->setSuperlayer(workspaceLayer); cursorLayer->setSuperlayer(workspaceLayer);

View file

@ -21,8 +21,9 @@
namespace KWin namespace KWin
{ {
CursorDelegateOpenGL::CursorDelegateOpenGL(Output *output) CursorDelegateOpenGL::CursorDelegateOpenGL(Scene *scene, Output *output)
: m_output(output) : SceneDelegate(scene, nullptr)
, m_output(output)
{ {
} }

View file

@ -5,10 +5,8 @@
*/ */
#pragma once #pragma once
#include <QObject>
#include <memory>
#include "core/renderlayerdelegate.h" #include "scene/scene.h"
namespace KWin namespace KWin
{ {
@ -17,12 +15,12 @@ class GLFramebuffer;
class GLTexture; class GLTexture;
class Output; class Output;
class CursorDelegateOpenGL final : public QObject, public RenderLayerDelegate class CursorDelegateOpenGL final : public QObject, public SceneDelegate
{ {
Q_OBJECT Q_OBJECT
public: public:
CursorDelegateOpenGL(Output *output); CursorDelegateOpenGL(Scene *scene, Output *output);
~CursorDelegateOpenGL() override; ~CursorDelegateOpenGL() override;
void paint(const RenderTarget &renderTarget, const QRegion &region) override; void paint(const RenderTarget &renderTarget, const QRegion &region) override;

View file

@ -18,8 +18,9 @@
namespace KWin namespace KWin
{ {
CursorDelegateQPainter::CursorDelegateQPainter(Output *output) CursorDelegateQPainter::CursorDelegateQPainter(Scene *scene, Output *output)
: m_output(output) : SceneDelegate(scene, nullptr)
, m_output(output)
{ {
} }

View file

@ -6,7 +6,7 @@
#pragma once #pragma once
#include "core/renderlayerdelegate.h" #include "scene/scene.h"
#include <QImage> #include <QImage>
@ -15,10 +15,10 @@ namespace KWin
class Output; class Output;
class CursorDelegateQPainter final : public RenderLayerDelegate class CursorDelegateQPainter final : public SceneDelegate
{ {
public: public:
CursorDelegateQPainter(Output *output); CursorDelegateQPainter(Scene *scene, Output *output);
void paint(const RenderTarget &renderTarget, const QRegion &region) override; void paint(const RenderTarget &renderTarget, const QRegion &region) override;

View file

@ -48,7 +48,7 @@ QRegion CursorScene::prePaint(SceneDelegate *delegate)
{ {
resetRepaintsHelper(m_rootItem.get(), delegate); resetRepaintsHelper(m_rootItem.get(), delegate);
m_paintedOutput = delegate->output(); m_paintedOutput = delegate->output();
return QRegion(); return m_rootItem->boundingRect().translated(-delegate->viewport().topLeft()).toAlignedRect();
} }
void CursorScene::postPaint() void CursorScene::postPaint()