Connect ThumbnailItem to Compositor::compositingToggled

If a KWin script uses a ThumbnailItem which gets created before the
Compositor is fully initialized the thumbnail is not shown at all because
the connect to windowAdded etc. will never happen.

Therefore connect to Compositor::compositingToggled to re-connect
whenever the compositing state changes.

REVIEW: 109310
This commit is contained in:
Martin Gräßlin 2013-03-06 09:46:25 +01:00
parent 7bf9fe6c37
commit 5891133111
2 changed files with 15 additions and 4 deletions

View file

@ -23,6 +23,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include "client.h" #include "client.h"
#include "effects.h" #include "effects.h"
#include "workspace.h" #include "workspace.h"
#include "composite.h"
// Qt // Qt
#include <QtDeclarative/QDeclarativeContext> #include <QtDeclarative/QDeclarativeContext>
#include <QtDeclarative/QDeclarativeEngine> #include <QtDeclarative/QDeclarativeEngine>
@ -40,10 +41,9 @@ ThumbnailItem::ThumbnailItem(QDeclarativeItem* parent)
, m_parentWindow(0) , m_parentWindow(0)
{ {
setFlags(flags() & ~QGraphicsItem::ItemHasNoContents); setFlags(flags() & ~QGraphicsItem::ItemHasNoContents);
if (effects) { Q_ASSERT(Compositor::isCreated());
connect(effects, SIGNAL(windowAdded(KWin::EffectWindow*)), SLOT(effectWindowAdded())); connect(Compositor::self(), SIGNAL(compositingToggled(bool)), SLOT(compositingToggled()));
connect(effects, SIGNAL(windowDamaged(KWin::EffectWindow*,QRect)), SLOT(repaint(KWin::EffectWindow*))); compositingToggled();
}
QTimer::singleShot(0, this, SLOT(init())); QTimer::singleShot(0, this, SLOT(init()));
} }
@ -51,6 +51,16 @@ ThumbnailItem::~ThumbnailItem()
{ {
} }
void ThumbnailItem::compositingToggled()
{
m_parent.clear();
if (effects) {
connect(effects, SIGNAL(windowAdded(KWin::EffectWindow*)), SLOT(effectWindowAdded()));
connect(effects, SIGNAL(windowDamaged(KWin::EffectWindow*,QRect)), SLOT(repaint(KWin::EffectWindow*)));
effectWindowAdded();
}
}
void ThumbnailItem::init() void ThumbnailItem::init()
{ {
findParentEffectWindow(); findParentEffectWindow();

View file

@ -60,6 +60,7 @@ private Q_SLOTS:
void init(); void init();
void effectWindowAdded(); void effectWindowAdded();
void repaint(KWin::EffectWindow* w); void repaint(KWin::EffectWindow* w);
void compositingToggled();
private: private:
void findParentEffectWindow(); void findParentEffectWindow();
qulonglong m_wId; qulonglong m_wId;