From 147af71f8a146ba60c374fe1c6e3627288643dc5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Gr=C3=A4=C3=9Flin?= Date: Mon, 23 Feb 2015 14:41:45 +0100 Subject: [PATCH] Drop Workspace dependency from Scene Only used for one connect which can also be done outside of Scene. Subclasses got the singleton pointer and just passed to the parent. --- composite.cpp | 7 ++++--- scene.cpp | 7 ++----- scene.h | 4 +--- scene_opengl.cpp | 13 ++++++------- scene_opengl.h | 6 +++--- scene_qpainter.cpp | 9 ++++----- scene_qpainter.h | 4 ++-- scene_xrender.cpp | 11 +++++------ scene_xrender.h | 4 ++-- 9 files changed, 29 insertions(+), 36 deletions(-) diff --git a/composite.cpp b/composite.cpp index ef4d66a069..273c2e709b 100644 --- a/composite.cpp +++ b/composite.cpp @@ -215,7 +215,7 @@ void Compositor::slotCompositingOptionsInitialized() } #endif - m_scene = SceneOpenGL::createScene(); + m_scene = SceneOpenGL::createScene(this); // TODO: Add 30 second delay to protect against screen freezes as well unsafeConfig.writeEntry(openGLIsUnsafe, false); @@ -235,12 +235,12 @@ void Compositor::slotCompositingOptionsInitialized() #ifdef KWIN_HAVE_XRENDER_COMPOSITING case XRenderCompositing: qCDebug(KWIN_CORE) << "Initializing XRender compositing"; - m_scene = SceneXrender::createScene(); + m_scene = SceneXrender::createScene(this); break; #endif case QPainterCompositing: qCDebug(KWIN_CORE) << "Initializing QPainter compositing"; - m_scene = SceneQPainter::createScene(); + m_scene = SceneQPainter::createScene(this); break; default: qCDebug(KWIN_CORE) << "No compositing enabled"; @@ -268,6 +268,7 @@ void Compositor::slotCompositingOptionsInitialized() } return; } + connect(Workspace::self(), &Workspace::deletedRemoved, m_scene, &Scene::windowDeleted); m_xrrRefreshRate = KWin::currentRefreshRate(); fpsInterval = options->maxFpsInterval(); if (m_scene->syncsToVBlank()) { // if we do vsync, set the fps to the next multiple of the vblank rate diff --git a/scene.cpp b/scene.cpp index 37e1c3a42b..0766ceea70 100644 --- a/scene.cpp +++ b/scene.cpp @@ -79,7 +79,6 @@ along with this program. If not, see . #include "shadow.h" #include "thumbnailitem.h" -#include "workspace.h" #if HAVE_WAYLAND #include @@ -93,12 +92,10 @@ namespace KWin // Scene //**************************************** -Scene::Scene(Workspace* ws) - : QObject(ws) - , wspace(ws) +Scene::Scene(QObject *parent) + : QObject(parent) { last_time.invalidate(); // Initialize the timer - connect(Workspace::self(), SIGNAL(deletedRemoved(KWin::Deleted*)), SLOT(windowDeleted(KWin::Deleted*))); } Scene::~Scene() diff --git a/scene.h b/scene.h index bb68fbc548..9e41cccc2d 100644 --- a/scene.h +++ b/scene.h @@ -47,7 +47,6 @@ class Renderer; } class AbstractThumbnailItem; -class Workspace; class Deleted; class EffectFrameImpl; class EffectWindowImpl; @@ -60,7 +59,7 @@ class Scene : public QObject { Q_OBJECT public: - explicit Scene(Workspace* ws); + explicit Scene(QObject *parent = nullptr); virtual ~Scene() = 0; class EffectFrame; class Window; @@ -209,7 +208,6 @@ protected: // time since last repaint int time_diff; QElapsedTimer last_time; - Workspace* wspace; private: void paintWindowThumbnails(Scene::Window *w, QRegion region, qreal opacity, qreal brightness, qreal saturation); void paintDesktopThumbnails(Scene::Window *w); diff --git a/scene_opengl.cpp b/scene_opengl.cpp index b9d43fc8dd..f1033c237d 100644 --- a/scene_opengl.cpp +++ b/scene_opengl.cpp @@ -50,7 +50,6 @@ along with this program. If not, see . #include "main.h" #include "overlaywindow.h" #include "screens.h" -#include "workspace.h" #include "decorations/decoratedclient.h" #include @@ -350,8 +349,8 @@ OverlayWindow* OpenGLBackend::overlayWindow() * SceneOpenGL ***********************************************/ -SceneOpenGL::SceneOpenGL(Workspace* ws, OpenGLBackend *backend) - : Scene(ws) +SceneOpenGL::SceneOpenGL(OpenGLBackend *backend, QObject *parent) + : Scene(parent) , init_ok(true) , m_backend(backend) , m_syncManager(nullptr) @@ -471,7 +470,7 @@ void SceneOpenGL::initDebugOutput() GL_DEBUG_SEVERITY_LOW, message.length(), message.constData()); } -SceneOpenGL *SceneOpenGL::createScene() +SceneOpenGL *SceneOpenGL::createScene(QObject *parent) { OpenGLBackend *backend = NULL; OpenGLPlatformInterface platformInterface = options->glPlatformInterface(); @@ -506,7 +505,7 @@ SceneOpenGL *SceneOpenGL::createScene() SceneOpenGL *scene = NULL; // first let's try an OpenGL 2 scene if (SceneOpenGL2::supported(backend)) { - scene = new SceneOpenGL2(backend); + scene = new SceneOpenGL2(backend, parent); if (scene->initFailed()) { delete scene; scene = NULL; @@ -904,8 +903,8 @@ bool SceneOpenGL2::supported(OpenGLBackend *backend) return true; } -SceneOpenGL2::SceneOpenGL2(OpenGLBackend *backend) - : SceneOpenGL(Workspace::self(), backend) +SceneOpenGL2::SceneOpenGL2(OpenGLBackend *backend, QObject *parent) + : SceneOpenGL(backend, parent) , m_lanczosFilter(NULL) , m_colorCorrection() { diff --git a/scene_opengl.h b/scene_opengl.h index d0eb1f6b70..f76fd7ec9e 100644 --- a/scene_opengl.h +++ b/scene_opengl.h @@ -84,10 +84,10 @@ public: static void copyPixels(const QRegion ®ion); #endif - static SceneOpenGL *createScene(); + static SceneOpenGL *createScene(QObject *parent); protected: - SceneOpenGL(Workspace* ws, OpenGLBackend *backend); + SceneOpenGL(OpenGLBackend *backend, QObject *parent = nullptr); virtual void paintBackground(QRegion region); virtual void extendPaintRegion(QRegion ®ion, bool opaqueFullscreen); QMatrix4x4 transformation(int mask, const ScreenPaintData &data) const; @@ -115,7 +115,7 @@ class SceneOpenGL2 : public SceneOpenGL { Q_OBJECT public: - explicit SceneOpenGL2(OpenGLBackend *backend); + explicit SceneOpenGL2(OpenGLBackend *backend, QObject *parent = nullptr); virtual ~SceneOpenGL2(); virtual CompositingType compositingType() const { return OpenGL2Compositing; diff --git a/scene_qpainter.cpp b/scene_qpainter.cpp index 1f21755885..e6001dcbf0 100644 --- a/scene_qpainter.cpp +++ b/scene_qpainter.cpp @@ -33,7 +33,6 @@ along with this program. If not, see . #include #include #endif -#include "workspace.h" #include "xcbutils.h" #include "decorations/decoratedclient.h" // Qt @@ -188,7 +187,7 @@ bool WaylandQPainterBackend::needsFullRepaint() const //**************************************** // SceneQPainter //**************************************** -SceneQPainter *SceneQPainter::createScene() +SceneQPainter *SceneQPainter::createScene(QObject *parent) { QScopedPointer backend; #if HAVE_WAYLAND @@ -197,14 +196,14 @@ SceneQPainter *SceneQPainter::createScene() if (backend->isFailed()) { return NULL; } - return new SceneQPainter(backend.take()); + return new SceneQPainter(backend.take(), parent); } #endif return NULL; } -SceneQPainter::SceneQPainter(QPainterBackend* backend) - : Scene(Workspace::self()) +SceneQPainter::SceneQPainter(QPainterBackend *backend, QObject *parent) + : Scene(parent) , m_backend(backend) , m_painter(new QPainter()) { diff --git a/scene_qpainter.h b/scene_qpainter.h index d3b8bb8f58..ff8f8c839f 100644 --- a/scene_qpainter.h +++ b/scene_qpainter.h @@ -144,14 +144,14 @@ public: QPainter *painter(); - static SceneQPainter *createScene(); + static SceneQPainter *createScene(QObject *parent); protected: virtual void paintBackground(QRegion region) override; virtual Scene::Window *createWindow(Toplevel *toplevel) override; private: - explicit SceneQPainter(QPainterBackend *backend); + explicit SceneQPainter(QPainterBackend *backend, QObject *parent = nullptr); QScopedPointer m_backend; QScopedPointer m_painter; class Window; diff --git a/scene_xrender.cpp b/scene_xrender.cpp index 47d9d839c4..256454588f 100644 --- a/scene_xrender.cpp +++ b/scene_xrender.cpp @@ -32,7 +32,6 @@ along with this program. If not, see . #include "effects.h" #include "main.h" #include "overlaywindow.h" -#include "workspace.h" #include "xcbutils.h" #include "kwinxrenderutils.h" #if HAVE_WAYLAND @@ -309,7 +308,7 @@ bool WaylandXRenderBackend::usesOverlayWindow() const //**************************************** // SceneXrender //**************************************** -SceneXrender* SceneXrender::createScene() +SceneXrender* SceneXrender::createScene(QObject *parent) { QScopedPointer backend; #if HAVE_WAYLAND @@ -318,18 +317,18 @@ SceneXrender* SceneXrender::createScene() if (backend->isFailed()) { return NULL; } - return new SceneXrender(backend.take()); + return new SceneXrender(backend.take(), parent); } #endif backend.reset(new X11XRenderBackend); if (backend->isFailed()) { return NULL; } - return new SceneXrender(backend.take()); + return new SceneXrender(backend.take(), parent); } -SceneXrender::SceneXrender(XRenderBackend *backend) - : Scene(Workspace::self()) +SceneXrender::SceneXrender(XRenderBackend *backend, QObject *parent) + : Scene(parent) , m_backend(backend) { } diff --git a/scene_xrender.h b/scene_xrender.h index 0ff87f36b3..d8bf405c00 100644 --- a/scene_xrender.h +++ b/scene_xrender.h @@ -187,14 +187,14 @@ public: } Decoration::Renderer *createDecorationRenderer(Decoration::DecoratedClientImpl *client); - static SceneXrender *createScene(); + static SceneXrender *createScene(QObject *parent); protected: virtual Scene::Window *createWindow(Toplevel *toplevel); virtual void paintBackground(QRegion region); virtual void paintGenericScreen(int mask, ScreenPaintData data); virtual void paintDesktop(int desktop, int mask, const QRegion ®ion, ScreenPaintData &data); private: - explicit SceneXrender(XRenderBackend *backend); + explicit SceneXrender(XRenderBackend *backend, QObject *parent = nullptr); static ScreenPaintData screen_paint; class Window; QScopedPointer m_backend;