Changeset View
Changeset View
Standalone View
Standalone View
effects/coverswitch/coverswitch.cpp
Show First 20 Lines • Show All 44 Lines • ▼ Show 20 Line(s) | 42 | CoverSwitchEffect::CoverSwitchEffect() | |||
---|---|---|---|---|---|
45 | , animation(false) | 45 | , animation(false) | ||
46 | , start(false) | 46 | , start(false) | ||
47 | , stop(false) | 47 | , stop(false) | ||
48 | , stopRequested(false) | 48 | , stopRequested(false) | ||
49 | , startRequested(false) | 49 | , startRequested(false) | ||
50 | , zPosition(900.0) | 50 | , zPosition(900.0) | ||
51 | , scaleFactor(0.0) | 51 | , scaleFactor(0.0) | ||
52 | , direction(Left) | 52 | , direction(Left) | ||
53 | , selected_window(0) | 53 | , selected_window(nullptr) | ||
54 | , captionFrame(NULL) | 54 | , captionFrame(nullptr) | ||
55 | , primaryTabBox(false) | 55 | , primaryTabBox(false) | ||
56 | , secondaryTabBox(false) | 56 | , secondaryTabBox(false) | ||
57 | { | 57 | { | ||
58 | initConfig<CoverSwitchConfig>(); | 58 | initConfig<CoverSwitchConfig>(); | ||
59 | reconfigure(ReconfigureAll); | 59 | reconfigure(ReconfigureAll); | ||
60 | 60 | | |||
61 | // Caption frame | 61 | // Caption frame | ||
62 | captionFont.setBold(true); | 62 | captionFont.setBold(true); | ||
63 | captionFont.setPointSize(captionFont.pointSize() * 2); | 63 | captionFont.setPointSize(captionFont.pointSize() * 2); | ||
64 | 64 | | |||
65 | if (effects->compositingType() == OpenGL2Compositing) { | 65 | if (effects->compositingType() == OpenGL2Compositing) { | ||
66 | m_reflectionShader = ShaderManager::instance()->generateShaderFromResources(ShaderTrait::MapTexture, QString(), QStringLiteral("coverswitch-reflection.glsl")); | 66 | m_reflectionShader = ShaderManager::instance()->generateShaderFromResources(ShaderTrait::MapTexture, QString(), QStringLiteral("coverswitch-reflection.glsl")); | ||
67 | } else { | 67 | } else { | ||
68 | m_reflectionShader = NULL; | 68 | m_reflectionShader = nullptr; | ||
69 | } | 69 | } | ||
70 | connect(effects, &EffectsHandler::windowClosed, this, &CoverSwitchEffect::slotWindowClosed); | 70 | connect(effects, &EffectsHandler::windowClosed, this, &CoverSwitchEffect::slotWindowClosed); | ||
71 | connect(effects, &EffectsHandler::tabBoxAdded, this, &CoverSwitchEffect::slotTabBoxAdded); | 71 | connect(effects, &EffectsHandler::tabBoxAdded, this, &CoverSwitchEffect::slotTabBoxAdded); | ||
72 | connect(effects, &EffectsHandler::tabBoxClosed, this, &CoverSwitchEffect::slotTabBoxClosed); | 72 | connect(effects, &EffectsHandler::tabBoxClosed, this, &CoverSwitchEffect::slotTabBoxClosed); | ||
73 | connect(effects, &EffectsHandler::tabBoxUpdated, this, &CoverSwitchEffect::slotTabBoxUpdated); | 73 | connect(effects, &EffectsHandler::tabBoxUpdated, this, &CoverSwitchEffect::slotTabBoxUpdated); | ||
74 | connect(effects, &EffectsHandler::tabBoxKeyEvent, this, &CoverSwitchEffect::slotTabBoxKeyEvent); | 74 | connect(effects, &EffectsHandler::tabBoxKeyEvent, this, &CoverSwitchEffect::slotTabBoxKeyEvent); | ||
75 | } | 75 | } | ||
76 | 76 | | |||
▲ Show 20 Lines • Show All 41 Lines • ▼ Show 20 Line(s) | |||||
118 | 118 | | |||
119 | void CoverSwitchEffect::prePaintScreen(ScreenPrePaintData& data, int time) | 119 | void CoverSwitchEffect::prePaintScreen(ScreenPrePaintData& data, int time) | ||
120 | { | 120 | { | ||
121 | if (mActivated || stop || stopRequested) { | 121 | if (mActivated || stop || stopRequested) { | ||
122 | data.mask |= Effect::PAINT_SCREEN_WITH_TRANSFORMED_WINDOWS; | 122 | data.mask |= Effect::PAINT_SCREEN_WITH_TRANSFORMED_WINDOWS; | ||
123 | if (animation || start || stop) { | 123 | if (animation || start || stop) { | ||
124 | timeLine.update(std::chrono::milliseconds(time)); | 124 | timeLine.update(std::chrono::milliseconds(time)); | ||
125 | } | 125 | } | ||
126 | if (selected_window == NULL) | 126 | if (selected_window == nullptr) | ||
127 | abort(); | 127 | abort(); | ||
128 | } | 128 | } | ||
129 | effects->prePaintScreen(data, time); | 129 | effects->prePaintScreen(data, time); | ||
130 | } | 130 | } | ||
131 | 131 | | |||
132 | void CoverSwitchEffect::paintScreen(int mask, QRegion region, ScreenPaintData& data) | 132 | void CoverSwitchEffect::paintScreen(int mask, QRegion region, ScreenPaintData& data) | ||
133 | { | 133 | { | ||
134 | effects->paintScreen(mask, region, data); | 134 | effects->paintScreen(mask, region, data); | ||
▲ Show 20 Lines • Show All 152 Lines • ▼ Show 20 Line(s) | |||||
287 | 287 | | |||
288 | void CoverSwitchEffect::postPaintScreen() | 288 | void CoverSwitchEffect::postPaintScreen() | ||
289 | { | 289 | { | ||
290 | if ((mActivated && (animation || start)) || stop || stopRequested) { | 290 | if ((mActivated && (animation || start)) || stop || stopRequested) { | ||
291 | if (timeLine.done()) { | 291 | if (timeLine.done()) { | ||
292 | timeLine.reset(); | 292 | timeLine.reset(); | ||
293 | if (stop) { | 293 | if (stop) { | ||
294 | stop = false; | 294 | stop = false; | ||
295 | effects->setActiveFullScreenEffect(0); | 295 | effects->setActiveFullScreenEffect(nullptr); | ||
296 | foreach (EffectWindow * window, referrencedWindows) { | 296 | foreach (EffectWindow * window, referrencedWindows) { | ||
297 | window->unrefWindow(); | 297 | window->unrefWindow(); | ||
298 | } | 298 | } | ||
299 | referrencedWindows.clear(); | 299 | referrencedWindows.clear(); | ||
300 | currentWindowList.clear(); | 300 | currentWindowList.clear(); | ||
301 | if (startRequested) { | 301 | if (startRequested) { | ||
302 | startRequested = false; | 302 | startRequested = false; | ||
303 | mActivated = true; | 303 | mActivated = true; | ||
▲ Show 20 Lines • Show All 238 Lines • ▼ Show 20 Line(s) | 539 | if (animateStop) { | |||
542 | } else if (start && scheduled_directions.isEmpty()) { | 542 | } else if (start && scheduled_directions.isEmpty()) { | ||
543 | start = false; | 543 | start = false; | ||
544 | stop = true; | 544 | stop = true; | ||
545 | timeLine.setElapsed(timeLine.duration() - timeLine.elapsed()); | 545 | timeLine.setElapsed(timeLine.duration() - timeLine.elapsed()); | ||
546 | } else { | 546 | } else { | ||
547 | stopRequested = true; | 547 | stopRequested = true; | ||
548 | } | 548 | } | ||
549 | } else { | 549 | } else { | ||
550 | effects->setActiveFullScreenEffect(0); | 550 | effects->setActiveFullScreenEffect(nullptr); | ||
551 | start = false; | 551 | start = false; | ||
552 | animation = false; | 552 | animation = false; | ||
553 | timeLine.reset(); | 553 | timeLine.reset(); | ||
554 | } | 554 | } | ||
555 | mActivated = false; | 555 | mActivated = false; | ||
556 | effects->unrefTabBox(); | 556 | effects->unrefTabBox(); | ||
557 | effects->stopMouseInterception(this); | 557 | effects->stopMouseInterception(this); | ||
558 | effects->addRepaintFull(); | 558 | effects->addRepaintFull(); | ||
559 | } | 559 | } | ||
560 | } | 560 | } | ||
561 | 561 | | |||
562 | void CoverSwitchEffect::slotTabBoxUpdated() | 562 | void CoverSwitchEffect::slotTabBoxUpdated() | ||
563 | { | 563 | { | ||
564 | if (mActivated) { | 564 | if (mActivated) { | ||
565 | if (animateSwitch && currentWindowList.count() > 1) { | 565 | if (animateSwitch && currentWindowList.count() > 1) { | ||
566 | // determine the switch direction | 566 | // determine the switch direction | ||
567 | if (selected_window != effects->currentTabBoxWindow()) { | 567 | if (selected_window != effects->currentTabBoxWindow()) { | ||
568 | if (selected_window != NULL) { | 568 | if (selected_window != nullptr) { | ||
569 | int old_index = currentWindowList.indexOf(selected_window); | 569 | int old_index = currentWindowList.indexOf(selected_window); | ||
570 | int new_index = effects->currentTabBoxWindowList().indexOf(effects->currentTabBoxWindow()); | 570 | int new_index = effects->currentTabBoxWindowList().indexOf(effects->currentTabBoxWindow()); | ||
571 | Direction new_direction; | 571 | Direction new_direction; | ||
572 | int distance = new_index - old_index; | 572 | int distance = new_index - old_index; | ||
573 | if (distance > 0) | 573 | if (distance > 0) | ||
574 | new_direction = Left; | 574 | new_direction = Left; | ||
575 | if (distance < 0) | 575 | if (distance < 0) | ||
576 | new_direction = Right; | 576 | new_direction = Right; | ||
▲ Show 20 Lines • Show All 119 Lines • ▼ Show 20 Line(s) | 695 | } else { | |||
696 | effects->paintWindow(w, | 696 | effects->paintWindow(w, | ||
697 | PAINT_WINDOW_TRANSFORMED, | 697 | PAINT_WINDOW_TRANSFORMED, | ||
698 | infiniteRegion(), data); | 698 | infiniteRegion(), data); | ||
699 | } | 699 | } | ||
700 | } | 700 | } | ||
701 | 701 | | |||
702 | void CoverSwitchEffect::paintFrontWindow(EffectWindow* frontWindow, int width, int leftWindows, int rightWindows, bool reflectedWindow) | 702 | void CoverSwitchEffect::paintFrontWindow(EffectWindow* frontWindow, int width, int leftWindows, int rightWindows, bool reflectedWindow) | ||
703 | { | 703 | { | ||
704 | if (frontWindow == NULL) | 704 | if (frontWindow == nullptr) | ||
705 | return; | 705 | return; | ||
706 | bool specialHandlingForward = false; | 706 | bool specialHandlingForward = false; | ||
707 | WindowPaintData data(frontWindow); | 707 | WindowPaintData data(frontWindow); | ||
708 | if (effects->numScreens() > 1) { | 708 | if (effects->numScreens() > 1) { | ||
709 | data.setProjectionMatrix(m_projectionMatrix); | 709 | data.setProjectionMatrix(m_projectionMatrix); | ||
710 | data.setModelViewMatrix(m_modelviewMatrix); | 710 | data.setModelViewMatrix(m_modelviewMatrix); | ||
711 | } | 711 | } | ||
712 | data.setXTranslation(area.width() * 0.5 - frontWindow->geometry().x() - frontWindow->geometry().width() * 0.5); | 712 | data.setXTranslation(area.width() * 0.5 - frontWindow->geometry().x() - frontWindow->geometry().width() * 0.5); | ||
▲ Show 20 Lines • Show All 46 Lines • ▼ Show 20 Line(s) | 751 | { | |||
759 | } | 759 | } | ||
760 | 760 | | |||
761 | const QSize screenSize = effects->virtualScreenSize(); | 761 | const QSize screenSize = effects->virtualScreenSize(); | ||
762 | float xTranslate = -((float)(width) * 0.5f - ((float)screenSize.width() * 0.5 * scaleFactor)); | 762 | float xTranslate = -((float)(width) * 0.5f - ((float)screenSize.width() * 0.5 * scaleFactor)); | ||
763 | if (!left) | 763 | if (!left) | ||
764 | xTranslate = ((float)screenSize.width() * 0.5 * scaleFactor) - (float)width * 0.5f; | 764 | xTranslate = ((float)screenSize.width() * 0.5 * scaleFactor) - (float)width * 0.5f; | ||
765 | // handling for additional window from other side | 765 | // handling for additional window from other side | ||
766 | // has to appear on this side after half of the time | 766 | // has to appear on this side after half of the time | ||
767 | if (animation && timeLine.value() >= 0.5 && additionalWindow != NULL) { | 767 | if (animation && timeLine.value() >= 0.5 && additionalWindow != nullptr) { | ||
768 | WindowPaintData data(additionalWindow); | 768 | WindowPaintData data(additionalWindow); | ||
769 | if (effects->numScreens() > 1) { | 769 | if (effects->numScreens() > 1) { | ||
770 | data.setProjectionMatrix(m_projectionMatrix); | 770 | data.setProjectionMatrix(m_projectionMatrix); | ||
771 | data.setModelViewMatrix(m_modelviewMatrix); | 771 | data.setModelViewMatrix(m_modelviewMatrix); | ||
772 | } | 772 | } | ||
773 | data.setRotationAxis(Qt::YAxis); | 773 | data.setRotationAxis(Qt::YAxis); | ||
774 | data.setRotationAngle(angle * rotateFactor); | 774 | data.setRotationAngle(angle * rotateFactor); | ||
775 | if (left) { | 775 | if (left) { | ||
776 | data.translate(-xTranslate - additionalWindow->geometry().x()); | 776 | data.translate(-xTranslate - additionalWindow->geometry().x()); | ||
777 | } | 777 | } | ||
778 | else { | 778 | else { | ||
779 | data.translate(xTranslate + area.width() - | 779 | data.translate(xTranslate + area.width() - | ||
780 | additionalWindow->geometry().x() - additionalWindow->geometry().width()); | 780 | additionalWindow->geometry().x() - additionalWindow->geometry().width()); | ||
781 | data.setRotationOrigin(QVector3D(additionalWindow->geometry().width(), 0.0, 0.0)); | 781 | data.setRotationOrigin(QVector3D(additionalWindow->geometry().width(), 0.0, 0.0)); | ||
782 | } | 782 | } | ||
783 | data.multiplyOpacity((timeLine.value() - 0.5) * 2.0); | 783 | data.multiplyOpacity((timeLine.value() - 0.5) * 2.0); | ||
784 | paintWindowCover(additionalWindow, reflectedWindows, data); | 784 | paintWindowCover(additionalWindow, reflectedWindows, data); | ||
785 | } | 785 | } | ||
786 | // normal behaviour | 786 | // normal behaviour | ||
787 | for (int i = 0; i < windows.count(); i++) { | 787 | for (int i = 0; i < windows.count(); i++) { | ||
788 | window = windows.at(i); | 788 | window = windows.at(i); | ||
789 | if (window == NULL || window->isDeleted()) { | 789 | if (window == nullptr || window->isDeleted()) { | ||
790 | continue; | 790 | continue; | ||
791 | } | 791 | } | ||
792 | WindowPaintData data(window); | 792 | WindowPaintData data(window); | ||
793 | if (effects->numScreens() > 1) { | 793 | if (effects->numScreens() > 1) { | ||
794 | data.setProjectionMatrix(m_projectionMatrix); | 794 | data.setProjectionMatrix(m_projectionMatrix); | ||
795 | data.setModelViewMatrix(m_modelviewMatrix); | 795 | data.setModelViewMatrix(m_modelviewMatrix); | ||
796 | } | 796 | } | ||
797 | data.setRotationAxis(Qt::YAxis); | 797 | data.setRotationAxis(Qt::YAxis); | ||
▲ Show 20 Lines • Show All 115 Lines • ▼ Show 20 Line(s) | |||||
913 | void CoverSwitchEffect::abort() | 913 | void CoverSwitchEffect::abort() | ||
914 | { | 914 | { | ||
915 | // it's possible that abort is called after tabbox has been closed | 915 | // it's possible that abort is called after tabbox has been closed | ||
916 | // in this case the cleanup is already done (see bug 207554) | 916 | // in this case the cleanup is already done (see bug 207554) | ||
917 | if (mActivated) { | 917 | if (mActivated) { | ||
918 | effects->unrefTabBox(); | 918 | effects->unrefTabBox(); | ||
919 | effects->stopMouseInterception(this); | 919 | effects->stopMouseInterception(this); | ||
920 | } | 920 | } | ||
921 | effects->setActiveFullScreenEffect(0); | 921 | effects->setActiveFullScreenEffect(nullptr); | ||
922 | timeLine.reset(); | 922 | timeLine.reset(); | ||
923 | mActivated = false; | 923 | mActivated = false; | ||
924 | stop = false; | 924 | stop = false; | ||
925 | stopRequested = false; | 925 | stopRequested = false; | ||
926 | effects->addRepaintFull(); | 926 | effects->addRepaintFull(); | ||
927 | captionFrame->free(); | 927 | captionFrame->free(); | ||
928 | } | 928 | } | ||
929 | 929 | | |||
930 | void CoverSwitchEffect::slotWindowClosed(EffectWindow* c) | 930 | void CoverSwitchEffect::slotWindowClosed(EffectWindow* c) | ||
931 | { | 931 | { | ||
932 | if (c == selected_window) | 932 | if (c == selected_window) | ||
933 | selected_window = 0; | 933 | selected_window = nullptr; | ||
934 | // if the list is not empty, the effect is active | 934 | // if the list is not empty, the effect is active | ||
935 | if (!currentWindowList.isEmpty()) { | 935 | if (!currentWindowList.isEmpty()) { | ||
936 | c->refWindow(); | 936 | c->refWindow(); | ||
937 | referrencedWindows.append(c); | 937 | referrencedWindows.append(c); | ||
938 | currentWindowList.removeAll(c); | 938 | currentWindowList.removeAll(c); | ||
939 | leftWindows.removeAll(c); | 939 | leftWindows.removeAll(c); | ||
940 | rightWindows.removeAll(c); | 940 | rightWindows.removeAll(c); | ||
941 | } | 941 | } | ||
▲ Show 20 Lines • Show All 64 Lines • Show Last 20 Lines |