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.
This commit is contained in:
Martin Gräßlin 2015-02-23 14:41:45 +01:00
parent f1f87c7a7d
commit 147af71f8a
9 changed files with 29 additions and 36 deletions

View file

@ -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

View file

@ -79,7 +79,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include "shadow.h"
#include "thumbnailitem.h"
#include "workspace.h"
#if HAVE_WAYLAND
#include <KWayland/Server/buffer_interface.h>
@ -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()

View file

@ -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);

View file

@ -50,7 +50,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include "main.h"
#include "overlaywindow.h"
#include "screens.h"
#include "workspace.h"
#include "decorations/decoratedclient.h"
#include <array>
@ -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()
{

View file

@ -84,10 +84,10 @@ public:
static void copyPixels(const QRegion &region);
#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 &region, 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;

View file

@ -33,7 +33,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include <KWayland/Server/buffer_interface.h>
#include <KWayland/Server/surface_interface.h>
#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<QPainterBackend> 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())
{

View file

@ -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<QPainterBackend> m_backend;
QScopedPointer<QPainter> m_painter;
class Window;

View file

@ -32,7 +32,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#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<XRenderBackend> 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)
{
}

View file

@ -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 &region, ScreenPaintData &data);
private:
explicit SceneXrender(XRenderBackend *backend);
explicit SceneXrender(XRenderBackend *backend, QObject *parent = nullptr);
static ScreenPaintData screen_paint;
class Window;
QScopedPointer<XRenderBackend> m_backend;