From 21691fe5707608cd3175f3d35f280b65355ffbdf Mon Sep 17 00:00:00 2001 From: Vlad Zahorodnii Date: Fri, 6 Sep 2024 19:46:07 +0300 Subject: [PATCH] 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 --- src/compositor_wayland.cpp | 4 ++-- src/scene/cursordelegate_opengl.cpp | 5 +++-- src/scene/cursordelegate_opengl.h | 8 +++----- src/scene/cursordelegate_qpainter.cpp | 5 +++-- src/scene/cursordelegate_qpainter.h | 6 +++--- src/scene/cursorscene.cpp | 2 +- 6 files changed, 15 insertions(+), 15 deletions(-) diff --git a/src/compositor_wayland.cpp b/src/compositor_wayland.cpp index 4e1c7358cc..420592f54c 100644 --- a/src/compositor_wayland.cpp +++ b/src/compositor_wayland.cpp @@ -416,9 +416,9 @@ void WaylandCompositor::addOutput(Output *output) auto cursorLayer = new RenderLayer(output->renderLoop()); cursorLayer->setVisible(false); if (m_backend->compositingType() == OpenGLCompositing) { - cursorLayer->setDelegate(std::make_unique(output)); + cursorLayer->setDelegate(std::make_unique(m_cursorScene.get(), output)); } else { - cursorLayer->setDelegate(std::make_unique(output)); + cursorLayer->setDelegate(std::make_unique(m_cursorScene.get(), output)); } cursorLayer->setParent(workspaceLayer); cursorLayer->setSuperlayer(workspaceLayer); diff --git a/src/scene/cursordelegate_opengl.cpp b/src/scene/cursordelegate_opengl.cpp index b1dd5cee73..93ba6f3a82 100644 --- a/src/scene/cursordelegate_opengl.cpp +++ b/src/scene/cursordelegate_opengl.cpp @@ -21,8 +21,9 @@ namespace KWin { -CursorDelegateOpenGL::CursorDelegateOpenGL(Output *output) - : m_output(output) +CursorDelegateOpenGL::CursorDelegateOpenGL(Scene *scene, Output *output) + : SceneDelegate(scene, nullptr) + , m_output(output) { } diff --git a/src/scene/cursordelegate_opengl.h b/src/scene/cursordelegate_opengl.h index 20ae8048c0..97c6fa59e6 100644 --- a/src/scene/cursordelegate_opengl.h +++ b/src/scene/cursordelegate_opengl.h @@ -5,10 +5,8 @@ */ #pragma once -#include -#include -#include "core/renderlayerdelegate.h" +#include "scene/scene.h" namespace KWin { @@ -17,12 +15,12 @@ class GLFramebuffer; class GLTexture; class Output; -class CursorDelegateOpenGL final : public QObject, public RenderLayerDelegate +class CursorDelegateOpenGL final : public QObject, public SceneDelegate { Q_OBJECT public: - CursorDelegateOpenGL(Output *output); + CursorDelegateOpenGL(Scene *scene, Output *output); ~CursorDelegateOpenGL() override; void paint(const RenderTarget &renderTarget, const QRegion ®ion) override; diff --git a/src/scene/cursordelegate_qpainter.cpp b/src/scene/cursordelegate_qpainter.cpp index 5c4e8cb6ff..5d922bbed9 100644 --- a/src/scene/cursordelegate_qpainter.cpp +++ b/src/scene/cursordelegate_qpainter.cpp @@ -18,8 +18,9 @@ namespace KWin { -CursorDelegateQPainter::CursorDelegateQPainter(Output *output) - : m_output(output) +CursorDelegateQPainter::CursorDelegateQPainter(Scene *scene, Output *output) + : SceneDelegate(scene, nullptr) + , m_output(output) { } diff --git a/src/scene/cursordelegate_qpainter.h b/src/scene/cursordelegate_qpainter.h index 4cbe013038..6ab606ef33 100644 --- a/src/scene/cursordelegate_qpainter.h +++ b/src/scene/cursordelegate_qpainter.h @@ -6,7 +6,7 @@ #pragma once -#include "core/renderlayerdelegate.h" +#include "scene/scene.h" #include @@ -15,10 +15,10 @@ namespace KWin class Output; -class CursorDelegateQPainter final : public RenderLayerDelegate +class CursorDelegateQPainter final : public SceneDelegate { public: - CursorDelegateQPainter(Output *output); + CursorDelegateQPainter(Scene *scene, Output *output); void paint(const RenderTarget &renderTarget, const QRegion ®ion) override; diff --git a/src/scene/cursorscene.cpp b/src/scene/cursorscene.cpp index 1e8a3cb95d..7c9c271ce4 100644 --- a/src/scene/cursorscene.cpp +++ b/src/scene/cursorscene.cpp @@ -48,7 +48,7 @@ QRegion CursorScene::prePaint(SceneDelegate *delegate) { resetRepaintsHelper(m_rootItem.get(), delegate); m_paintedOutput = delegate->output(); - return QRegion(); + return m_rootItem->boundingRect().translated(-delegate->viewport().topLeft()).toAlignedRect(); } void CursorScene::postPaint()