Changeset View
Changeset View
Standalone View
Standalone View
effects/fallapart/fallapart.cpp
Show All 32 Lines | |||||
33 | } | 33 | } | ||
34 | 34 | | |||
35 | FallApartEffect::FallApartEffect() | 35 | FallApartEffect::FallApartEffect() | ||
36 | { | 36 | { | ||
37 | initConfig<FallApartConfig>(); | 37 | initConfig<FallApartConfig>(); | ||
38 | reconfigure(ReconfigureAll); | 38 | reconfigure(ReconfigureAll); | ||
39 | connect(effects, SIGNAL(windowClosed(KWin::EffectWindow*)), this, SLOT(slotWindowClosed(KWin::EffectWindow*))); | 39 | connect(effects, SIGNAL(windowClosed(KWin::EffectWindow*)), this, SLOT(slotWindowClosed(KWin::EffectWindow*))); | ||
40 | connect(effects, SIGNAL(windowDeleted(KWin::EffectWindow*)), this, SLOT(slotWindowDeleted(KWin::EffectWindow*))); | 40 | connect(effects, SIGNAL(windowDeleted(KWin::EffectWindow*)), this, SLOT(slotWindowDeleted(KWin::EffectWindow*))); | ||
41 | connect(effects, SIGNAL(windowDataChanged(KWin::EffectWindow*,int)), this, SLOT(slotWindowDataChanged(KWin::EffectWindow*,int))); | ||||
41 | } | 42 | } | ||
42 | 43 | | |||
43 | void FallApartEffect::reconfigure(ReconfigureFlags) | 44 | void FallApartEffect::reconfigure(ReconfigureFlags) | ||
44 | { | 45 | { | ||
45 | FallApartConfig::self()->read(); | 46 | FallApartConfig::self()->read(); | ||
46 | blockSize = FallApartConfig::blockSize(); | 47 | blockSize = FallApartConfig::blockSize(); | ||
47 | } | 48 | } | ||
48 | 49 | | |||
▲ Show 20 Lines • Show All 103 Lines • ▼ Show 20 Line(s) | |||||
152 | { | 153 | { | ||
153 | if (!isRealWindow(c)) | 154 | if (!isRealWindow(c)) | ||
154 | return; | 155 | return; | ||
155 | if (!c->isVisible()) | 156 | if (!c->isVisible()) | ||
156 | return; | 157 | return; | ||
157 | const void* e = c->data(WindowClosedGrabRole).value<void*>(); | 158 | const void* e = c->data(WindowClosedGrabRole).value<void*>(); | ||
158 | if (e && e != this) | 159 | if (e && e != this) | ||
159 | return; | 160 | return; | ||
161 | c->setData(WindowClosedGrabRole, QVariant::fromValue(static_cast<void*>(this))); | ||||
160 | windows[ c ] = 0; | 162 | windows[ c ] = 0; | ||
161 | c->refWindow(); | 163 | c->refWindow(); | ||
162 | } | 164 | } | ||
163 | 165 | | |||
164 | void FallApartEffect::slotWindowDeleted(EffectWindow* c) | 166 | void FallApartEffect::slotWindowDeleted(EffectWindow* c) | ||
165 | { | 167 | { | ||
166 | windows.remove(c); | 168 | windows.remove(c); | ||
167 | } | 169 | } | ||
168 | 170 | | |||
171 | void FallApartEffect::slotWindowDataChanged(EffectWindow* w, int role) | ||||
172 | { | ||||
173 | if (role != WindowClosedGrabRole) { | ||||
174 | return; | ||||
175 | } | ||||
176 | | ||||
177 | if (w->data(role).value<void*>() == this) { | ||||
178 | return; | ||||
179 | } | ||||
180 | | ||||
181 | auto it = windows.find(w); | ||||
182 | if (it == windows.end()) { | ||||
183 | return; | ||||
184 | } | ||||
185 | | ||||
186 | it.key()->unrefWindow(); | ||||
187 | windows.erase(it); | ||||
188 | } | ||||
189 | | ||||
169 | bool FallApartEffect::isActive() const | 190 | bool FallApartEffect::isActive() const | ||
170 | { | 191 | { | ||
171 | return !windows.isEmpty(); | 192 | return !windows.isEmpty(); | ||
172 | } | 193 | } | ||
173 | 194 | | |||
174 | } // namespace | 195 | } // namespace |