From 58911331117f7abd1b1a644855cdc56f9b16d54b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Gr=C3=A4=C3=9Flin?= Date: Wed, 6 Mar 2013 09:46:25 +0100 Subject: [PATCH] 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 --- thumbnailitem.cpp | 18 ++++++++++++++---- thumbnailitem.h | 1 + 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/thumbnailitem.cpp b/thumbnailitem.cpp index b2685be71e..66b665a685 100644 --- a/thumbnailitem.cpp +++ b/thumbnailitem.cpp @@ -23,6 +23,7 @@ along with this program. If not, see . #include "client.h" #include "effects.h" #include "workspace.h" +#include "composite.h" // Qt #include #include @@ -40,10 +41,9 @@ ThumbnailItem::ThumbnailItem(QDeclarativeItem* parent) , m_parentWindow(0) { setFlags(flags() & ~QGraphicsItem::ItemHasNoContents); - if (effects) { - connect(effects, SIGNAL(windowAdded(KWin::EffectWindow*)), SLOT(effectWindowAdded())); - connect(effects, SIGNAL(windowDamaged(KWin::EffectWindow*,QRect)), SLOT(repaint(KWin::EffectWindow*))); - } + Q_ASSERT(Compositor::isCreated()); + connect(Compositor::self(), SIGNAL(compositingToggled(bool)), SLOT(compositingToggled())); + compositingToggled(); 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() { findParentEffectWindow(); diff --git a/thumbnailitem.h b/thumbnailitem.h index a219a33d13..885702dd26 100644 --- a/thumbnailitem.h +++ b/thumbnailitem.h @@ -60,6 +60,7 @@ private Q_SLOTS: void init(); void effectWindowAdded(); void repaint(KWin::EffectWindow* w); + void compositingToggled(); private: void findParentEffectWindow(); qulonglong m_wId;