diff --git a/effects/fallapart/fallapart.cpp b/effects/fallapart/fallapart.cpp index 08cddcc2f1..4e928bbc11 100644 --- a/effects/fallapart/fallapart.cpp +++ b/effects/fallapart/fallapart.cpp @@ -38,6 +38,7 @@ FallApartEffect::FallApartEffect() reconfigure(ReconfigureAll); connect(effects, SIGNAL(windowClosed(KWin::EffectWindow*)), this, SLOT(slotWindowClosed(KWin::EffectWindow*))); connect(effects, SIGNAL(windowDeleted(KWin::EffectWindow*)), this, SLOT(slotWindowDeleted(KWin::EffectWindow*))); + connect(effects, SIGNAL(windowDataChanged(KWin::EffectWindow*,int)), this, SLOT(slotWindowDataChanged(KWin::EffectWindow*,int))); } void FallApartEffect::reconfigure(ReconfigureFlags) @@ -157,6 +158,7 @@ void FallApartEffect::slotWindowClosed(EffectWindow* c) const void* e = c->data(WindowClosedGrabRole).value(); if (e && e != this) return; + c->setData(WindowClosedGrabRole, QVariant::fromValue(static_cast(this))); windows[ c ] = 0; c->refWindow(); } @@ -166,6 +168,25 @@ void FallApartEffect::slotWindowDeleted(EffectWindow* c) windows.remove(c); } +void FallApartEffect::slotWindowDataChanged(EffectWindow* w, int role) +{ + if (role != WindowClosedGrabRole) { + return; + } + + if (w->data(role).value() == this) { + return; + } + + auto it = windows.find(w); + if (it == windows.end()) { + return; + } + + it.key()->unrefWindow(); + windows.erase(it); +} + bool FallApartEffect::isActive() const { return !windows.isEmpty(); diff --git a/effects/fallapart/fallapart.h b/effects/fallapart/fallapart.h index 6ac3d93914..b8d27a5885 100644 --- a/effects/fallapart/fallapart.h +++ b/effects/fallapart/fallapart.h @@ -54,9 +54,10 @@ public: public Q_SLOTS: void slotWindowClosed(KWin::EffectWindow *c); void slotWindowDeleted(KWin::EffectWindow *w); + void slotWindowDataChanged(KWin::EffectWindow *w, int role); private: - QHash< const EffectWindow*, double > windows; + QHash< EffectWindow*, double > windows; bool isRealWindow(EffectWindow* w); int blockSize; };