Changeset View
Changeset View
Standalone View
Standalone View
effects/slidingpopups/slidingpopups.cpp
Show All 37 Lines | 35 | { | |||
---|---|---|---|---|---|
38 | if (display) { | 38 | if (display) { | ||
39 | display->createSlideManager(this)->create(); | 39 | display->createSlideManager(this)->create(); | ||
40 | } | 40 | } | ||
41 | 41 | | |||
42 | mSlideLength = QFontMetrics(qApp->font()).height() * 8; | 42 | mSlideLength = QFontMetrics(qApp->font()).height() * 8; | ||
43 | 43 | | |||
44 | mAtom = effects->announceSupportProperty("_KDE_SLIDE", this); | 44 | mAtom = effects->announceSupportProperty("_KDE_SLIDE", this); | ||
45 | connect(effects, SIGNAL(windowAdded(KWin::EffectWindow*)), this, SLOT(slotWindowAdded(KWin::EffectWindow*))); | 45 | connect(effects, SIGNAL(windowAdded(KWin::EffectWindow*)), this, SLOT(slotWindowAdded(KWin::EffectWindow*))); | ||
46 | connect(effects, SIGNAL(windowClosed(KWin::EffectWindow*)), this, SLOT(slotWindowClosed(KWin::EffectWindow*))); | 46 | connect(effects, &EffectsHandler::windowClosed, this, &SlidingPopupsEffect::slideOut); | ||
47 | connect(effects, SIGNAL(windowDeleted(KWin::EffectWindow*)), this, SLOT(slotWindowDeleted(KWin::EffectWindow*))); | 47 | connect(effects, SIGNAL(windowDeleted(KWin::EffectWindow*)), this, SLOT(slotWindowDeleted(KWin::EffectWindow*))); | ||
48 | connect(effects, SIGNAL(propertyNotify(KWin::EffectWindow*,long)), this, SLOT(slotPropertyNotify(KWin::EffectWindow*,long))); | 48 | connect(effects, SIGNAL(propertyNotify(KWin::EffectWindow*,long)), this, SLOT(slotPropertyNotify(KWin::EffectWindow*,long))); | ||
49 | connect(effects, &EffectsHandler::windowShown, this, &SlidingPopupsEffect::startForShow); | 49 | connect(effects, &EffectsHandler::windowShown, this, &SlidingPopupsEffect::slideIn); | ||
50 | connect(effects, &EffectsHandler::windowHidden, this, &SlidingPopupsEffect::slotWindowClosed); | 50 | connect(effects, &EffectsHandler::windowHidden, this, &SlidingPopupsEffect::slideOut); | ||
51 | connect(effects, &EffectsHandler::xcbConnectionChanged, this, | 51 | connect(effects, &EffectsHandler::xcbConnectionChanged, this, | ||
52 | [this] { | 52 | [this] { | ||
53 | mAtom = effects->announceSupportProperty(QByteArrayLiteral("_KDE_SLIDE"), this); | 53 | mAtom = effects->announceSupportProperty(QByteArrayLiteral("_KDE_SLIDE"), this); | ||
54 | } | 54 | } | ||
55 | ); | 55 | ); | ||
56 | reconfigure(ReconfigureAll); | 56 | reconfigure(ReconfigureAll); | ||
57 | } | 57 | } | ||
58 | 58 | | |||
Show All 9 Lines | |||||
68 | void SlidingPopupsEffect::reconfigure(ReconfigureFlags flags) | 68 | void SlidingPopupsEffect::reconfigure(ReconfigureFlags flags) | ||
69 | { | 69 | { | ||
70 | Q_UNUSED(flags) | 70 | Q_UNUSED(flags) | ||
71 | SlidingPopupsConfig::self()->read(); | 71 | SlidingPopupsConfig::self()->read(); | ||
72 | mFadeInTime = std::chrono::milliseconds( | 72 | mFadeInTime = std::chrono::milliseconds( | ||
73 | static_cast<int>(animationTime(SlidingPopupsConfig::slideInTime() != 0 ? SlidingPopupsConfig::slideInTime() : 150))); | 73 | static_cast<int>(animationTime(SlidingPopupsConfig::slideInTime() != 0 ? SlidingPopupsConfig::slideInTime() : 150))); | ||
74 | mFadeOutTime = std::chrono::milliseconds( | 74 | mFadeOutTime = std::chrono::milliseconds( | ||
75 | static_cast<int>(animationTime(SlidingPopupsConfig::slideOutTime() != 0 ? SlidingPopupsConfig::slideOutTime() : 250))); | 75 | static_cast<int>(animationTime(SlidingPopupsConfig::slideOutTime() != 0 ? SlidingPopupsConfig::slideOutTime() : 250))); | ||
76 | QHash< const EffectWindow*, TimeLine >::iterator it = mAppearingWindows.begin(); | 76 | | ||
77 | while (it != mAppearingWindows.end()) { | 77 | auto animationIt = m_animations.begin(); | ||
78 | (*it).setDuration(mFadeInTime); | 78 | while (animationIt != m_animations.end()) { | ||
79 | ++it; | 79 | const auto duration = ((*animationIt).kind == AnimationKind::In) | ||
80 | } | 80 | ? mFadeInTime | ||
81 | it = mDisappearingWindows.begin(); | 81 | : mFadeOutTime; | ||
82 | while (it != mDisappearingWindows.end()) { | 82 | (*animationIt).timeLine.setDuration(duration); | ||
83 | (*it).setDuration(mFadeOutTime); | 83 | ++animationIt; | ||
84 | ++it; | | |||
85 | } | 84 | } | ||
85 | | ||||
86 | QHash< const EffectWindow*, Data >::iterator wIt = mWindowsData.begin(); | 86 | QHash< const EffectWindow*, Data >::iterator wIt = mWindowsData.begin(); | ||
87 | while (wIt != mWindowsData.end()) { | 87 | while (wIt != mWindowsData.end()) { | ||
88 | wIt.value().fadeInDuration = mFadeInTime; | 88 | wIt.value().fadeInDuration = mFadeInTime; | ||
89 | wIt.value().fadeOutDuration = mFadeOutTime; | 89 | wIt.value().fadeOutDuration = mFadeOutTime; | ||
90 | ++wIt; | 90 | ++wIt; | ||
91 | } | 91 | } | ||
92 | } | 92 | } | ||
93 | 93 | | |||
94 | void SlidingPopupsEffect::prePaintWindow(EffectWindow* w, WindowPrePaintData& data, int time) | 94 | void SlidingPopupsEffect::prePaintWindow(EffectWindow* w, WindowPrePaintData& data, int time) | ||
95 | { | 95 | { | ||
96 | const std::chrono::milliseconds delta(time); | 96 | auto animationIt = m_animations.find(w); | ||
97 | 97 | if (animationIt == m_animations.end()) { | |||
98 | qreal progress = 1.0; | 98 | effects->prePaintWindow(w, data, time); | ||
99 | bool appearing = false; | 99 | return; | ||
100 | if (mAppearingWindows.contains(w)) { | | |||
101 | mAppearingWindows[ w ].update(delta); | | |||
102 | if (!mAppearingWindows[ w ].done()) { | | |||
103 | data.setTransformed(); | | |||
104 | progress = mAppearingWindows[ w ].value(); | | |||
105 | appearing = true; | | |||
106 | } else { | | |||
107 | mAppearingWindows.remove(w); | | |||
108 | w->setData(WindowForceBackgroundContrastRole, false); | | |||
109 | w->setData(WindowForceBlurRole, false); | | |||
110 | } | 100 | } | ||
111 | } else if (mDisappearingWindows.contains(w)) { | | |||
112 | | ||||
113 | mDisappearingWindows[ w ].update(delta); | | |||
114 | progress = mDisappearingWindows[ w ].value(); | | |||
115 | 101 | | |||
116 | if (!mDisappearingWindows[ w ].done()) { | 102 | (*animationIt).timeLine.update(std::chrono::milliseconds(time)); | ||
117 | data.setTransformed(); | 103 | data.setTransformed(); | ||
118 | w->enablePainting(EffectWindow::PAINT_DISABLED | EffectWindow::PAINT_DISABLED_BY_DELETE); | 104 | w->enablePainting(EffectWindow::PAINT_DISABLED | EffectWindow::PAINT_DISABLED_BY_DELETE); | ||
119 | } else { | 105 | | ||
120 | mDisappearingWindows.remove(w); | | |||
121 | w->addRepaintFull(); | | |||
122 | if (w->isDeleted()) { | | |||
123 | w->unrefWindow(); | | |||
124 | } | | |||
125 | } | | |||
126 | } | | |||
127 | if (progress != 1.0) { | | |||
128 | const int start = mWindowsData[ w ].start; | 106 | const int start = mWindowsData[ w ].start; | ||
129 | if (start != 0) { | 107 | if (start != 0) { | ||
130 | const QRect screenRect = effects->clientArea(FullScreenArea, w->screen(), effects->currentDesktop()); | 108 | const QRect screenRect = effects->clientArea(FullScreenArea, w->screen(), effects->currentDesktop()); | ||
131 | const QRect geo = w->expandedGeometry(); | 109 | const QRect geo = w->expandedGeometry(); | ||
110 | const qreal t = (*animationIt).timeLine.value(); | ||||
132 | // filter out window quads, but only if the window does not start from the edge | 111 | // filter out window quads, but only if the window does not start from the edge | ||
133 | int slideLength; | 112 | int slideLength; | ||
134 | if (mWindowsData[ w ].slideLength > 0) { | 113 | if (mWindowsData[ w ].slideLength > 0) { | ||
135 | slideLength = mWindowsData[ w ].slideLength; | 114 | slideLength = mWindowsData[ w ].slideLength; | ||
136 | } else { | 115 | } else { | ||
137 | slideLength = mSlideLength; | 116 | slideLength = mSlideLength; | ||
138 | } | 117 | } | ||
139 | 118 | | |||
140 | switch(mWindowsData[ w ].from) { | 119 | switch(mWindowsData[ w ].from) { | ||
141 | case West: { | 120 | case West: { | ||
142 | const double splitPoint = geo.width() - (geo.x() + geo.width() - screenRect.x() - start) + qMin(geo.width(), slideLength) * (appearing ? 1.0 - progress : progress); | 121 | const double splitPoint = geo.width() - (geo.x() + geo.width() - screenRect.x() - start) + interpolate(qMin(geo.width(), slideLength), 0, t); | ||
143 | data.quads = data.quads.splitAtX(splitPoint); | 122 | data.quads = data.quads.splitAtX(splitPoint); | ||
144 | WindowQuadList filtered; | 123 | WindowQuadList filtered; | ||
145 | filtered.reserve(data.quads.count()); | 124 | filtered.reserve(data.quads.count()); | ||
146 | for (const WindowQuad &quad : qAsConst(data.quads)) { | 125 | for (const WindowQuad &quad : qAsConst(data.quads)) { | ||
147 | if (quad.left() >= splitPoint) { | 126 | if (quad.left() >= splitPoint) { | ||
148 | filtered << quad; | 127 | filtered << quad; | ||
149 | } | 128 | } | ||
150 | } | 129 | } | ||
151 | data.quads = filtered; | 130 | data.quads = filtered; | ||
152 | break; | 131 | break; | ||
153 | } | 132 | } | ||
154 | case North: { | 133 | case North: { | ||
155 | const double splitPoint = geo.height() - (geo.y() + geo.height() - screenRect.y() - start) + qMin(geo.height(), slideLength) * (appearing ? 1.0 - progress : progress); | 134 | const double splitPoint = geo.height() - (geo.y() + geo.height() - screenRect.y() - start) + interpolate(qMin(geo.height(), slideLength), 0, t); | ||
156 | data.quads = data.quads.splitAtY(splitPoint); | 135 | data.quads = data.quads.splitAtY(splitPoint); | ||
157 | WindowQuadList filtered; | 136 | WindowQuadList filtered; | ||
158 | filtered.reserve(data.quads.count()); | 137 | filtered.reserve(data.quads.count()); | ||
159 | for (const WindowQuad &quad : qAsConst(data.quads)) { | 138 | for (const WindowQuad &quad : qAsConst(data.quads)) { | ||
160 | if (quad.top() >= splitPoint) { | 139 | if (quad.top() >= splitPoint) { | ||
161 | filtered << quad; | 140 | filtered << quad; | ||
162 | } | 141 | } | ||
163 | } | 142 | } | ||
164 | data.quads = filtered; | 143 | data.quads = filtered; | ||
165 | break; | 144 | break; | ||
166 | } | 145 | } | ||
167 | case East: { | 146 | case East: { | ||
168 | const double splitPoint = screenRect.x() + screenRect.width() - geo.x() - start - qMin(geo.width(), slideLength) * (appearing ? 1.0 - progress : progress); | 147 | const double splitPoint = screenRect.x() + screenRect.width() - geo.x() - start - interpolate(qMin(geo.width(), slideLength), 0, t); | ||
169 | data.quads = data.quads.splitAtX(splitPoint); | 148 | data.quads = data.quads.splitAtX(splitPoint); | ||
170 | WindowQuadList filtered; | 149 | WindowQuadList filtered; | ||
171 | filtered.reserve(data.quads.count()); | 150 | filtered.reserve(data.quads.count()); | ||
172 | for (const WindowQuad &quad : qAsConst(data.quads)) { | 151 | for (const WindowQuad &quad : qAsConst(data.quads)) { | ||
173 | if (quad.right() <= splitPoint) { | 152 | if (quad.right() <= splitPoint) { | ||
174 | filtered << quad; | 153 | filtered << quad; | ||
175 | } | 154 | } | ||
176 | } | 155 | } | ||
177 | data.quads = filtered; | 156 | data.quads = filtered; | ||
178 | break; | 157 | break; | ||
179 | } | 158 | } | ||
180 | case South: | 159 | case South: | ||
181 | default: { | 160 | default: { | ||
182 | const double splitPoint = screenRect.y() + screenRect.height() - geo.y() - start - qMin(geo.height(), slideLength) * (appearing ? 1.0 - progress : progress); | 161 | const double splitPoint = screenRect.y() + screenRect.height() - geo.y() - start - interpolate(qMin(geo.height(), slideLength), 0, t); | ||
183 | data.quads = data.quads.splitAtY(splitPoint); | 162 | data.quads = data.quads.splitAtY(splitPoint); | ||
184 | WindowQuadList filtered; | 163 | WindowQuadList filtered; | ||
185 | filtered.reserve(data.quads.count()); | 164 | filtered.reserve(data.quads.count()); | ||
186 | for (const WindowQuad &quad : qAsConst(data.quads)) { | 165 | for (const WindowQuad &quad : qAsConst(data.quads)) { | ||
187 | if (quad.bottom() <= splitPoint) { | 166 | if (quad.bottom() <= splitPoint) { | ||
188 | filtered << quad; | 167 | filtered << quad; | ||
189 | } | 168 | } | ||
190 | } | 169 | } | ||
191 | data.quads = filtered; | 170 | data.quads = filtered; | ||
192 | break; | 171 | break; | ||
193 | } | 172 | } | ||
194 | } | 173 | } | ||
195 | } | 174 | } | ||
196 | } | 175 | | ||
197 | effects->prePaintWindow(w, data, time); | 176 | effects->prePaintWindow(w, data, time); | ||
198 | } | 177 | } | ||
199 | 178 | | |||
200 | void SlidingPopupsEffect::paintWindow(EffectWindow* w, int mask, QRegion region, WindowPaintData& data) | 179 | void SlidingPopupsEffect::paintWindow(EffectWindow* w, int mask, QRegion region, WindowPaintData& data) | ||
201 | { | 180 | { | ||
202 | bool animating = false; | 181 | auto animationIt = m_animations.constFind(w); | ||
203 | bool appearing = false; | 182 | if (animationIt == m_animations.constEnd()) { | ||
204 | 183 | effects->paintWindow(w, mask, region, data); | |||
205 | if (mAppearingWindows.contains(w)) { | 184 | return; | ||
206 | appearing = true; | | |||
207 | animating = true; | | |||
208 | } else if (mDisappearingWindows.contains(w)) { | | |||
209 | appearing = false; | | |||
210 | animating = true; | | |||
211 | } | | |||
212 | | ||||
213 | if (animating) { | | |||
214 | qreal progress; | | |||
215 | if (appearing) | | |||
216 | progress = 1.0 - mAppearingWindows[ w ].value(); | | |||
217 | else { | | |||
218 | if (mDisappearingWindows.contains(w)) | | |||
219 | progress = mDisappearingWindows[ w ].value(); | | |||
220 | else | | |||
221 | progress = 1.0; | | |||
222 | } | 185 | } | ||
186 | | ||||
223 | const int start = mWindowsData[ w ].start; | 187 | const int start = mWindowsData[ w ].start; | ||
224 | 188 | | |||
225 | int slideLength; | 189 | int slideLength; | ||
226 | if (mWindowsData[ w ].slideLength > 0) { | 190 | if (mWindowsData[ w ].slideLength > 0) { | ||
227 | slideLength = mWindowsData[ w ].slideLength; | 191 | slideLength = mWindowsData[ w ].slideLength; | ||
228 | } else { | 192 | } else { | ||
229 | slideLength = mSlideLength; | 193 | slideLength = mSlideLength; | ||
230 | } | 194 | } | ||
231 | 195 | | |||
232 | const QRect screenRect = effects->clientArea(FullScreenArea, w->screen(), w->desktop()); | 196 | const QRect screenRect = effects->clientArea(FullScreenArea, w->screen(), w->desktop()); | ||
233 | int splitPoint = 0; | 197 | int splitPoint = 0; | ||
234 | const QRect geo = w->expandedGeometry(); | 198 | const QRect geo = w->expandedGeometry(); | ||
199 | const qreal t = (*animationIt).timeLine.value(); | ||||
200 | | ||||
235 | switch(mWindowsData[ w ].from) { | 201 | switch(mWindowsData[ w ].from) { | ||
236 | case West: | 202 | case West: | ||
237 | if (slideLength < geo.width()) { | 203 | if (slideLength < geo.width()) { | ||
238 | data.multiplyOpacity(1 - progress); | 204 | data.multiplyOpacity(t); | ||
239 | } | 205 | } | ||
240 | data.translate(- qMin(geo.width(), slideLength) * progress); | 206 | data.translate(-interpolate(qMin(geo.width(), slideLength), 0.0, t)); | ||
241 | splitPoint = geo.width() - (geo.x() + geo.width() - screenRect.x() - start); | 207 | splitPoint = geo.width() - (geo.x() + geo.width() - screenRect.x() - start); | ||
242 | region = QRegion(geo.x() + splitPoint, geo.y(), geo.width() - splitPoint, geo.height()); | 208 | region = QRegion(geo.x() + splitPoint, geo.y(), geo.width() - splitPoint, geo.height()); | ||
243 | break; | 209 | break; | ||
244 | case North: | 210 | case North: | ||
245 | if (slideLength < geo.height()) { | 211 | if (slideLength < geo.height()) { | ||
246 | data.multiplyOpacity(1 - progress); | 212 | data.multiplyOpacity(t); | ||
247 | } | 213 | } | ||
248 | data.translate(0.0, - qMin(geo.height(), slideLength) * progress); | 214 | data.translate(0.0, -interpolate(qMin(geo.height(), slideLength), 0.0, t)); | ||
249 | splitPoint = geo.height() - (geo.y() + geo.height() - screenRect.y() - start); | 215 | splitPoint = geo.height() - (geo.y() + geo.height() - screenRect.y() - start); | ||
250 | region = QRegion(geo.x(), geo.y() + splitPoint, geo.width(), geo.height() - splitPoint); | 216 | region = QRegion(geo.x(), geo.y() + splitPoint, geo.width(), geo.height() - splitPoint); | ||
251 | break; | 217 | break; | ||
252 | case East: | 218 | case East: | ||
253 | if (slideLength < geo.width()) { | 219 | if (slideLength < geo.width()) { | ||
254 | data.multiplyOpacity(1 - progress); | 220 | data.multiplyOpacity(t); | ||
255 | } | 221 | } | ||
256 | data.translate(qMin(geo.width(), slideLength) * progress); | 222 | data.translate(interpolate(qMin(geo.width(), slideLength), 0.0, t)); | ||
257 | splitPoint = screenRect.x() + screenRect.width() - geo.x() - start; | 223 | splitPoint = screenRect.x() + screenRect.width() - geo.x() - start; | ||
258 | region = QRegion(geo.x(), geo.y(), splitPoint, geo.height()); | 224 | region = QRegion(geo.x(), geo.y(), splitPoint, geo.height()); | ||
259 | break; | 225 | break; | ||
260 | case South: | 226 | case South: | ||
261 | default: | 227 | default: | ||
262 | if (slideLength < geo.height()) { | 228 | if (slideLength < geo.height()) { | ||
263 | data.multiplyOpacity(1 - progress); | 229 | data.multiplyOpacity(t); | ||
264 | } | 230 | } | ||
265 | data.translate(0.0, qMin(geo.height(), slideLength) * progress); | 231 | data.translate(0.0, interpolate(qMin(geo.height(), slideLength), 0.0, t)); | ||
266 | splitPoint = screenRect.y() + screenRect.height() - geo.y() - start; | 232 | splitPoint = screenRect.y() + screenRect.height() - geo.y() - start; | ||
267 | region = QRegion(geo.x(), geo.y(), geo.width(), splitPoint); | 233 | region = QRegion(geo.x(), geo.y(), geo.width(), splitPoint); | ||
268 | } | 234 | } | ||
269 | } | | |||
270 | 235 | | |||
271 | effects->paintWindow(w, mask, region, data); | 236 | effects->paintWindow(w, mask, region, data); | ||
272 | } | 237 | } | ||
273 | 238 | | |||
274 | void SlidingPopupsEffect::postPaintWindow(EffectWindow* w) | 239 | void SlidingPopupsEffect::postPaintWindow(EffectWindow* w) | ||
275 | { | 240 | { | ||
276 | if (mAppearingWindows.contains(w) || mDisappearingWindows.contains(w)) { | 241 | auto animationIt = m_animations.find(w); | ||
277 | w->addRepaintFull(); // trigger next animation repaint | 242 | if (animationIt != m_animations.end()) { | ||
243 | if ((*animationIt).timeLine.done()) { | ||||
244 | if (w->isDeleted()) { | ||||
245 | w->unrefWindow(); | ||||
246 | } else { | ||||
247 | w->setData(WindowForceBackgroundContrastRole, QVariant()); | ||||
248 | w->setData(WindowForceBlurRole, QVariant()); | ||||
249 | } | ||||
250 | m_animations.erase(animationIt); | ||||
251 | } | ||||
252 | w->addRepaintFull(); | ||||
278 | } | 253 | } | ||
254 | | ||||
279 | effects->postPaintWindow(w); | 255 | effects->postPaintWindow(w); | ||
280 | } | 256 | } | ||
281 | 257 | | |||
282 | void SlidingPopupsEffect::slotWindowAdded(EffectWindow *w) | 258 | void SlidingPopupsEffect::slotWindowAdded(EffectWindow *w) | ||
283 | { | 259 | { | ||
284 | //X11 | 260 | //X11 | ||
285 | if (mAtom != XCB_ATOM_NONE) { | 261 | if (mAtom != XCB_ATOM_NONE) { | ||
286 | slotPropertyNotify(w, mAtom); | 262 | slotPropertyNotify(w, mAtom); | ||
287 | } | 263 | } | ||
288 | 264 | | |||
289 | //Wayland | 265 | //Wayland | ||
290 | if (auto surf = w->surface()) { | 266 | if (auto surf = w->surface()) { | ||
291 | slotWaylandSlideOnShowChanged(w); | 267 | slotWaylandSlideOnShowChanged(w); | ||
292 | connect(surf, &KWayland::Server::SurfaceInterface::slideOnShowHideChanged, this, [this, surf] { | 268 | connect(surf, &KWayland::Server::SurfaceInterface::slideOnShowHideChanged, this, [this, surf] { | ||
293 | slotWaylandSlideOnShowChanged(effects->findWindow(surf)); | 269 | slotWaylandSlideOnShowChanged(effects->findWindow(surf)); | ||
294 | }); | 270 | }); | ||
295 | } | 271 | } | ||
296 | 272 | | |||
297 | startForShow(w); | 273 | slideIn(w); | ||
298 | } | | |||
299 | | ||||
300 | void SlidingPopupsEffect::startForShow(EffectWindow *w) | | |||
301 | { | | |||
302 | if (w->isOnCurrentDesktop() && mWindowsData.contains(w)) { | | |||
303 | mDisappearingWindows.remove(w); | | |||
304 | | ||||
305 | TimeLine &timeLine = mAppearingWindows[ w ]; | | |||
306 | timeLine.reset(); | | |||
307 | timeLine.setDirection(TimeLine::Forward); | | |||
308 | timeLine.setDuration(mWindowsData[ w ].fadeInDuration); | | |||
309 | timeLine.setEasingCurve(QEasingCurve::InOutSine); | | |||
310 | | ||||
311 | w->setData(WindowAddedGrabRole, QVariant::fromValue(static_cast<void*>(this))); | | |||
312 | w->setData(WindowClosedGrabRole, QVariant::fromValue(static_cast<void*>(this))); | | |||
313 | w->setData(WindowForceBackgroundContrastRole, true); | | |||
314 | w->setData(WindowForceBlurRole, true); | | |||
315 | | ||||
316 | w->addRepaintFull(); | | |||
317 | } | | |||
318 | } | | |||
319 | | ||||
320 | void SlidingPopupsEffect::slotWindowClosed(EffectWindow* w) | | |||
321 | { | | |||
322 | if (w->isOnCurrentDesktop() && !w->isMinimized() && mWindowsData.contains(w)) { | | |||
323 | if (w->isDeleted()) { | | |||
324 | w->refWindow(); | | |||
325 | } | | |||
326 | | ||||
327 | mAppearingWindows.remove(w); | | |||
328 | | ||||
329 | TimeLine &timeLine = mDisappearingWindows[ w ]; | | |||
330 | if (timeLine.running()) { | | |||
331 | return; | | |||
332 | } | | |||
333 | timeLine.setDirection(TimeLine::Forward); | | |||
334 | timeLine.setDuration(mWindowsData[ w ].fadeOutDuration); | | |||
335 | timeLine.setEasingCurve(QEasingCurve::InOutSine); | | |||
336 | | ||||
337 | // Tell other windowClosed() effects to ignore this window | | |||
338 | w->setData(WindowClosedGrabRole, QVariant::fromValue(static_cast<void*>(this))); | | |||
339 | w->setData(WindowForceBackgroundContrastRole, true); | | |||
340 | w->setData(WindowForceBlurRole, true); | | |||
341 | | ||||
342 | w->addRepaintFull(); | | |||
343 | } | | |||
344 | } | 274 | } | ||
345 | 275 | | |||
346 | void SlidingPopupsEffect::slotWindowDeleted(EffectWindow* w) | 276 | void SlidingPopupsEffect::slotWindowDeleted(EffectWindow* w) | ||
347 | { | 277 | { | ||
348 | mAppearingWindows.remove(w); | 278 | m_animations.remove(w); | ||
349 | mDisappearingWindows.remove(w); | | |||
350 | mWindowsData.remove(w); | 279 | mWindowsData.remove(w); | ||
351 | effects->addRepaint(w->expandedGeometry()); | 280 | effects->addRepaint(w->expandedGeometry()); | ||
352 | } | 281 | } | ||
353 | 282 | | |||
354 | void SlidingPopupsEffect::slotPropertyNotify(EffectWindow* w, long a) | 283 | void SlidingPopupsEffect::slotPropertyNotify(EffectWindow* w, long a) | ||
355 | { | 284 | { | ||
356 | if (!w || a != mAtom || mAtom == XCB_ATOM_NONE) | 285 | if (!w || a != mAtom || mAtom == XCB_ATOM_NONE) | ||
357 | return; | 286 | return; | ||
358 | 287 | | |||
359 | QByteArray data = w->readProperty(mAtom, mAtom, 32); | 288 | QByteArray data = w->readProperty(mAtom, mAtom, 32); | ||
360 | 289 | | |||
361 | if (data.length() < 1) { | 290 | if (data.length() < 1) { | ||
362 | // Property was removed, thus also remove the effect for window | 291 | // Property was removed, thus also remove the effect for window | ||
363 | if (w->data(WindowClosedGrabRole).value<void *>() == this) { | 292 | if (w->data(WindowClosedGrabRole).value<void *>() == this) { | ||
364 | w->setData(WindowClosedGrabRole, QVariant()); | 293 | w->setData(WindowClosedGrabRole, QVariant()); | ||
365 | } | 294 | } | ||
366 | mAppearingWindows.remove(w); | 295 | m_animations.remove(w); | ||
367 | mDisappearingWindows.remove(w); | | |||
368 | mWindowsData.remove(w); | 296 | mWindowsData.remove(w); | ||
369 | return; | 297 | return; | ||
370 | } | 298 | } | ||
371 | 299 | | |||
372 | auto* d = reinterpret_cast< uint32_t* >(data.data()); | 300 | auto* d = reinterpret_cast< uint32_t* >(data.data()); | ||
373 | Data animData; | 301 | Data animData; | ||
374 | animData.start = d[ 0 ]; | 302 | animData.start = d[ 0 ]; | ||
375 | animData.from = (Position)d[ 1 ]; | 303 | animData.from = (Position)d[ 1 ]; | ||
▲ Show 20 Lines • Show All 96 Lines • ▼ Show 20 Line(s) | 380 | if (surf->slideOnShowHide()) { | |||
472 | animData.fadeInDuration = mFadeInTime; | 400 | animData.fadeInDuration = mFadeInTime; | ||
473 | animData.fadeOutDuration = mFadeOutTime; | 401 | animData.fadeOutDuration = mFadeOutTime; | ||
474 | mWindowsData[ w ] = animData; | 402 | mWindowsData[ w ] = animData; | ||
475 | 403 | | |||
476 | setupAnimData(w); | 404 | setupAnimData(w); | ||
477 | } | 405 | } | ||
478 | } | 406 | } | ||
479 | 407 | | |||
408 | void SlidingPopupsEffect::slideIn(EffectWindow *w) | ||||
409 | { | ||||
410 | if (effects->activeFullScreenEffect()) { | ||||
411 | return; | ||||
412 | } | ||||
413 | | ||||
414 | if (!w->isVisible()) { | ||||
415 | return; | ||||
416 | } | ||||
417 | | ||||
418 | auto dataIt = mWindowsData.constFind(w); | ||||
419 | if (dataIt == mWindowsData.constEnd()) { | ||||
420 | return; | ||||
421 | } | ||||
422 | | ||||
423 | Animation &animation = m_animations[w]; | ||||
424 | animation.kind = AnimationKind::In; | ||||
425 | animation.timeLine.reset(); | ||||
426 | animation.timeLine.setDirection(TimeLine::Forward); | ||||
427 | animation.timeLine.setDuration((*dataIt).fadeInDuration); | ||||
428 | animation.timeLine.setEasingCurve(QEasingCurve::InOutSine); | ||||
429 | | ||||
430 | w->setData(WindowAddedGrabRole, QVariant::fromValue(static_cast<void*>(this))); | ||||
431 | w->setData(WindowForceBackgroundContrastRole, QVariant(true)); | ||||
432 | w->setData(WindowForceBlurRole, QVariant(true)); | ||||
433 | | ||||
434 | w->addRepaintFull(); | ||||
435 | } | ||||
436 | | ||||
437 | void SlidingPopupsEffect::slideOut(EffectWindow *w) | ||||
438 | { | ||||
439 | if (effects->activeFullScreenEffect()) { | ||||
440 | return; | ||||
441 | } | ||||
442 | | ||||
443 | if (!w->isVisible()) { | ||||
444 | return; | ||||
445 | } | ||||
446 | | ||||
447 | auto dataIt = mWindowsData.constFind(w); | ||||
448 | if (dataIt == mWindowsData.constEnd()) { | ||||
449 | return; | ||||
450 | } | ||||
451 | | ||||
452 | if (w->isDeleted()) { | ||||
453 | w->refWindow(); | ||||
454 | } | ||||
455 | | ||||
456 | Animation &animation = m_animations[w]; | ||||
457 | animation.kind = AnimationKind::Out; | ||||
458 | animation.timeLine.reset(); | ||||
459 | animation.timeLine.setDirection(TimeLine::Backward); | ||||
460 | animation.timeLine.setDuration((*dataIt).fadeOutDuration); | ||||
461 | animation.timeLine.setEasingCurve(QEasingCurve::InOutSine); | ||||
462 | | ||||
463 | w->setData(WindowClosedGrabRole, QVariant::fromValue(static_cast<void*>(this))); | ||||
464 | w->setData(WindowForceBackgroundContrastRole, QVariant(true)); | ||||
465 | w->setData(WindowForceBlurRole, QVariant(true)); | ||||
466 | | ||||
467 | w->addRepaintFull(); | ||||
468 | } | ||||
469 | | ||||
480 | bool SlidingPopupsEffect::isActive() const | 470 | bool SlidingPopupsEffect::isActive() const | ||
481 | { | 471 | { | ||
482 | return !mAppearingWindows.isEmpty() || !mDisappearingWindows.isEmpty(); | 472 | return !m_animations.isEmpty(); | ||
483 | } | 473 | } | ||
484 | 474 | | |||
485 | } // namespace | 475 | } // namespace |