diff --git a/src/composite.cpp b/src/composite.cpp index d2b2a0a99a..98d5b868f9 100644 --- a/src/composite.cpp +++ b/src/composite.cpp @@ -366,7 +366,7 @@ void Compositor::startupWithWorkspace() const QList outputs = workspace()->outputs(); if (kwinApp()->operationMode() == Application::OperationModeX11) { auto workspaceLayer = new RenderLayer(outputs.constFirst()->renderLoop()); - workspaceLayer->setDelegate(new SceneDelegate(m_scene.get())); + workspaceLayer->setDelegate(std::make_unique(m_scene.get())); workspaceLayer->setGeometry(workspace()->geometry()); connect(workspace(), &Workspace::geometryChanged, workspaceLayer, [workspaceLayer]() { workspaceLayer->setGeometry(workspace()->geometry()); @@ -425,7 +425,7 @@ void Compositor::addOutput(Output *output) Q_ASSERT(kwinApp()->operationMode() != Application::OperationModeX11); auto workspaceLayer = new RenderLayer(output->renderLoop()); - workspaceLayer->setDelegate(new SceneDelegate(m_scene.get(), output)); + workspaceLayer->setDelegate(std::make_unique(m_scene.get(), output)); workspaceLayer->setGeometry(output->rect()); connect(output, &Output::geometryChanged, workspaceLayer, [output, workspaceLayer]() { workspaceLayer->setGeometry(output->rect()); @@ -434,9 +434,9 @@ void Compositor::addOutput(Output *output) auto cursorLayer = new RenderLayer(output->renderLoop()); cursorLayer->setVisible(false); if (m_backend->compositingType() == OpenGLCompositing) { - cursorLayer->setDelegate(new CursorDelegateOpenGL()); + cursorLayer->setDelegate(std::make_unique()); } else { - cursorLayer->setDelegate(new CursorDelegateQPainter()); + cursorLayer->setDelegate(std::make_unique()); } cursorLayer->setParent(workspaceLayer); cursorLayer->setSuperlayer(workspaceLayer); diff --git a/src/core/renderlayer.cpp b/src/core/renderlayer.cpp index 1687c39185..06bd06a6ce 100644 --- a/src/core/renderlayer.cpp +++ b/src/core/renderlayer.cpp @@ -95,9 +95,9 @@ RenderLayerDelegate *RenderLayer::delegate() const return m_delegate.get(); } -void RenderLayer::setDelegate(RenderLayerDelegate *delegate) +void RenderLayer::setDelegate(std::unique_ptr delegate) { - m_delegate.reset(delegate); + m_delegate = std::move(delegate); m_delegate->setLayer(this); } diff --git a/src/core/renderlayer.h b/src/core/renderlayer.h index 865dbd2c8e..c3ec33c8db 100644 --- a/src/core/renderlayer.h +++ b/src/core/renderlayer.h @@ -45,7 +45,7 @@ public: RenderLoop *loop() const; RenderLayerDelegate *delegate() const; - void setDelegate(RenderLayerDelegate *delegate); + void setDelegate(std::unique_ptr delegate); QList sublayers() const; RenderLayer *superlayer() const; diff --git a/src/core/renderlayerdelegate.cpp b/src/core/renderlayerdelegate.cpp index c3a1d2d0a8..c7d06e9df3 100644 --- a/src/core/renderlayerdelegate.cpp +++ b/src/core/renderlayerdelegate.cpp @@ -9,11 +9,6 @@ namespace KWin { -RenderLayerDelegate::RenderLayerDelegate(QObject *parent) - : QObject(parent) -{ -} - RenderLayer *RenderLayerDelegate::layer() const { return m_layer; diff --git a/src/core/renderlayerdelegate.h b/src/core/renderlayerdelegate.h index ec1e39b6e0..e726c4f123 100644 --- a/src/core/renderlayerdelegate.h +++ b/src/core/renderlayerdelegate.h @@ -8,7 +8,6 @@ #include "kwin_export.h" -#include #include namespace KWin @@ -21,12 +20,10 @@ class SurfaceItem; /** * The RenderLayerDelegate class represents a render layer's contents. */ -class KWIN_EXPORT RenderLayerDelegate : public QObject +class KWIN_EXPORT RenderLayerDelegate { - Q_OBJECT - public: - explicit RenderLayerDelegate(QObject *parent = nullptr); + virtual ~RenderLayerDelegate() = default; RenderLayer *layer() const; void setLayer(RenderLayer *layer); diff --git a/src/cursordelegate_opengl.cpp b/src/cursordelegate_opengl.cpp index 09e4052d57..f75c4c2d6f 100644 --- a/src/cursordelegate_opengl.cpp +++ b/src/cursordelegate_opengl.cpp @@ -14,11 +14,6 @@ namespace KWin { -CursorDelegateOpenGL::CursorDelegateOpenGL(QObject *parent) - : RenderLayerDelegate(parent) -{ -} - CursorDelegateOpenGL::~CursorDelegateOpenGL() { } diff --git a/src/cursordelegate_opengl.h b/src/cursordelegate_opengl.h index f543330e2d..6da31007fa 100644 --- a/src/cursordelegate_opengl.h +++ b/src/cursordelegate_opengl.h @@ -5,6 +5,7 @@ */ #pragma once +#include #include #include "core/renderlayerdelegate.h" @@ -14,12 +15,11 @@ namespace KWin class GLTexture; -class CursorDelegateOpenGL final : public RenderLayerDelegate +class CursorDelegateOpenGL final : public QObject, public RenderLayerDelegate { Q_OBJECT public: - explicit CursorDelegateOpenGL(QObject *parent = nullptr); ~CursorDelegateOpenGL() override; void paint(RenderTarget *renderTarget, const QRegion ®ion) override; diff --git a/src/cursordelegate_qpainter.cpp b/src/cursordelegate_qpainter.cpp index 2aa94a5bb9..674744a21e 100644 --- a/src/cursordelegate_qpainter.cpp +++ b/src/cursordelegate_qpainter.cpp @@ -14,11 +14,6 @@ namespace KWin { -CursorDelegateQPainter::CursorDelegateQPainter(QObject *parent) - : RenderLayerDelegate(parent) -{ -} - void CursorDelegateQPainter::paint(RenderTarget *renderTarget, const QRegion ®ion) { if (!region.intersects(layer()->mapToGlobal(layer()->rect()))) { diff --git a/src/cursordelegate_qpainter.h b/src/cursordelegate_qpainter.h index 376448b96a..80d29f5489 100644 --- a/src/cursordelegate_qpainter.h +++ b/src/cursordelegate_qpainter.h @@ -13,11 +13,7 @@ namespace KWin class CursorDelegateQPainter final : public RenderLayerDelegate { - Q_OBJECT - public: - explicit CursorDelegateQPainter(QObject *parent = nullptr); - void paint(RenderTarget *renderTarget, const QRegion ®ion) override; }; diff --git a/src/scene/scene.cpp b/src/scene/scene.cpp index 4a9e9a726c..eb1d495c86 100644 --- a/src/scene/scene.cpp +++ b/src/scene/scene.cpp @@ -79,16 +79,14 @@ namespace KWin { -SceneDelegate::SceneDelegate(Scene *scene, QObject *parent) - : RenderLayerDelegate(parent) - , m_scene(scene) +SceneDelegate::SceneDelegate(Scene *scene) + : m_scene(scene) { m_scene->addDelegate(this); } -SceneDelegate::SceneDelegate(Scene *scene, Output *output, QObject *parent) - : RenderLayerDelegate(parent) - , m_scene(scene) +SceneDelegate::SceneDelegate(Scene *scene, Output *output) + : m_scene(scene) , m_output(output) { m_scene->addDelegate(this); diff --git a/src/scene/scene.h b/src/scene/scene.h index 6deefd6c27..00ae48a0f0 100644 --- a/src/scene/scene.h +++ b/src/scene/scene.h @@ -44,11 +44,9 @@ class WindowItem; class SceneDelegate : public RenderLayerDelegate { - Q_OBJECT - public: - explicit SceneDelegate(Scene *scene, QObject *parent = nullptr); - explicit SceneDelegate(Scene *scene, Output *output, QObject *parent = nullptr); + explicit SceneDelegate(Scene *scene); + explicit SceneDelegate(Scene *scene, Output *output); ~SceneDelegate() override; Output *output() const;