Changeset View
Changeset View
Standalone View
Standalone View
effects/slide/slide.cpp
Show First 20 Lines • Show All 65 Lines • ▼ Show 20 Line(s) | 65 | m_timeLine.setDuration( | |||
---|---|---|---|---|---|
66 | std::chrono::milliseconds(animationTime<SlideConfig>(500))); | 66 | std::chrono::milliseconds(animationTime<SlideConfig>(500))); | ||
67 | 67 | | |||
68 | m_hGap = SlideConfig::horizontalGap(); | 68 | m_hGap = SlideConfig::horizontalGap(); | ||
69 | m_vGap = SlideConfig::verticalGap(); | 69 | m_vGap = SlideConfig::verticalGap(); | ||
70 | m_slideDocks = SlideConfig::slideDocks(); | 70 | m_slideDocks = SlideConfig::slideDocks(); | ||
71 | m_slideBackground = SlideConfig::slideBackground(); | 71 | m_slideBackground = SlideConfig::slideBackground(); | ||
72 | } | 72 | } | ||
73 | 73 | | |||
74 | void SlideEffect::prePaintScreen(ScreenPrePaintData& data, int time) | 74 | void SlideEffect::prePaintScreen(ScreenPrePaintData &data, int time) | ||
75 | { | 75 | { | ||
76 | m_timeLine.update(std::chrono::milliseconds(time)); | 76 | m_timeLine.update(std::chrono::milliseconds(time)); | ||
77 | 77 | | |||
78 | data.mask |= PAINT_SCREEN_TRANSFORMED | 78 | data.mask |= PAINT_SCREEN_TRANSFORMED | ||
79 | | PAINT_SCREEN_BACKGROUND_FIRST; | 79 | | PAINT_SCREEN_BACKGROUND_FIRST; | ||
80 | 80 | | |||
81 | effects->prePaintScreen(data, time); | 81 | effects->prePaintScreen(data, time); | ||
82 | } | 82 | } | ||
83 | 83 | | |||
84 | /** | 84 | /** | ||
85 | * Wrap vector @p diff around grid @p w x @p h. | 85 | * Wrap vector @p diff around grid @p w x @p h. | ||
86 | * | 86 | * | ||
87 | * Wrapping is done in such a way that magnitude of x and y component of vector | 87 | * Wrapping is done in such a way that magnitude of x and y component of vector | ||
88 | * @p diff is less than half of @p w and half of @p h, respectively. This will | 88 | * @p diff is less than half of @p w and half of @p h, respectively. This will | ||
89 | * result in having the "shortest" path between two points. | 89 | * result in having the "shortest" path between two points. | ||
90 | * | 90 | * | ||
91 | * @param diff Vector between two points | 91 | * @param diff Vector between two points | ||
92 | * @param w Width of the desktop grid | 92 | * @param w Width of the desktop grid | ||
93 | * @param h Height of the desktop grid | 93 | * @param h Height of the desktop grid | ||
94 | */ | 94 | */ | ||
95 | inline void wrapDiff(QPoint& diff, int w, int h) | 95 | inline void wrapDiff(QPoint &diff, int w, int h) | ||
96 | { | 96 | { | ||
97 | if (diff.x() > w/2) { | 97 | if (diff.x() > w/2) { | ||
98 | diff.setX(diff.x() - w); | 98 | diff.setX(diff.x() - w); | ||
99 | } else if (diff.x() < -w/2) { | 99 | } else if (diff.x() < -w/2) { | ||
100 | diff.setX(diff.x() + w); | 100 | diff.setX(diff.x() + w); | ||
101 | } | 101 | } | ||
102 | 102 | | |||
103 | if (diff.y() > h/2) { | 103 | if (diff.y() > h/2) { | ||
104 | diff.setY(diff.y() - h); | 104 | diff.setY(diff.y() - h); | ||
105 | } else if (diff.y() < -h/2) { | 105 | } else if (diff.y() < -h/2) { | ||
106 | diff.setY(diff.y() + h); | 106 | diff.setY(diff.y() + h); | ||
107 | } | 107 | } | ||
108 | } | 108 | } | ||
109 | 109 | | |||
110 | inline QRegion buildClipRegion(const QPoint& pos, int w, int h) | 110 | inline QRegion buildClipRegion(const QPoint &pos, int w, int h) | ||
111 | { | 111 | { | ||
112 | const QSize screenSize = effects->virtualScreenSize(); | 112 | const QSize screenSize = effects->virtualScreenSize(); | ||
113 | QRegion r = QRect(pos, screenSize); | 113 | QRegion r = QRect(pos, screenSize); | ||
114 | if (effects->optionRollOverDesktops()) { | 114 | if (effects->optionRollOverDesktops()) { | ||
115 | r |= (r & QRect(-w, 0, w, h)).translated(w, 0); // W | 115 | r |= (r & QRect(-w, 0, w, h)).translated(w, 0); // W | ||
116 | r |= (r & QRect(w, 0, w, h)).translated(-w, 0); // E | 116 | r |= (r & QRect(w, 0, w, h)).translated(-w, 0); // E | ||
117 | 117 | | |||
118 | r |= (r & QRect(0, -h, w, h)).translated(0, h); // N | 118 | r |= (r & QRect(0, -h, w, h)).translated(0, h); // N | ||
119 | r |= (r & QRect(0, h, w, h)).translated(0, -h); // S | 119 | r |= (r & QRect(0, h, w, h)).translated(0, -h); // S | ||
120 | 120 | | |||
121 | r |= (r & QRect(-w, -h, w, h)).translated(w, h); // NW | 121 | r |= (r & QRect(-w, -h, w, h)).translated(w, h); // NW | ||
122 | r |= (r & QRect(w, -h, w, h)).translated(-w, h); // NE | 122 | r |= (r & QRect(w, -h, w, h)).translated(-w, h); // NE | ||
123 | r |= (r & QRect(w, h, w, h)).translated(-w, -h); // SE | 123 | r |= (r & QRect(w, h, w, h)).translated(-w, -h); // SE | ||
124 | r |= (r & QRect(-w, h, w, h)).translated(w, -h); // SW | 124 | r |= (r & QRect(-w, h, w, h)).translated(w, -h); // SW | ||
125 | } | 125 | } | ||
126 | return r; | 126 | return r; | ||
127 | } | 127 | } | ||
128 | 128 | | |||
129 | void SlideEffect::paintScreen(int mask, QRegion region, ScreenPaintData& data) | 129 | void SlideEffect::paintScreen(int mask, QRegion region, ScreenPaintData &data) | ||
130 | { | 130 | { | ||
131 | if (! m_active) { | 131 | if (!m_active) { | ||
132 | effects->paintScreen(mask, region, data); | 132 | effects->paintScreen(mask, region, data); | ||
133 | return; | 133 | return; | ||
134 | } | 134 | } | ||
135 | 135 | | |||
136 | const bool wrap = effects->optionRollOverDesktops(); | 136 | const bool wrap = effects->optionRollOverDesktops(); | ||
137 | const int w = workspaceWidth(); | 137 | const int w = workspaceWidth(); | ||
138 | const int h = workspaceHeight(); | 138 | const int h = workspaceHeight(); | ||
139 | 139 | | |||
140 | QPoint currentPos = m_startPos + m_diff * m_timeLine.value(); | 140 | QPoint currentPos = m_startPos + m_diff * m_timeLine.value(); | ||
141 | 141 | | |||
142 | // When "Desktop navigation wraps around" checkbox is checked, currentPos | 142 | // When "Desktop navigation wraps around" checkbox is checked, currentPos | ||
143 | // can be outside the rectangle Rect{x:-w, y:-h, width:2*w, height: 2*h}, | 143 | // can be outside the rectangle Rect{x:-w, y:-h, width:2*w, height: 2*h}, | ||
144 | // so we map currentPos back to the rect. | 144 | // so we map currentPos back to the rect. | ||
145 | if (wrap) { | 145 | if (wrap) { | ||
146 | currentPos.setX(currentPos.x() % w); | 146 | currentPos.setX(currentPos.x() % w); | ||
147 | currentPos.setY(currentPos.y() % h); | 147 | currentPos.setY(currentPos.y() % h); | ||
148 | } | 148 | } | ||
149 | 149 | | |||
150 | QVector<int> visibleDesktops; | 150 | QVector<int> visibleDesktops; | ||
151 | visibleDesktops.reserve(4); // 4 - maximum number of visible desktops | 151 | visibleDesktops.reserve(4); // 4 - maximum number of visible desktops | ||
152 | const QRegion clipRegion = buildClipRegion(currentPos, w, h); | 152 | const QRegion clipRegion = buildClipRegion(currentPos, w, h); | ||
153 | for (int i = 1; i <= effects->numberOfDesktops(); i++) { | 153 | for (int i = 1; i <= effects->numberOfDesktops(); i++) { | ||
154 | const QRect desktopGeo = desktopGeometry(i); | 154 | const QRect desktopGeo = desktopGeometry(i); | ||
155 | if (! clipRegion.contains(desktopGeo)) { | 155 | if (!clipRegion.contains(desktopGeo)) { | ||
156 | continue; | 156 | continue; | ||
157 | } | 157 | } | ||
158 | visibleDesktops << i; | 158 | visibleDesktops << i; | ||
159 | } | 159 | } | ||
160 | 160 | | |||
161 | // When we enter a virtual desktop that has a window in fullscreen mode, | 161 | // When we enter a virtual desktop that has a window in fullscreen mode, | ||
162 | // stacking order is fine. When we leave a virtual desktop that has | 162 | // stacking order is fine. When we leave a virtual desktop that has | ||
163 | // a window in fullscreen mode, stacking order is no longer valid | 163 | // a window in fullscreen mode, stacking order is no longer valid | ||
164 | // because panels are raised above the fullscreen window. Construct | 164 | // because panels are raised above the fullscreen window. Construct | ||
165 | // a list of fullscreen windows, so we can decide later whether | 165 | // a list of fullscreen windows, so we can decide later whether | ||
166 | // docks should be visible on different virtual desktops. | 166 | // docks should be visible on different virtual desktops. | ||
167 | if (m_slideDocks) { | 167 | if (m_slideDocks) { | ||
168 | const auto windows = effects->stackingOrder(); | 168 | const auto windows = effects->stackingOrder(); | ||
169 | m_paintCtx.fullscreenWindows.clear(); | 169 | m_paintCtx.fullscreenWindows.clear(); | ||
170 | for (EffectWindow* w : windows) { | 170 | for (EffectWindow *w : windows) { | ||
171 | if (! w->isFullScreen()) { | 171 | if (!w->isFullScreen()) { | ||
172 | continue; | 172 | continue; | ||
173 | } | 173 | } | ||
174 | m_paintCtx.fullscreenWindows << w; | 174 | m_paintCtx.fullscreenWindows << w; | ||
175 | } | 175 | } | ||
176 | } | 176 | } | ||
177 | 177 | | |||
178 | // If screen is painted with either PAINT_SCREEN_TRANSFORMED or | 178 | // If screen is painted with either PAINT_SCREEN_TRANSFORMED or | ||
179 | // PAINT_SCREEN_WITH_TRANSFORMED_WINDOWS there is no clipping!! | 179 | // PAINT_SCREEN_WITH_TRANSFORMED_WINDOWS there is no clipping!! | ||
Show All 19 Lines | 191 | for (int desktop : qAsConst(visibleDesktops)) { | |||
199 | m_paintCtx.firstPass = false; | 199 | m_paintCtx.firstPass = false; | ||
200 | } | 200 | } | ||
201 | } | 201 | } | ||
202 | 202 | | |||
203 | /** | 203 | /** | ||
204 | * Decide whether given window @p w should be transformed/translated. | 204 | * Decide whether given window @p w should be transformed/translated. | ||
205 | * @returns @c true if given window @p w should be transformed, otherwise @c false | 205 | * @returns @c true if given window @p w should be transformed, otherwise @c false | ||
206 | */ | 206 | */ | ||
207 | bool SlideEffect::isTranslated(const EffectWindow* w) const | 207 | bool SlideEffect::isTranslated(const EffectWindow *w) const | ||
208 | { | 208 | { | ||
209 | if (w->isOnAllDesktops()) { | 209 | if (w->isOnAllDesktops()) { | ||
210 | if (w->isDock()) { | 210 | if (w->isDock()) { | ||
211 | return m_slideDocks; | 211 | return m_slideDocks; | ||
212 | } | 212 | } | ||
213 | if (w->isDesktop()) { | 213 | if (w->isDesktop()) { | ||
214 | return m_slideBackground; | 214 | return m_slideBackground; | ||
215 | } | 215 | } | ||
216 | return false; | 216 | return false; | ||
217 | } else if (w == m_movingWindow) { | 217 | } else if (w == m_movingWindow) { | ||
218 | return false; | 218 | return false; | ||
219 | } else if (w->isOnDesktop(m_paintCtx.desktop)) { | 219 | } else if (w->isOnDesktop(m_paintCtx.desktop)) { | ||
220 | return true; | 220 | return true; | ||
221 | } | 221 | } | ||
222 | return false; | 222 | return false; | ||
223 | } | 223 | } | ||
224 | 224 | | |||
225 | /** | 225 | /** | ||
226 | * Decide whether given window @p w should be painted. | 226 | * Decide whether given window @p w should be painted. | ||
227 | * @returns @c true if given window @p w should be painted, otherwise @c false | 227 | * @returns @c true if given window @p w should be painted, otherwise @c false | ||
228 | */ | 228 | */ | ||
229 | bool SlideEffect::isPainted(const EffectWindow* w) const | 229 | bool SlideEffect::isPainted(const EffectWindow *w) const | ||
230 | { | 230 | { | ||
231 | if (w->isOnAllDesktops()) { | 231 | if (w->isOnAllDesktops()) { | ||
232 | if (w->isDock()) { | 232 | if (w->isDock()) { | ||
233 | if (! m_slideDocks) { | 233 | if (!m_slideDocks) { | ||
234 | return m_paintCtx.lastPass; | 234 | return m_paintCtx.lastPass; | ||
235 | } | 235 | } | ||
236 | for (const EffectWindow* fw : qAsConst(m_paintCtx.fullscreenWindows)) { | 236 | for (const EffectWindow *fw : qAsConst(m_paintCtx.fullscreenWindows)) { | ||
237 | if (fw->isOnDesktop(m_paintCtx.desktop) | 237 | if (fw->isOnDesktop(m_paintCtx.desktop) | ||
238 | && fw->screen() == w->screen()) { | 238 | && fw->screen() == w->screen()) { | ||
239 | return false; | 239 | return false; | ||
240 | } | 240 | } | ||
241 | } | 241 | } | ||
242 | return true; | 242 | return true; | ||
243 | } | 243 | } | ||
244 | if (w->isDesktop()) { | 244 | if (w->isDesktop()) { | ||
Show All 13 Lines | |||||
258 | } else if (w == m_movingWindow) { | 258 | } else if (w == m_movingWindow) { | ||
259 | return m_paintCtx.lastPass; | 259 | return m_paintCtx.lastPass; | ||
260 | } else if (w->isOnDesktop(m_paintCtx.desktop)) { | 260 | } else if (w->isOnDesktop(m_paintCtx.desktop)) { | ||
261 | return true; | 261 | return true; | ||
262 | } | 262 | } | ||
263 | return false; | 263 | return false; | ||
264 | } | 264 | } | ||
265 | 265 | | |||
266 | void SlideEffect::prePaintWindow(EffectWindow* w, WindowPrePaintData& data, int time) | 266 | void SlideEffect::prePaintWindow(EffectWindow *w, WindowPrePaintData &data, int time) | ||
267 | { | 267 | { | ||
268 | if (m_active) { | 268 | if (m_active) { | ||
269 | const bool painted = isPainted(w); | 269 | const bool painted = isPainted(w); | ||
270 | if (painted) { | 270 | if (painted) { | ||
271 | w->enablePainting(EffectWindow::PAINT_DISABLED_BY_DESKTOP); | 271 | w->enablePainting(EffectWindow::PAINT_DISABLED_BY_DESKTOP); | ||
272 | } else { | 272 | } else { | ||
273 | w->disablePainting(EffectWindow::PAINT_DISABLED_BY_DESKTOP); | 273 | w->disablePainting(EffectWindow::PAINT_DISABLED_BY_DESKTOP); | ||
274 | } | 274 | } | ||
275 | if (painted && isTranslated(w)) { | 275 | if (painted && isTranslated(w)) { | ||
276 | data.setTransformed(); | 276 | data.setTransformed(); | ||
277 | } | 277 | } | ||
278 | } | 278 | } | ||
279 | effects->prePaintWindow(w, data, time); | 279 | effects->prePaintWindow(w, data, time); | ||
280 | } | 280 | } | ||
281 | 281 | | |||
282 | void SlideEffect::paintWindow(EffectWindow* w, int mask, QRegion region, WindowPaintData& data) | 282 | void SlideEffect::paintWindow(EffectWindow *w, int mask, QRegion region, WindowPaintData &data) | ||
283 | { | 283 | { | ||
284 | if (m_active && isTranslated(w)) { | 284 | if (m_active && isTranslated(w)) { | ||
285 | data += m_paintCtx.translation; | 285 | data += m_paintCtx.translation; | ||
286 | } | 286 | } | ||
287 | effects->paintWindow(w, mask, region, data); | 287 | effects->paintWindow(w, mask, region, data); | ||
288 | } | 288 | } | ||
289 | 289 | | |||
290 | void SlideEffect::postPaintScreen() | 290 | void SlideEffect::postPaintScreen() | ||
▲ Show 20 Lines • Show All 45 Lines • ▼ Show 20 Line(s) | |||||
336 | */ | 336 | */ | ||
337 | int SlideEffect::workspaceHeight() const | 337 | int SlideEffect::workspaceHeight() const | ||
338 | { | 338 | { | ||
339 | int h = effects->workspaceHeight(); | 339 | int h = effects->workspaceHeight(); | ||
340 | h += m_vGap * effects->desktopGridHeight(); | 340 | h += m_vGap * effects->desktopGridHeight(); | ||
341 | return h; | 341 | return h; | ||
342 | } | 342 | } | ||
343 | 343 | | |||
344 | bool SlideEffect::shouldForceBlur(const EffectWindow* w) const | 344 | bool SlideEffect::shouldForceBlur(const EffectWindow *w) const | ||
345 | { | 345 | { | ||
346 | // While there is an active fullscreen effect, the blur effect | 346 | // While there is an active fullscreen effect, the blur effect | ||
347 | // tends to do nothing, i.e. it doesn't blur behind windows. | 347 | // tends to do nothing, i.e. it doesn't blur behind windows. | ||
348 | // So, we should force the blur effect to blur by setting | 348 | // So, we should force the blur effect to blur by setting | ||
349 | // WindowForceBlurRole. | 349 | // WindowForceBlurRole. | ||
350 | 350 | | |||
351 | if (w->data(WindowForceBlurRole).toBool()) { | 351 | if (w->data(WindowForceBlurRole).toBool()) { | ||
352 | return false; | 352 | return false; | ||
353 | } | 353 | } | ||
354 | 354 | | |||
355 | if (w->data(WindowBlurBehindRole).isValid()) { | 355 | if (w->data(WindowBlurBehindRole).isValid()) { | ||
356 | return true; | 356 | return true; | ||
357 | } | 357 | } | ||
358 | 358 | | |||
359 | if (w->decorationHasAlpha() && effects->decorationSupportsBlurBehind()) { | 359 | if (w->decorationHasAlpha() && effects->decorationSupportsBlurBehind()) { | ||
360 | return true; | 360 | return true; | ||
361 | } | 361 | } | ||
362 | 362 | | |||
363 | // FIXME: it should be something like this: | 363 | // FIXME: it should be something like this: | ||
364 | // if (surf) { | 364 | // if (surf) { | ||
365 | // return !surf->blur().isNull(); | 365 | // return !surf->blur().isNull(); | ||
366 | // } | 366 | // } | ||
367 | const KWayland::Server::SurfaceInterface* surf = w->surface(); | 367 | const KWayland::Server::SurfaceInterface *surf = w->surface(); | ||
368 | if (surf && surf->blur()) { | 368 | if (surf && surf->blur()) { | ||
369 | return true; | 369 | return true; | ||
370 | } | 370 | } | ||
371 | 371 | | |||
372 | // TODO: make it X11-specific(check _KDE_NET_WM_BLUR_BEHIND_REGION) | 372 | // TODO: make it X11-specific(check _KDE_NET_WM_BLUR_BEHIND_REGION) | ||
373 | // or delete it in the future | 373 | // or delete it in the future | ||
374 | return w->hasAlpha(); | 374 | return w->hasAlpha(); | ||
375 | } | 375 | } | ||
376 | 376 | | |||
377 | bool SlideEffect::shouldForceBackgroundContrast(const EffectWindow* w) const | 377 | bool SlideEffect::shouldForceBackgroundContrast(const EffectWindow *w) const | ||
378 | { | 378 | { | ||
379 | // While there is an active fullscreen effect, the background | 379 | // While there is an active fullscreen effect, the background | ||
380 | // contrast effect tends to do nothing, i.e. it doesn't change | 380 | // contrast effect tends to do nothing, i.e. it doesn't change | ||
381 | // contrast. So, we should force the background contrast effect | 381 | // contrast. So, we should force the background contrast effect | ||
382 | // to change contrast by setting WindowForceBackgroundContrastRole. | 382 | // to change contrast by setting WindowForceBackgroundContrastRole. | ||
383 | 383 | | |||
384 | if (w->data(WindowForceBackgroundContrastRole).toBool()) { | 384 | if (w->data(WindowForceBackgroundContrastRole).toBool()) { | ||
385 | return false; | 385 | return false; | ||
386 | } | 386 | } | ||
387 | 387 | | |||
388 | if (w->data(WindowBackgroundContrastRole).isValid()) { | 388 | if (w->data(WindowBackgroundContrastRole).isValid()) { | ||
389 | return true; | 389 | return true; | ||
390 | } | 390 | } | ||
391 | 391 | | |||
392 | // FIXME: it should be something like this: | 392 | // FIXME: it should be something like this: | ||
393 | // if (surf) { | 393 | // if (surf) { | ||
394 | // return !surf->contrast().isNull(); | 394 | // return !surf->contrast().isNull(); | ||
395 | // } | 395 | // } | ||
396 | const KWayland::Server::SurfaceInterface* surf = w->surface(); | 396 | const KWayland::Server::SurfaceInterface *surf = w->surface(); | ||
397 | if (surf && surf->contrast()) { | 397 | if (surf && surf->contrast()) { | ||
398 | return true; | 398 | return true; | ||
399 | } | 399 | } | ||
400 | 400 | | |||
401 | // TODO: make it X11-specific(check _KDE_NET_WM_BACKGROUND_CONTRAST_REGION) | 401 | // TODO: make it X11-specific(check _KDE_NET_WM_BACKGROUND_CONTRAST_REGION) | ||
402 | // or delete it in the future | 402 | // or delete it in the future | ||
403 | return w->hasAlpha() | 403 | return w->hasAlpha() | ||
404 | && w->isOnAllDesktops() | 404 | && w->isOnAllDesktops() | ||
405 | && (w->isDock() || w->keepAbove()); | 405 | && (w->isDock() || w->keepAbove()); | ||
406 | } | 406 | } | ||
407 | 407 | | |||
408 | bool SlideEffect::shouldElevate(const EffectWindow* w) const | 408 | bool SlideEffect::shouldElevate(const EffectWindow *w) const | ||
409 | { | 409 | { | ||
410 | // Static docks(i.e. this effect doesn't slide docks) should be elevated | 410 | // Static docks(i.e. this effect doesn't slide docks) should be elevated | ||
411 | // so they can properly animate themselves when an user enters or leaves | 411 | // so they can properly animate themselves when an user enters or leaves | ||
412 | // a virtual desktop with a window in fullscreen mode. | 412 | // a virtual desktop with a window in fullscreen mode. | ||
413 | return w->isDock() && !m_slideDocks; | 413 | return w->isDock() && !m_slideDocks; | ||
414 | } | 414 | } | ||
415 | 415 | | |||
416 | void SlideEffect::start(int old, int current, EffectWindow* movingWindow) | 416 | void SlideEffect::start(int old, int current, EffectWindow *movingWindow) | ||
417 | { | 417 | { | ||
418 | m_movingWindow = movingWindow; | 418 | m_movingWindow = movingWindow; | ||
419 | 419 | | |||
420 | const bool wrap = effects->optionRollOverDesktops(); | 420 | const bool wrap = effects->optionRollOverDesktops(); | ||
421 | const int w = workspaceWidth(); | 421 | const int w = workspaceWidth(); | ||
422 | const int h = workspaceHeight(); | 422 | const int h = workspaceHeight(); | ||
423 | 423 | | |||
424 | if (m_active) { | 424 | if (m_active) { | ||
425 | QPoint passed = m_diff * m_timeLine.value(); | 425 | QPoint passed = m_diff * m_timeLine.value(); | ||
426 | QPoint currentPos = m_startPos + passed; | 426 | QPoint currentPos = m_startPos + passed; | ||
427 | QPoint delta = desktopCoords(current) - desktopCoords(old); | 427 | QPoint delta = desktopCoords(current) - desktopCoords(old); | ||
428 | if (wrap) { | 428 | if (wrap) { | ||
429 | wrapDiff(delta, w, h); | 429 | wrapDiff(delta, w, h); | ||
430 | } | 430 | } | ||
431 | m_diff += delta - passed; | 431 | m_diff += delta - passed; | ||
432 | m_startPos = currentPos; | 432 | m_startPos = currentPos; | ||
433 | // TODO: Figure out how to smooth movement. | 433 | // TODO: Figure out how to smooth movement. | ||
434 | m_timeLine.reset(); | 434 | m_timeLine.reset(); | ||
435 | return; | 435 | return; | ||
436 | } | 436 | } | ||
437 | 437 | | |||
438 | const auto windows = effects->stackingOrder(); | 438 | const auto windows = effects->stackingOrder(); | ||
439 | for (EffectWindow* w : windows) { | 439 | for (EffectWindow *w : windows) { | ||
440 | if (shouldForceBlur(w)) { | 440 | if (shouldForceBlur(w)) { | ||
441 | w->setData(WindowForceBlurRole, QVariant(true)); | 441 | w->setData(WindowForceBlurRole, QVariant(true)); | ||
442 | m_forcedRoles.blur << w; | 442 | m_forcedRoles.blur << w; | ||
443 | } | 443 | } | ||
444 | if (shouldForceBackgroundContrast(w)) { | 444 | if (shouldForceBackgroundContrast(w)) { | ||
445 | w->setData(WindowForceBackgroundContrastRole, QVariant(true)); | 445 | w->setData(WindowForceBackgroundContrastRole, QVariant(true)); | ||
446 | m_forcedRoles.backgroundContrast << w; | 446 | m_forcedRoles.backgroundContrast << w; | ||
447 | } | 447 | } | ||
Show All 11 Lines | |||||
459 | m_timeLine.reset(); | 459 | m_timeLine.reset(); | ||
460 | m_active = true; | 460 | m_active = true; | ||
461 | effects->setActiveFullScreenEffect(this); | 461 | effects->setActiveFullScreenEffect(this); | ||
462 | effects->addRepaintFull(); | 462 | effects->addRepaintFull(); | ||
463 | } | 463 | } | ||
464 | 464 | | |||
465 | void SlideEffect::stop() | 465 | void SlideEffect::stop() | ||
466 | { | 466 | { | ||
467 | for (EffectWindow* w : m_forcedRoles.blur) { | 467 | for (EffectWindow *w : m_forcedRoles.blur) { | ||
468 | w->setData(WindowForceBlurRole, QVariant()); | 468 | w->setData(WindowForceBlurRole, QVariant()); | ||
469 | } | 469 | } | ||
470 | m_forcedRoles.blur.clear(); | 470 | m_forcedRoles.blur.clear(); | ||
471 | 471 | | |||
472 | for (EffectWindow* w : m_forcedRoles.backgroundContrast) { | 472 | for (EffectWindow *w : m_forcedRoles.backgroundContrast) { | ||
473 | w->setData(WindowForceBackgroundContrastRole, QVariant()); | 473 | w->setData(WindowForceBackgroundContrastRole, QVariant()); | ||
474 | } | 474 | } | ||
475 | m_forcedRoles.backgroundContrast.clear(); | 475 | m_forcedRoles.backgroundContrast.clear(); | ||
476 | 476 | | |||
477 | for (EffectWindow* w : m_elevatedWindows) { | 477 | for (EffectWindow *w : m_elevatedWindows) { | ||
478 | effects->setElevatedWindow(w, false); | 478 | effects->setElevatedWindow(w, false); | ||
479 | } | 479 | } | ||
480 | m_elevatedWindows.clear(); | 480 | m_elevatedWindows.clear(); | ||
481 | 481 | | |||
482 | m_paintCtx.fullscreenWindows.clear(); | 482 | m_paintCtx.fullscreenWindows.clear(); | ||
483 | m_movingWindow = nullptr; | 483 | m_movingWindow = nullptr; | ||
484 | m_active = false; | 484 | m_active = false; | ||
485 | effects->setActiveFullScreenEffect(nullptr); | 485 | effects->setActiveFullScreenEffect(nullptr); | ||
486 | } | 486 | } | ||
487 | 487 | | |||
488 | void SlideEffect::desktopChanged(int old, int current, EffectWindow* with) | 488 | void SlideEffect::desktopChanged(int old, int current, EffectWindow *with) | ||
489 | { | 489 | { | ||
490 | if (effects->activeFullScreenEffect() && effects->activeFullScreenEffect() != this) { | 490 | if (effects->activeFullScreenEffect() && effects->activeFullScreenEffect() != this) { | ||
491 | return; | 491 | return; | ||
492 | } | 492 | } | ||
493 | start(old, current, with); | 493 | start(old, current, with); | ||
494 | } | 494 | } | ||
495 | 495 | | |||
496 | void SlideEffect::windowAdded(EffectWindow *w) | 496 | void SlideEffect::windowAdded(EffectWindow *w) | ||
497 | { | 497 | { | ||
498 | if (! m_active) { | 498 | if (!m_active) { | ||
499 | return; | 499 | return; | ||
500 | } | 500 | } | ||
501 | if (shouldForceBlur(w)) { | 501 | if (shouldForceBlur(w)) { | ||
502 | w->setData(WindowForceBlurRole, QVariant(true)); | 502 | w->setData(WindowForceBlurRole, QVariant(true)); | ||
503 | m_forcedRoles.blur << w; | 503 | m_forcedRoles.blur << w; | ||
504 | } | 504 | } | ||
505 | if (shouldForceBackgroundContrast(w)) { | 505 | if (shouldForceBackgroundContrast(w)) { | ||
506 | w->setData(WindowForceBackgroundContrastRole, QVariant(true)); | 506 | w->setData(WindowForceBackgroundContrastRole, QVariant(true)); | ||
507 | m_forcedRoles.backgroundContrast << w; | 507 | m_forcedRoles.backgroundContrast << w; | ||
508 | } | 508 | } | ||
509 | if (shouldElevate(w)) { | 509 | if (shouldElevate(w)) { | ||
510 | effects->setElevatedWindow(w, true); | 510 | effects->setElevatedWindow(w, true); | ||
511 | m_elevatedWindows << w; | 511 | m_elevatedWindows << w; | ||
512 | } | 512 | } | ||
513 | } | 513 | } | ||
514 | 514 | | |||
515 | void SlideEffect::windowDeleted(EffectWindow *w) | 515 | void SlideEffect::windowDeleted(EffectWindow *w) | ||
516 | { | 516 | { | ||
517 | if (! m_active) { | 517 | if (!m_active) { | ||
518 | return; | 518 | return; | ||
519 | } | 519 | } | ||
520 | if (w == m_movingWindow) { | 520 | if (w == m_movingWindow) { | ||
521 | m_movingWindow = nullptr; | 521 | m_movingWindow = nullptr; | ||
522 | } | 522 | } | ||
523 | m_forcedRoles.blur.removeAll(w); | 523 | m_forcedRoles.blur.removeAll(w); | ||
524 | m_forcedRoles.backgroundContrast.removeAll(w); | 524 | m_forcedRoles.backgroundContrast.removeAll(w); | ||
525 | m_elevatedWindows.removeAll(w); | 525 | m_elevatedWindows.removeAll(w); | ||
526 | m_paintCtx.fullscreenWindows.removeAll(w); | 526 | m_paintCtx.fullscreenWindows.removeAll(w); | ||
527 | } | 527 | } | ||
528 | 528 | | |||
529 | void SlideEffect::numberDesktopsChanged(uint) | 529 | void SlideEffect::numberDesktopsChanged(uint) | ||
530 | { | 530 | { | ||
531 | if (! m_active) { | 531 | if (!m_active) { | ||
532 | return; | 532 | return; | ||
533 | } | 533 | } | ||
534 | stop(); | 534 | stop(); | ||
535 | } | 535 | } | ||
536 | 536 | | |||
537 | void SlideEffect::numberScreensChanged() | 537 | void SlideEffect::numberScreensChanged() | ||
538 | { | 538 | { | ||
539 | if (! m_active) { | 539 | if (!m_active) { | ||
540 | return; | 540 | return; | ||
541 | } | 541 | } | ||
542 | stop(); | 542 | stop(); | ||
543 | } | 543 | } | ||
544 | 544 | | |||
545 | } // namespace KWin | 545 | } // namespace KWin |