From 8e5b2ae1aa99f9fec496a5b5061b39901ac50ac3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Gr=C3=A4=C3=9Flin?= Date: Thu, 23 Aug 2012 18:04:36 +0200 Subject: [PATCH] Pass Compositor to EffectsHandlerImpl Obsoletes the need to go through the Workspace object to get to the Compositor. TODO for future: make the Compositor being the parent object for the EffectsHandlerImpl. Closing Review and bug from this commit, which is the top most of the patch series. REVIEW: 106060 BUG: 299277 FIXED-IN: 4.10 --- composite.cpp | 2 +- effects.cpp | 21 +++++++++++---------- effects.h | 4 +++- 3 files changed, 15 insertions(+), 12 deletions(-) diff --git a/composite.cpp b/composite.cpp index 3fe4213fc9..4837d8a9c0 100644 --- a/composite.cpp +++ b/composite.cpp @@ -214,7 +214,7 @@ void Compositor::slotCompositingOptionsInitialized() m_timeSinceLastVBlank = fpsInterval - 1; // means "start now" - we don't have even a slight idea when the first vsync will occur scheduleRepaint(); XCompositeRedirectSubwindows(display(), rootWindow(), CompositeRedirectManual); - new EffectsHandlerImpl(m_scene); // sets also the 'effects' pointer + new EffectsHandlerImpl(this, m_scene); // sets also the 'effects' pointer connect(effects, SIGNAL(screenGeometryChanged(QSize)), SLOT(addRepaintFull())); addRepaintFull(); foreach (Client * c, Workspace::self()->clientList()) diff --git a/effects.cpp b/effects.cpp index b90030ce55..cd7d7ee433 100644 --- a/effects.cpp +++ b/effects.cpp @@ -96,12 +96,13 @@ static void deleteWindowProperty(Window win, long int atom) //--------------------- -EffectsHandlerImpl::EffectsHandlerImpl(Scene *scene) +EffectsHandlerImpl::EffectsHandlerImpl(Compositor *compositor, Scene *scene) : EffectsHandler(scene->compositingType()) , keyboard_grab_effect(NULL) , fullscreen_effect(0) , next_window_quad_type(EFFECT_QUAD_TYPE_START) , mouse_poll_ref_count(0) + , m_compositor(compositor) , m_scene(scene) { // init is important, otherwise causes crashes when quads are build before the first painting pass start @@ -511,7 +512,7 @@ void EffectsHandlerImpl::slotPaddingChanged(Toplevel* t, const QRect& old) void EffectsHandlerImpl::setActiveFullScreenEffect(Effect* e) { fullscreen_effect = e; - Workspace::self()->compositor()->checkUnredirect(); + m_compositor->checkUnredirect(); } Effect* EffectsHandlerImpl::activeFullScreenEffect() const @@ -567,7 +568,7 @@ void* EffectsHandlerImpl::getProxy(QString name) void EffectsHandlerImpl::startMousePolling() { if (!mouse_poll_ref_count) // Start timer if required - Workspace::self()->compositor()->startMousePolling(); + m_compositor->startMousePolling(); mouse_poll_ref_count++; } @@ -576,7 +577,7 @@ void EffectsHandlerImpl::stopMousePolling() assert(mouse_poll_ref_count); mouse_poll_ref_count--; if (!mouse_poll_ref_count) // Stop timer if required - Workspace::self()->compositor()->stopMousePolling(); + m_compositor->stopMousePolling(); } bool EffectsHandlerImpl::hasKeyboardGrab() const @@ -909,22 +910,22 @@ EffectWindow* EffectsHandlerImpl::currentTabBoxWindow() const void EffectsHandlerImpl::addRepaintFull() { - Workspace::self()->compositor()->addRepaintFull(); + m_compositor->addRepaintFull(); } void EffectsHandlerImpl::addRepaint(const QRect& r) { - Workspace::self()->compositor()->addRepaint(r); + m_compositor->addRepaint(r); } void EffectsHandlerImpl::addRepaint(const QRegion& r) { - Workspace::self()->compositor()->addRepaint(r); + m_compositor->addRepaint(r); } void EffectsHandlerImpl::addRepaint(int x, int y, int w, int h) { - Workspace::self()->compositor()->addRepaint(x, y, w, h); + m_compositor->addRepaint(x, y, w, h); } int EffectsHandlerImpl::activeScreen() const @@ -1192,7 +1193,7 @@ QStringList EffectsHandlerImpl::listOfEffects() const bool EffectsHandlerImpl::loadEffect(const QString& name, bool checkDefault) { - Workspace::self()->compositor()->addRepaintFull(); + m_compositor->addRepaintFull(); if (!name.startsWith(QLatin1String("kwin4_effect_"))) kWarning(1212) << "Effect names usually have kwin4_effect_ prefix" ; @@ -1330,7 +1331,7 @@ bool EffectsHandlerImpl::loadScriptedEffect(const QString& name, KService *servi void EffectsHandlerImpl::unloadEffect(const QString& name) { - Workspace::self()->compositor()->addRepaintFull(); + m_compositor->addRepaintFull(); for (QMap< int, EffectPair >::iterator it = effect_order.begin(); it != effect_order.end(); ++it) { if (it.value().first == name) { diff --git a/effects.h b/effects.h index b6434b3ab9..8e67380c47 100644 --- a/effects.h +++ b/effects.h @@ -40,6 +40,7 @@ namespace KWin class ThumbnailItem; class Client; +class Compositor; class Deleted; class Unmanaged; @@ -47,7 +48,7 @@ class EffectsHandlerImpl : public EffectsHandler { Q_OBJECT public: - EffectsHandlerImpl(Scene *scene); + EffectsHandlerImpl(Compositor *compositor, Scene *scene); virtual ~EffectsHandlerImpl(); virtual void prePaintScreen(ScreenPrePaintData& data, int time); virtual void paintScreen(int mask, QRegion region, ScreenPaintData& data); @@ -228,6 +229,7 @@ private: QList< Effect* >::iterator m_currentPaintEffectFrameIterator; QList< Effect* >::iterator m_currentPaintScreenIterator; QList< Effect* >::iterator m_currentBuildQuadsIterator; + Compositor *m_compositor; Scene *m_scene; };