Changeset View
Changeset View
Standalone View
Standalone View
effects/coverswitch/coverswitch.cpp
Show First 20 Lines • Show All 82 Lines • ▼ Show 20 Line(s) | |||||
83 | bool CoverSwitchEffect::supported() | 83 | bool CoverSwitchEffect::supported() | ||
84 | { | 84 | { | ||
85 | return effects->isOpenGLCompositing() && effects->animationsSupported(); | 85 | return effects->isOpenGLCompositing() && effects->animationsSupported(); | ||
86 | } | 86 | } | ||
87 | 87 | | |||
88 | void CoverSwitchEffect::reconfigure(ReconfigureFlags) | 88 | void CoverSwitchEffect::reconfigure(ReconfigureFlags) | ||
89 | { | 89 | { | ||
90 | CoverSwitchConfig::self()->read(); | 90 | CoverSwitchConfig::self()->read(); | ||
91 | animationDuration = animationTime<CoverSwitchConfig>(200); | 91 | animationDuration = std::chrono::milliseconds( | ||
92 | animationTime<CoverSwitchConfig>(200)); | ||||
92 | animateSwitch = CoverSwitchConfig::animateSwitch(); | 93 | animateSwitch = CoverSwitchConfig::animateSwitch(); | ||
93 | animateStart = CoverSwitchConfig::animateStart(); | 94 | animateStart = CoverSwitchConfig::animateStart(); | ||
94 | animateStop = CoverSwitchConfig::animateStop(); | 95 | animateStop = CoverSwitchConfig::animateStop(); | ||
95 | reflection = CoverSwitchConfig::reflection(); | 96 | reflection = CoverSwitchConfig::reflection(); | ||
96 | windowTitle = CoverSwitchConfig::windowTitle(); | 97 | windowTitle = CoverSwitchConfig::windowTitle(); | ||
97 | zPosition = CoverSwitchConfig::zPosition(); | 98 | zPosition = CoverSwitchConfig::zPosition(); | ||
98 | timeLine.setCurveShape(QTimeLine::EaseInOutCurve); | 99 | timeLine.setEasingCurve(QEasingCurve::InOutSine); | ||
99 | timeLine.setDuration(animationDuration); | 100 | timeLine.setDuration(animationDuration); | ||
100 | 101 | | |||
101 | // Defined outside the ui | 102 | // Defined outside the ui | ||
102 | primaryTabBox = CoverSwitchConfig::tabBox(); | 103 | primaryTabBox = CoverSwitchConfig::tabBox(); | ||
103 | secondaryTabBox = CoverSwitchConfig::tabBoxAlternative(); | 104 | secondaryTabBox = CoverSwitchConfig::tabBoxAlternative(); | ||
104 | 105 | | |||
105 | QColor tmp = CoverSwitchConfig::mirrorFrontColor(); | 106 | QColor tmp = CoverSwitchConfig::mirrorFrontColor(); | ||
106 | mirrorColor[0][0] = tmp.redF(); | 107 | mirrorColor[0][0] = tmp.redF(); | ||
107 | mirrorColor[0][1] = tmp.greenF(); | 108 | mirrorColor[0][1] = tmp.greenF(); | ||
108 | mirrorColor[0][2] = tmp.blueF(); | 109 | mirrorColor[0][2] = tmp.blueF(); | ||
109 | mirrorColor[0][3] = 1.0; | 110 | mirrorColor[0][3] = 1.0; | ||
110 | tmp = CoverSwitchConfig::mirrorRearColor(); | 111 | tmp = CoverSwitchConfig::mirrorRearColor(); | ||
111 | mirrorColor[1][0] = tmp.redF(); | 112 | mirrorColor[1][0] = tmp.redF(); | ||
112 | mirrorColor[1][1] = tmp.greenF(); | 113 | mirrorColor[1][1] = tmp.greenF(); | ||
113 | mirrorColor[1][2] = tmp.blueF(); | 114 | mirrorColor[1][2] = tmp.blueF(); | ||
114 | mirrorColor[1][3] = -1.0; | 115 | mirrorColor[1][3] = -1.0; | ||
115 | 116 | | |||
116 | } | 117 | } | ||
117 | 118 | | |||
118 | void CoverSwitchEffect::prePaintScreen(ScreenPrePaintData& data, int time) | 119 | void CoverSwitchEffect::prePaintScreen(ScreenPrePaintData& data, int time) | ||
119 | { | 120 | { | ||
120 | if (mActivated || stop || stopRequested) { | 121 | if (mActivated || stop || stopRequested) { | ||
121 | data.mask |= Effect::PAINT_SCREEN_WITH_TRANSFORMED_WINDOWS; | 122 | data.mask |= Effect::PAINT_SCREEN_WITH_TRANSFORMED_WINDOWS; | ||
122 | if (animation || start || stop) { | 123 | if (animation || start || stop) { | ||
123 | timeLine.setCurrentTime(timeLine.currentTime() + time); | 124 | timeLine.update(std::chrono::milliseconds(time)); | ||
124 | } | 125 | } | ||
125 | if (selected_window == NULL) | 126 | if (selected_window == NULL) | ||
126 | abort(); | 127 | abort(); | ||
127 | } | 128 | } | ||
128 | effects->prePaintScreen(data, time); | 129 | effects->prePaintScreen(data, time); | ||
129 | } | 130 | } | ||
130 | 131 | | |||
131 | void CoverSwitchEffect::paintScreen(int mask, QRegion region, ScreenPaintData& data) | 132 | void CoverSwitchEffect::paintScreen(int mask, QRegion region, ScreenPaintData& data) | ||
▲ Show 20 Lines • Show All 74 Lines • ▼ Show 20 Line(s) | 195 | if (reflection) { | |||
206 | float vertices[] = { | 207 | float vertices[] = { | ||
207 | -width * 0.5f, height, 0.0, | 208 | -width * 0.5f, height, 0.0, | ||
208 | width * 0.5f, height, 0.0, | 209 | width * 0.5f, height, 0.0, | ||
209 | width*reflectionScaleFactor, height, -5000, | 210 | width*reflectionScaleFactor, height, -5000, | ||
210 | -width*reflectionScaleFactor, height, -5000 | 211 | -width*reflectionScaleFactor, height, -5000 | ||
211 | }; | 212 | }; | ||
212 | // foreground | 213 | // foreground | ||
213 | if (start) { | 214 | if (start) { | ||
214 | mirrorColor[0][3] = timeLine.currentValue(); | 215 | mirrorColor[0][3] = timeLine.value(); | ||
215 | } else if (stop) { | 216 | } else if (stop) { | ||
216 | mirrorColor[0][3] = 1.0 - timeLine.currentValue(); | 217 | mirrorColor[0][3] = 1.0 - timeLine.value(); | ||
217 | } else { | 218 | } else { | ||
218 | mirrorColor[0][3] = 1.0; | 219 | mirrorColor[0][3] = 1.0; | ||
219 | } | 220 | } | ||
220 | 221 | | |||
221 | int y = 0; | 222 | int y = 0; | ||
222 | // have to adjust the y values to fit OpenGL | 223 | // have to adjust the y values to fit OpenGL | ||
223 | // in OpenGL y==0 is at bottom, in Qt at top | 224 | // in OpenGL y==0 is at bottom, in Qt at top | ||
224 | if (effects->numScreens() > 1) { | 225 | if (effects->numScreens() > 1) { | ||
▲ Show 20 Lines • Show All 44 Lines • ▼ Show 20 Line(s) | |||||
269 | glDisable(GL_BLEND); | 270 | glDisable(GL_BLEND); | ||
270 | } | 271 | } | ||
271 | paintScene(frontWindow, leftWindows, rightWindows); | 272 | paintScene(frontWindow, leftWindows, rightWindows); | ||
272 | 273 | | |||
273 | // Render the caption frame | 274 | // Render the caption frame | ||
274 | if (windowTitle) { | 275 | if (windowTitle) { | ||
275 | double opacity = 1.0; | 276 | double opacity = 1.0; | ||
276 | if (start) | 277 | if (start) | ||
277 | opacity = timeLine.currentValue(); | 278 | opacity = timeLine.value(); | ||
278 | else if (stop) | 279 | else if (stop) | ||
279 | opacity = 1.0 - timeLine.currentValue(); | 280 | opacity = 1.0 - timeLine.value(); | ||
280 | if (animation) | 281 | if (animation) | ||
281 | captionFrame->setCrossFadeProgress(timeLine.currentValue()); | 282 | captionFrame->setCrossFadeProgress(timeLine.value()); | ||
282 | captionFrame->render(region, opacity); | 283 | captionFrame->render(region, opacity); | ||
283 | } | 284 | } | ||
284 | } | 285 | } | ||
285 | } | 286 | } | ||
286 | 287 | | |||
287 | void CoverSwitchEffect::postPaintScreen() | 288 | void CoverSwitchEffect::postPaintScreen() | ||
288 | { | 289 | { | ||
289 | if ((mActivated && (animation || start)) || stop || stopRequested) { | 290 | if ((mActivated && (animation || start)) || stop || stopRequested) { | ||
290 | if (timeLine.currentValue() == 1.0) { | 291 | if (timeLine.done()) { | ||
291 | timeLine.setCurrentTime(0); | 292 | timeLine.reset(); | ||
292 | if (stop) { | 293 | if (stop) { | ||
293 | stop = false; | 294 | stop = false; | ||
294 | effects->setActiveFullScreenEffect(0); | 295 | effects->setActiveFullScreenEffect(0); | ||
295 | foreach (EffectWindow * window, referrencedWindows) { | 296 | foreach (EffectWindow * window, referrencedWindows) { | ||
296 | window->unrefWindow(); | 297 | window->unrefWindow(); | ||
297 | } | 298 | } | ||
298 | referrencedWindows.clear(); | 299 | referrencedWindows.clear(); | ||
299 | currentWindowList.clear(); | 300 | currentWindowList.clear(); | ||
▲ Show 20 Lines • Show All 55 Lines • ▼ Show 20 Line(s) | 332 | { | |||
355 | // paint sequence forward animation: right, front, left | 356 | // paint sequence forward animation: right, front, left | ||
356 | 357 | | |||
357 | if (!animation) { | 358 | if (!animation) { | ||
358 | paintWindows(leftWindows, true, reflectedWindows); | 359 | paintWindows(leftWindows, true, reflectedWindows); | ||
359 | paintWindows(rightWindows, false, reflectedWindows); | 360 | paintWindows(rightWindows, false, reflectedWindows); | ||
360 | paintFrontWindow(frontWindow, width, leftWindowCount, rightWindowCount, reflectedWindows); | 361 | paintFrontWindow(frontWindow, width, leftWindowCount, rightWindowCount, reflectedWindows); | ||
361 | } else { | 362 | } else { | ||
362 | if (direction == Right) { | 363 | if (direction == Right) { | ||
363 | if (timeLine.currentValue() < 0.5) { | 364 | if (timeLine.value() < 0.5) { | ||
364 | // paint in normal way | 365 | // paint in normal way | ||
365 | paintWindows(leftWindows, true, reflectedWindows); | 366 | paintWindows(leftWindows, true, reflectedWindows); | ||
366 | paintWindows(rightWindows, false, reflectedWindows); | 367 | paintWindows(rightWindows, false, reflectedWindows); | ||
367 | paintFrontWindow(frontWindow, width, leftWindowCount, rightWindowCount, reflectedWindows); | 368 | paintFrontWindow(frontWindow, width, leftWindowCount, rightWindowCount, reflectedWindows); | ||
368 | } else { | 369 | } else { | ||
369 | paintWindows(rightWindows, false, reflectedWindows); | 370 | paintWindows(rightWindows, false, reflectedWindows); | ||
370 | paintFrontWindow(frontWindow, width, leftWindowCount, rightWindowCount, reflectedWindows); | 371 | paintFrontWindow(frontWindow, width, leftWindowCount, rightWindowCount, reflectedWindows); | ||
371 | paintWindows(leftWindows, true, reflectedWindows, rightWindows.at(0)); | 372 | paintWindows(leftWindows, true, reflectedWindows, rightWindows.at(0)); | ||
372 | } | 373 | } | ||
373 | } else { | 374 | } else { | ||
374 | paintWindows(leftWindows, true, reflectedWindows); | 375 | paintWindows(leftWindows, true, reflectedWindows); | ||
375 | if (timeLine.currentValue() < 0.5) { | 376 | if (timeLine.value() < 0.5) { | ||
376 | paintWindows(rightWindows, false, reflectedWindows); | 377 | paintWindows(rightWindows, false, reflectedWindows); | ||
377 | paintFrontWindow(frontWindow, width, leftWindowCount, rightWindowCount, reflectedWindows); | 378 | paintFrontWindow(frontWindow, width, leftWindowCount, rightWindowCount, reflectedWindows); | ||
378 | } else { | 379 | } else { | ||
379 | EffectWindow* leftWindow; | 380 | EffectWindow* leftWindow; | ||
380 | if (leftWindowCount > 0) { | 381 | if (leftWindowCount > 0) { | ||
381 | leftWindow = leftWindows.at(0); | 382 | leftWindow = leftWindows.at(0); | ||
382 | paintFrontWindow(frontWindow, width, leftWindowCount, rightWindowCount, reflectedWindows); | 383 | paintFrontWindow(frontWindow, width, leftWindowCount, rightWindowCount, reflectedWindows); | ||
383 | } else | 384 | } else | ||
384 | leftWindow = frontWindow; | 385 | leftWindow = frontWindow; | ||
385 | paintWindows(rightWindows, false, reflectedWindows, leftWindow); | 386 | paintWindows(rightWindows, false, reflectedWindows, leftWindow); | ||
386 | } | 387 | } | ||
387 | } | 388 | } | ||
388 | } | 389 | } | ||
389 | } | 390 | } | ||
390 | 391 | | |||
391 | void CoverSwitchEffect::paintWindow(EffectWindow* w, int mask, QRegion region, WindowPaintData& data) | 392 | void CoverSwitchEffect::paintWindow(EffectWindow* w, int mask, QRegion region, WindowPaintData& data) | ||
392 | { | 393 | { | ||
393 | if (mActivated || stop || stopRequested) { | 394 | if (mActivated || stop || stopRequested) { | ||
394 | if (!(mask & PAINT_WINDOW_TRANSFORMED) && !w->isDesktop()) { | 395 | if (!(mask & PAINT_WINDOW_TRANSFORMED) && !w->isDesktop()) { | ||
395 | if ((start || stop) && w->isDock()) { | 396 | if ((start || stop) && w->isDock()) { | ||
396 | data.setOpacity(1.0 - timeLine.currentValue()); | 397 | data.setOpacity(1.0 - timeLine.value()); | ||
397 | if (stop) | 398 | if (stop) | ||
398 | data.setOpacity(timeLine.currentValue()); | 399 | data.setOpacity(timeLine.value()); | ||
399 | } else | 400 | } else | ||
400 | return; | 401 | return; | ||
401 | } | 402 | } | ||
402 | } | 403 | } | ||
403 | if ((start || stop) && (!w->isOnCurrentDesktop() || w->isMinimized())) { | 404 | if ((start || stop) && (!w->isOnCurrentDesktop() || w->isMinimized())) { | ||
404 | if (stop) // Fade out windows not on the current desktop | 405 | if (stop) // Fade out windows not on the current desktop | ||
405 | data.setOpacity((1.0 - timeLine.currentValue())); | 406 | data.setOpacity(1.0 - timeLine.value()); | ||
davidedmundson: one set of parentheses seems redundant | |||||
zzag: Well, I didn't add them. Yeah, probably, that's okay to delete them. | |||||
406 | else // Fade in Windows from other desktops when animation is started | 407 | else // Fade in Windows from other desktops when animation is started | ||
407 | data.setOpacity(timeLine.currentValue()); | 408 | data.setOpacity(timeLine.value()); | ||
408 | } | 409 | } | ||
409 | effects->paintWindow(w, mask, region, data); | 410 | effects->paintWindow(w, mask, region, data); | ||
410 | } | 411 | } | ||
411 | 412 | | |||
412 | void CoverSwitchEffect::slotTabBoxAdded(int mode) | 413 | void CoverSwitchEffect::slotTabBoxAdded(int mode) | ||
413 | { | 414 | { | ||
414 | if (effects->activeFullScreenEffect() && effects->activeFullScreenEffect() != this) | 415 | if (effects->activeFullScreenEffect() && effects->activeFullScreenEffect() != this) | ||
415 | return; | 416 | return; | ||
▲ Show 20 Lines • Show All 120 Lines • ▼ Show 20 Line(s) | |||||
536 | { | 537 | { | ||
537 | if (mActivated) { | 538 | if (mActivated) { | ||
538 | if (animateStop) { | 539 | if (animateStop) { | ||
539 | if (!animation && !start) { | 540 | if (!animation && !start) { | ||
540 | stop = true; | 541 | stop = true; | ||
541 | } else if (start && scheduled_directions.isEmpty()) { | 542 | } else if (start && scheduled_directions.isEmpty()) { | ||
542 | start = false; | 543 | start = false; | ||
543 | stop = true; | 544 | stop = true; | ||
544 | timeLine.setCurrentTime(timeLine.duration() - timeLine.currentValue()); | 545 | timeLine.setElapsed(timeLine.duration() - timeLine.elapsed()); | ||
it'll be a bigger refactor, but would it be more in line with Timeline to do .setDirection() (maybe afterwards) then we can kill all the data.setOpacity(1.0 - timeLine.currentValue()); if (stop) data.setOpacity(timeLine.currentValue()); everywhere. davidedmundson: it'll be a bigger refactor, but would it be more in line with Timeline to do .setDirection()… | |||||
Yes, it would be nice to just toggle direction. That's not really cool that effects call setCurrentTime/setElapsed(in fact, it's discouraged to call setElapsed). zzag: Yes, it would be nice to just toggle direction. That's not really cool that effects call… | |||||
545 | } else { | 546 | } else { | ||
546 | stopRequested = true; | 547 | stopRequested = true; | ||
547 | } | 548 | } | ||
548 | } else | 549 | } else { | ||
549 | effects->setActiveFullScreenEffect(0); | 550 | effects->setActiveFullScreenEffect(0); | ||
551 | start = false; | ||||
552 | animation = false; | ||||
553 | timeLine.reset(); | ||||
554 | } | ||||
we should reset the timeline here If animateStart is on and animateStop is off and a user cancels halfway through the load, we become inactive straight away and won't hit the main cleanup. davidedmundson: we should reset the timeline here
If animateStart is on and animateStop is off and a user… | |||||
zzag: Probably, we also have to reset `start`. | |||||
550 | mActivated = false; | 555 | mActivated = false; | ||
551 | effects->unrefTabBox(); | 556 | effects->unrefTabBox(); | ||
552 | effects->stopMouseInterception(this); | 557 | effects->stopMouseInterception(this); | ||
553 | effects->addRepaintFull(); | 558 | effects->addRepaintFull(); | ||
554 | } | 559 | } | ||
555 | } | 560 | } | ||
556 | 561 | | |||
557 | void CoverSwitchEffect::slotTabBoxUpdated() | 562 | void CoverSwitchEffect::slotTabBoxUpdated() | ||
▲ Show 20 Lines • Show All 51 Lines • ▼ Show 20 Line(s) | |||||
609 | 614 | | |||
610 | void CoverSwitchEffect::paintWindowCover(EffectWindow* w, bool reflectedWindow, WindowPaintData& data) | 615 | void CoverSwitchEffect::paintWindowCover(EffectWindow* w, bool reflectedWindow, WindowPaintData& data) | ||
611 | { | 616 | { | ||
612 | QRect windowRect = w->geometry(); | 617 | QRect windowRect = w->geometry(); | ||
613 | data.setYTranslation(area.height() - windowRect.y() - windowRect.height()); | 618 | data.setYTranslation(area.height() - windowRect.y() - windowRect.height()); | ||
614 | data.setZTranslation(-zPosition); | 619 | data.setZTranslation(-zPosition); | ||
615 | if (start) { | 620 | if (start) { | ||
616 | if (w->isMinimized()) { | 621 | if (w->isMinimized()) { | ||
617 | data.multiplyOpacity(timeLine.currentValue()); | 622 | data.multiplyOpacity(timeLine.value()); | ||
618 | } else { | 623 | } else { | ||
619 | const QVector3D translation = data.translation() * timeLine.currentValue(); | 624 | const QVector3D translation = data.translation() * timeLine.value(); | ||
620 | data.setXTranslation(translation.x()); | 625 | data.setXTranslation(translation.x()); | ||
621 | data.setYTranslation(translation.y()); | 626 | data.setYTranslation(translation.y()); | ||
622 | data.setZTranslation(translation.z()); | 627 | data.setZTranslation(translation.z()); | ||
623 | if (effects->numScreens() > 1) { | 628 | if (effects->numScreens() > 1) { | ||
624 | QRect clientRect = effects->clientArea(FullScreenArea, w->screen(), effects->currentDesktop()); | 629 | QRect clientRect = effects->clientArea(FullScreenArea, w->screen(), effects->currentDesktop()); | ||
625 | QRect fullRect = effects->clientArea(FullArea, activeScreen, effects->currentDesktop()); | 630 | QRect fullRect = effects->clientArea(FullArea, activeScreen, effects->currentDesktop()); | ||
626 | if (w->screen() == activeScreen) { | 631 | if (w->screen() == activeScreen) { | ||
627 | if (clientRect.width() != fullRect.width() && clientRect.x() != fullRect.x()) { | 632 | if (clientRect.width() != fullRect.width() && clientRect.x() != fullRect.x()) { | ||
628 | data.translate(- clientRect.x() * (1.0f - timeLine.currentValue())); | 633 | data.translate(- clientRect.x() * (1.0f - timeLine.value())); | ||
629 | } | 634 | } | ||
630 | if (clientRect.height() != fullRect.height() && clientRect.y() != fullRect.y()) { | 635 | if (clientRect.height() != fullRect.height() && clientRect.y() != fullRect.y()) { | ||
631 | data.translate(0.0, - clientRect.y() * (1.0f - timeLine.currentValue())); | 636 | data.translate(0.0, - clientRect.y() * (1.0f - timeLine.value())); | ||
632 | } | 637 | } | ||
633 | } else { | 638 | } else { | ||
634 | if (clientRect.width() != fullRect.width() && clientRect.x() < area.x()) { | 639 | if (clientRect.width() != fullRect.width() && clientRect.x() < area.x()) { | ||
635 | data.translate(- clientRect.width() * (1.0f - timeLine.currentValue())); | 640 | data.translate(- clientRect.width() * (1.0f - timeLine.value())); | ||
636 | } | 641 | } | ||
637 | if (clientRect.height() != fullRect.height() && clientRect.y() < area.y()) { | 642 | if (clientRect.height() != fullRect.height() && clientRect.y() < area.y()) { | ||
638 | data.translate(0.0, - clientRect.height() * (1.0f - timeLine.currentValue())); | 643 | data.translate(0.0, - clientRect.height() * (1.0f - timeLine.value())); | ||
639 | } | 644 | } | ||
640 | } | 645 | } | ||
641 | } | 646 | } | ||
642 | data.setRotationAngle(data.rotationAngle() * timeLine.currentValue()); | 647 | data.setRotationAngle(data.rotationAngle() * timeLine.value()); | ||
643 | } | 648 | } | ||
644 | } | 649 | } | ||
645 | if (stop) { | 650 | if (stop) { | ||
646 | if (w->isMinimized() && w != effects->activeWindow()) { | 651 | if (w->isMinimized() && w != effects->activeWindow()) { | ||
647 | data.multiplyOpacity((1.0 - timeLine.currentValue())); | 652 | data.multiplyOpacity(1.0 - timeLine.value()); | ||
648 | } else { | 653 | } else { | ||
649 | const QVector3D translation = data.translation() * (1.0 - timeLine.currentValue()); | 654 | const QVector3D translation = data.translation() * (1.0 - timeLine.value()); | ||
650 | data.setXTranslation(translation.x()); | 655 | data.setXTranslation(translation.x()); | ||
651 | data.setYTranslation(translation.y()); | 656 | data.setYTranslation(translation.y()); | ||
652 | data.setZTranslation(translation.z()); | 657 | data.setZTranslation(translation.z()); | ||
653 | if (effects->numScreens() > 1) { | 658 | if (effects->numScreens() > 1) { | ||
654 | QRect clientRect = effects->clientArea(FullScreenArea, w->screen(), effects->currentDesktop()); | 659 | QRect clientRect = effects->clientArea(FullScreenArea, w->screen(), effects->currentDesktop()); | ||
655 | QRect rect = effects->clientArea(FullScreenArea, activeScreen, effects->currentDesktop()); | 660 | QRect rect = effects->clientArea(FullScreenArea, activeScreen, effects->currentDesktop()); | ||
656 | QRect fullRect = effects->clientArea(FullArea, activeScreen, effects->currentDesktop()); | 661 | QRect fullRect = effects->clientArea(FullArea, activeScreen, effects->currentDesktop()); | ||
657 | if (w->screen() == activeScreen) { | 662 | if (w->screen() == activeScreen) { | ||
658 | if (clientRect.width() != fullRect.width() && clientRect.x() != fullRect.x()) { | 663 | if (clientRect.width() != fullRect.width() && clientRect.x() != fullRect.x()) { | ||
659 | data.translate(- clientRect.x() * timeLine.currentValue()); | 664 | data.translate(- clientRect.x() * timeLine.value()); | ||
660 | } | 665 | } | ||
661 | if (clientRect.height() != fullRect.height() && clientRect.y() != fullRect.y()) { | 666 | if (clientRect.height() != fullRect.height() && clientRect.y() != fullRect.y()) { | ||
662 | data.translate(0.0, - clientRect.y() * timeLine.currentValue()); | 667 | data.translate(0.0, - clientRect.y() * timeLine.value()); | ||
663 | } | 668 | } | ||
664 | } else { | 669 | } else { | ||
665 | if (clientRect.width() != fullRect.width() && clientRect.x() < rect.x()) { | 670 | if (clientRect.width() != fullRect.width() && clientRect.x() < rect.x()) { | ||
666 | data.translate(- clientRect.width() * timeLine.currentValue()); | 671 | data.translate(- clientRect.width() * timeLine.value()); | ||
667 | } | 672 | } | ||
668 | if (clientRect.height() != fullRect.height() && clientRect.y() < area.y()) { | 673 | if (clientRect.height() != fullRect.height() && clientRect.y() < area.y()) { | ||
669 | data.translate(0.0, - clientRect.height() * timeLine.currentValue()); | 674 | data.translate(0.0, - clientRect.height() * timeLine.value()); | ||
670 | } | 675 | } | ||
671 | } | 676 | } | ||
672 | } | 677 | } | ||
673 | data.setRotationAngle(data.rotationAngle() * (1.0 - timeLine.currentValue())); | 678 | data.setRotationAngle(data.rotationAngle() * (1.0 - timeLine.value())); | ||
674 | } | 679 | } | ||
675 | } | 680 | } | ||
676 | 681 | | |||
677 | if (reflectedWindow) { | 682 | if (reflectedWindow) { | ||
678 | QMatrix4x4 reflectionMatrix; | 683 | QMatrix4x4 reflectionMatrix; | ||
679 | reflectionMatrix.scale(1.0, -1.0, 1.0); | 684 | reflectionMatrix.scale(1.0, -1.0, 1.0); | ||
680 | data.setModelViewMatrix(reflectionMatrix*data.modelViewMatrix()); | 685 | data.setModelViewMatrix(reflectionMatrix*data.modelViewMatrix()); | ||
681 | data.setYTranslation(- area.height() - windowRect.y() - windowRect.height()); | 686 | data.setYTranslation(- area.height() - windowRect.y() - windowRect.height()); | ||
682 | if (start) { | 687 | if (start) { | ||
683 | data.multiplyOpacity(timeLine.currentValue()); | 688 | data.multiplyOpacity(timeLine.value()); | ||
684 | } else if (stop) { | 689 | } else if (stop) { | ||
685 | data.multiplyOpacity(1.0 - timeLine.currentValue()); | 690 | data.multiplyOpacity(1.0 - timeLine.value()); | ||
686 | } | 691 | } | ||
687 | effects->drawWindow(w, | 692 | effects->drawWindow(w, | ||
688 | PAINT_WINDOW_TRANSFORMED, | 693 | PAINT_WINDOW_TRANSFORMED, | ||
689 | infiniteRegion(), data); | 694 | infiniteRegion(), data); | ||
690 | } else { | 695 | } else { | ||
691 | effects->paintWindow(w, | 696 | effects->paintWindow(w, | ||
692 | PAINT_WINDOW_TRANSFORMED, | 697 | PAINT_WINDOW_TRANSFORMED, | ||
693 | infiniteRegion(), data); | 698 | infiniteRegion(), data); | ||
Show All 21 Lines | 703 | { | |||
715 | } | 720 | } | ||
716 | if (animation) { | 721 | if (animation) { | ||
717 | float distance = 0.0; | 722 | float distance = 0.0; | ||
718 | const QSize screenSize = effects->virtualScreenSize(); | 723 | const QSize screenSize = effects->virtualScreenSize(); | ||
719 | if (direction == Right) { | 724 | if (direction == Right) { | ||
720 | // move to right | 725 | // move to right | ||
721 | distance = -frontWindow->geometry().width() * 0.5f + area.width() * 0.5f + | 726 | distance = -frontWindow->geometry().width() * 0.5f + area.width() * 0.5f + | ||
722 | (((float)screenSize.width() * 0.5 * scaleFactor) - (float)area.width() * 0.5f) / rightWindows; | 727 | (((float)screenSize.width() * 0.5 * scaleFactor) - (float)area.width() * 0.5f) / rightWindows; | ||
723 | data.translate(distance * timeLine.currentValue()); | 728 | data.translate(distance * timeLine.value()); | ||
724 | data.setRotationAxis(Qt::YAxis); | 729 | data.setRotationAxis(Qt::YAxis); | ||
725 | data.setRotationAngle(-angle * timeLine.currentValue()); | 730 | data.setRotationAngle(-angle * timeLine.value()); | ||
726 | data.setRotationOrigin(QVector3D(frontWindow->geometry().width(), 0.0, 0.0)); | 731 | data.setRotationOrigin(QVector3D(frontWindow->geometry().width(), 0.0, 0.0)); | ||
727 | } else { | 732 | } else { | ||
728 | // move to left | 733 | // move to left | ||
729 | distance = frontWindow->geometry().width() * 0.5f - area.width() * 0.5f + | 734 | distance = frontWindow->geometry().width() * 0.5f - area.width() * 0.5f + | ||
730 | ((float)width * 0.5f - ((float)screenSize.width() * 0.5 * scaleFactor)) / leftWindows; | 735 | ((float)width * 0.5f - ((float)screenSize.width() * 0.5 * scaleFactor)) / leftWindows; | ||
731 | float factor = 1.0; | 736 | float factor = 1.0; | ||
732 | if (specialHandlingForward) | 737 | if (specialHandlingForward) | ||
733 | factor = 2.0; | 738 | factor = 2.0; | ||
734 | data.translate(distance * timeLine.currentValue() * factor); | 739 | data.translate(distance * timeLine.value() * factor); | ||
735 | data.setRotationAxis(Qt::YAxis); | 740 | data.setRotationAxis(Qt::YAxis); | ||
736 | data.setRotationAngle(angle * timeLine.currentValue()); | 741 | data.setRotationAngle(angle * timeLine.value()); | ||
737 | } | 742 | } | ||
738 | } | 743 | } | ||
739 | if (specialHandlingForward) { | 744 | if (specialHandlingForward) { | ||
I know you've not touched this, but should these two lines be wrapped in && timeLine.value < 0.5 davidedmundson: I know you've not touched this, but
should these two lines be wrapped in
&& timeLine.value… | |||||
zzag: Probably, I also was wondering why opacity is ranging from -1 to 1. | |||||
740 | data.multiplyOpacity((1.0 - timeLine.currentValue() * 2.0)); | 745 | data.multiplyOpacity(1.0 - timeLine.value() * 2.0); | ||
741 | paintWindowCover(frontWindow, reflectedWindow, data); | 746 | paintWindowCover(frontWindow, reflectedWindow, data); | ||
742 | } else | 747 | } else | ||
743 | paintWindowCover(frontWindow, reflectedWindow, data); | 748 | paintWindowCover(frontWindow, reflectedWindow, data); | ||
744 | } | 749 | } | ||
745 | 750 | | |||
746 | void CoverSwitchEffect::paintWindows(const EffectWindowList& windows, bool left, bool reflectedWindows, EffectWindow* additionalWindow) | 751 | void CoverSwitchEffect::paintWindows(const EffectWindowList& windows, bool left, bool reflectedWindows, EffectWindow* additionalWindow) | ||
747 | { | 752 | { | ||
748 | int width = area.width(); | 753 | int width = area.width(); | ||
749 | int windowCount = windows.count(); | 754 | int windowCount = windows.count(); | ||
750 | EffectWindow* window; | 755 | EffectWindow* window; | ||
751 | 756 | | |||
752 | int rotateFactor = 1; | 757 | int rotateFactor = 1; | ||
753 | if (!left) { | 758 | if (!left) { | ||
754 | rotateFactor = -1; | 759 | rotateFactor = -1; | ||
755 | } | 760 | } | ||
756 | 761 | | |||
757 | const QSize screenSize = effects->virtualScreenSize(); | 762 | const QSize screenSize = effects->virtualScreenSize(); | ||
758 | float xTranslate = -((float)(width) * 0.5f - ((float)screenSize.width() * 0.5 * scaleFactor)); | 763 | float xTranslate = -((float)(width) * 0.5f - ((float)screenSize.width() * 0.5 * scaleFactor)); | ||
759 | if (!left) | 764 | if (!left) | ||
760 | xTranslate = ((float)screenSize.width() * 0.5 * scaleFactor) - (float)width * 0.5f; | 765 | xTranslate = ((float)screenSize.width() * 0.5 * scaleFactor) - (float)width * 0.5f; | ||
761 | // handling for additional window from other side | 766 | // handling for additional window from other side | ||
762 | // has to appear on this side after half of the time | 767 | // has to appear on this side after half of the time | ||
763 | if (animation && timeLine.currentValue() >= 0.5 && additionalWindow != NULL) { | 768 | if (animation && timeLine.value() >= 0.5 && additionalWindow != NULL) { | ||
764 | WindowPaintData data(additionalWindow); | 769 | WindowPaintData data(additionalWindow); | ||
765 | if (effects->numScreens() > 1) { | 770 | if (effects->numScreens() > 1) { | ||
766 | data.setProjectionMatrix(m_projectionMatrix); | 771 | data.setProjectionMatrix(m_projectionMatrix); | ||
767 | data.setModelViewMatrix(m_modelviewMatrix); | 772 | data.setModelViewMatrix(m_modelviewMatrix); | ||
768 | } | 773 | } | ||
769 | data.setRotationAxis(Qt::YAxis); | 774 | data.setRotationAxis(Qt::YAxis); | ||
770 | data.setRotationAngle(angle * rotateFactor); | 775 | data.setRotationAngle(angle * rotateFactor); | ||
771 | if (left) { | 776 | if (left) { | ||
772 | data.translate(-xTranslate - additionalWindow->geometry().x()); | 777 | data.translate(-xTranslate - additionalWindow->geometry().x()); | ||
773 | } | 778 | } | ||
774 | else { | 779 | else { | ||
775 | data.translate(xTranslate + area.width() - | 780 | data.translate(xTranslate + area.width() - | ||
776 | additionalWindow->geometry().x() - additionalWindow->geometry().width()); | 781 | additionalWindow->geometry().x() - additionalWindow->geometry().width()); | ||
777 | data.setRotationOrigin(QVector3D(additionalWindow->geometry().width(), 0.0, 0.0)); | 782 | data.setRotationOrigin(QVector3D(additionalWindow->geometry().width(), 0.0, 0.0)); | ||
778 | } | 783 | } | ||
779 | data.multiplyOpacity((timeLine.currentValue() - 0.5) * 2.0); | 784 | data.multiplyOpacity((timeLine.value() - 0.5) * 2.0); | ||
780 | paintWindowCover(additionalWindow, reflectedWindows, data); | 785 | paintWindowCover(additionalWindow, reflectedWindows, data); | ||
781 | } | 786 | } | ||
782 | // normal behaviour | 787 | // normal behaviour | ||
783 | for (int i = 0; i < windows.count(); i++) { | 788 | for (int i = 0; i < windows.count(); i++) { | ||
784 | window = windows.at(i); | 789 | window = windows.at(i); | ||
785 | if (window == NULL || window->isDeleted()) { | 790 | if (window == NULL || window->isDeleted()) { | ||
786 | continue; | 791 | continue; | ||
787 | } | 792 | } | ||
788 | WindowPaintData data(window); | 793 | WindowPaintData data(window); | ||
789 | if (effects->numScreens() > 1) { | 794 | if (effects->numScreens() > 1) { | ||
790 | data.setProjectionMatrix(m_projectionMatrix); | 795 | data.setProjectionMatrix(m_projectionMatrix); | ||
791 | data.setModelViewMatrix(m_modelviewMatrix); | 796 | data.setModelViewMatrix(m_modelviewMatrix); | ||
792 | } | 797 | } | ||
793 | data.setRotationAxis(Qt::YAxis); | 798 | data.setRotationAxis(Qt::YAxis); | ||
794 | data.setRotationAngle(angle); | 799 | data.setRotationAngle(angle); | ||
795 | if (left) | 800 | if (left) | ||
796 | data.translate(-xTranslate + xTranslate * i / windowCount - window->geometry().x()); | 801 | data.translate(-xTranslate + xTranslate * i / windowCount - window->geometry().x()); | ||
797 | else | 802 | else | ||
798 | data.translate(xTranslate + width - xTranslate * i / windowCount - window->geometry().x() - window->geometry().width()); | 803 | data.translate(xTranslate + width - xTranslate * i / windowCount - window->geometry().x() - window->geometry().width()); | ||
799 | if (animation) { | 804 | if (animation) { | ||
800 | if (direction == Right) { | 805 | if (direction == Right) { | ||
801 | if ((i == windowCount - 1) && left) { | 806 | if ((i == windowCount - 1) && left) { | ||
802 | // right most window on left side -> move to front | 807 | // right most window on left side -> move to front | ||
803 | // have to move one window distance plus half the difference between the window and the desktop size | 808 | // have to move one window distance plus half the difference between the window and the desktop size | ||
804 | data.translate((xTranslate / windowCount + (width - window->geometry().width()) * 0.5f) * timeLine.currentValue()); | 809 | data.translate((xTranslate / windowCount + (width - window->geometry().width()) * 0.5f) * timeLine.value()); | ||
805 | data.setRotationAngle(angle - angle * timeLine.currentValue()); | 810 | data.setRotationAngle(angle - angle * timeLine.value()); | ||
806 | } | 811 | } | ||
807 | // right most window does not have to be moved | 812 | // right most window does not have to be moved | ||
808 | else if (!left && (i == 0)); // do nothing | 813 | else if (!left && (i == 0)); // do nothing | ||
809 | else { | 814 | else { | ||
810 | // all other windows - move to next position | 815 | // all other windows - move to next position | ||
811 | data.translate(xTranslate / windowCount * timeLine.currentValue()); | 816 | data.translate(xTranslate / windowCount * timeLine.value()); | ||
812 | } | 817 | } | ||
813 | } else { | 818 | } else { | ||
814 | if ((i == windowCount - 1) && !left) { | 819 | if ((i == windowCount - 1) && !left) { | ||
815 | // left most window on right side -> move to front | 820 | // left most window on right side -> move to front | ||
816 | data.translate(- (xTranslate / windowCount + (width - window->geometry().width()) * 0.5f) * timeLine.currentValue()); | 821 | data.translate(- (xTranslate / windowCount + (width - window->geometry().width()) * 0.5f) * timeLine.value()); | ||
817 | data.setRotationAngle(angle - angle * timeLine.currentValue()); | 822 | data.setRotationAngle(angle - angle * timeLine.value()); | ||
818 | } | 823 | } | ||
819 | // left most window does not have to be moved | 824 | // left most window does not have to be moved | ||
820 | else if (i == 0 && left); // do nothing | 825 | else if (i == 0 && left); // do nothing | ||
821 | else { | 826 | else { | ||
822 | // all other windows - move to next position | 827 | // all other windows - move to next position | ||
823 | data.translate(- xTranslate / windowCount * timeLine.currentValue()); | 828 | data.translate(- xTranslate / windowCount * timeLine.value()); | ||
824 | } | 829 | } | ||
825 | } | 830 | } | ||
826 | } | 831 | } | ||
827 | if (!left) | 832 | if (!left) | ||
828 | data.setRotationOrigin(QVector3D(window->geometry().width(), 0.0, 0.0)); | 833 | data.setRotationOrigin(QVector3D(window->geometry().width(), 0.0, 0.0)); | ||
829 | data.setRotationAngle(data.rotationAngle() * rotateFactor); | 834 | data.setRotationAngle(data.rotationAngle() * rotateFactor); | ||
830 | // make window most to edge transparent if animation | 835 | // make window most to edge transparent if animation | ||
831 | if (animation && i == 0 && ((direction == Left && left) || (direction == Right && !left))) { | 836 | if (animation && i == 0 && ((direction == Left && left) || (direction == Right && !left))) { | ||
832 | // only for the first half of the animation | 837 | // only for the first half of the animation | ||
833 | if (timeLine.currentValue() < 0.5) { | 838 | if (timeLine.value() < 0.5) { | ||
834 | data.multiplyOpacity((1.0 - timeLine.currentValue() * 2.0)); | 839 | data.multiplyOpacity((1.0 - timeLine.value() * 2.0)); | ||
835 | paintWindowCover(window, reflectedWindows, data); | 840 | paintWindowCover(window, reflectedWindows, data); | ||
836 | } | 841 | } | ||
837 | } else { | 842 | } else { | ||
838 | paintWindowCover(window, reflectedWindows, data); | 843 | paintWindowCover(window, reflectedWindows, data); | ||
839 | } | 844 | } | ||
840 | } | 845 | } | ||
841 | } | 846 | } | ||
842 | 847 | | |||
▲ Show 20 Lines • Show All 66 Lines • ▼ Show 20 Line(s) | |||||
909 | void CoverSwitchEffect::abort() | 914 | void CoverSwitchEffect::abort() | ||
910 | { | 915 | { | ||
911 | // it's possible that abort is called after tabbox has been closed | 916 | // it's possible that abort is called after tabbox has been closed | ||
912 | // in this case the cleanup is already done (see bug 207554) | 917 | // in this case the cleanup is already done (see bug 207554) | ||
913 | if (mActivated) { | 918 | if (mActivated) { | ||
914 | effects->unrefTabBox(); | 919 | effects->unrefTabBox(); | ||
915 | effects->stopMouseInterception(this); | 920 | effects->stopMouseInterception(this); | ||
916 | } | 921 | } | ||
917 | effects->setActiveFullScreenEffect(0); | 922 | effects->setActiveFullScreenEffect(0); | ||
923 | timeLine.reset(); | ||||
davidedmundson: should we not reset the timeline here? | |||||
918 | mActivated = false; | 924 | mActivated = false; | ||
919 | stop = false; | 925 | stop = false; | ||
920 | stopRequested = false; | 926 | stopRequested = false; | ||
921 | effects->addRepaintFull(); | 927 | effects->addRepaintFull(); | ||
922 | captionFrame->free(); | 928 | captionFrame->free(); | ||
923 | } | 929 | } | ||
924 | 930 | | |||
925 | void CoverSwitchEffect::slotWindowClosed(EffectWindow* c) | 931 | void CoverSwitchEffect::slotWindowClosed(EffectWindow* c) | ||
▲ Show 20 Lines • Show All 75 Lines • Show Last 20 Lines |
one set of parentheses seems redundant