Changeset View
Changeset View
Standalone View
Standalone View
effects/kscreen/kscreen.cpp
Show First 20 Lines • Show All 68 Lines • ▼ Show 20 Line(s) | |||||
69 | { | 69 | { | ||
70 | } | 70 | } | ||
71 | 71 | | |||
72 | void KscreenEffect::reconfigure(ReconfigureFlags flags) | 72 | void KscreenEffect::reconfigure(ReconfigureFlags flags) | ||
73 | { | 73 | { | ||
74 | Q_UNUSED(flags) | 74 | Q_UNUSED(flags) | ||
75 | 75 | | |||
76 | KscreenConfig::self()->read(); | 76 | KscreenConfig::self()->read(); | ||
77 | m_timeLine.setDuration(animationTime<KscreenConfig>(250)); | 77 | m_timeLine.setDuration( | ||
78 | std::chrono::milliseconds(animationTime<KscreenConfig>(250))); | ||||
78 | } | 79 | } | ||
79 | 80 | | |||
80 | void KscreenEffect::prePaintScreen(ScreenPrePaintData &data, int time) | 81 | void KscreenEffect::prePaintScreen(ScreenPrePaintData &data, int time) | ||
81 | { | 82 | { | ||
82 | if (m_state == StateFadingIn || m_state == StateFadingOut) { | 83 | if (m_state == StateFadingIn || m_state == StateFadingOut) { | ||
83 | m_timeLine.setCurrentTime(m_timeLine.currentTime() + time); | 84 | m_timeLine.update(std::chrono::milliseconds(time)); | ||
84 | if (m_timeLine.currentValue() >= 1.0) { | 85 | if (m_timeLine.done()) { | ||
85 | switchState(); | 86 | switchState(); | ||
86 | } | 87 | } | ||
87 | } | 88 | } | ||
88 | effects->prePaintScreen(data, time); | 89 | effects->prePaintScreen(data, time); | ||
89 | } | 90 | } | ||
90 | 91 | | |||
91 | void KscreenEffect::postPaintScreen() | 92 | void KscreenEffect::postPaintScreen() | ||
92 | { | 93 | { | ||
Show All 10 Lines | 100 | { | |||
103 | effects->prePaintWindow(w, data, time); | 104 | effects->prePaintWindow(w, data, time); | ||
104 | } | 105 | } | ||
105 | 106 | | |||
106 | void KscreenEffect::paintWindow(EffectWindow *w, int mask, QRegion region, WindowPaintData &data) | 107 | void KscreenEffect::paintWindow(EffectWindow *w, int mask, QRegion region, WindowPaintData &data) | ||
107 | { | 108 | { | ||
108 | //fade to black and fully opaque | 109 | //fade to black and fully opaque | ||
109 | switch (m_state) { | 110 | switch (m_state) { | ||
110 | case StateFadingOut: | 111 | case StateFadingOut: | ||
111 | data.setOpacity(data.opacity() + (1.0 - data.opacity()) * m_timeLine.currentValue()); | 112 | data.setOpacity(data.opacity() + (1.0 - data.opacity()) * m_timeLine.value()); | ||
112 | data.multiplyBrightness(1.0 - m_timeLine.currentValue()); | 113 | data.multiplyBrightness(1.0 - m_timeLine.value()); | ||
113 | break; | 114 | break; | ||
114 | case StateFadedOut: | 115 | case StateFadedOut: | ||
115 | data.multiplyOpacity(0.0); | 116 | data.multiplyOpacity(0.0); | ||
116 | data.multiplyBrightness(0.0); | 117 | data.multiplyBrightness(0.0); | ||
117 | break; | 118 | break; | ||
118 | case StateFadingIn: | 119 | case StateFadingIn: | ||
119 | data.setOpacity(data.opacity() + (1.0 - data.opacity()) * (1.0 - m_timeLine.currentValue())); | 120 | data.setOpacity(data.opacity() + (1.0 - data.opacity()) * (1.0 - m_timeLine.value())); | ||
120 | data.multiplyBrightness(m_timeLine.currentValue()); | 121 | data.multiplyBrightness(m_timeLine.value()); | ||
121 | break; | 122 | break; | ||
122 | default: | 123 | default: | ||
123 | // no adjustment | 124 | // no adjustment | ||
124 | break; | 125 | break; | ||
125 | } | 126 | } | ||
126 | effects->paintWindow(w, mask, region, data); | 127 | effects->paintWindow(w, mask, region, data); | ||
127 | } | 128 | } | ||
128 | 129 | | |||
Show All 18 Lines | 147 | if (m_state != StateFadedOut) { | |||
147 | m_state = StateFadedOut; | 148 | m_state = StateFadedOut; | ||
148 | effects->addRepaintFull(); | 149 | effects->addRepaintFull(); | ||
149 | } | 150 | } | ||
150 | return; | 151 | return; | ||
151 | } | 152 | } | ||
152 | if (data[0] == 1) { | 153 | if (data[0] == 1) { | ||
153 | // kscreen wants KWin to fade out all windows | 154 | // kscreen wants KWin to fade out all windows | ||
154 | m_state = StateFadingOut; | 155 | m_state = StateFadingOut; | ||
155 | m_timeLine.setCurrentTime(0); | 156 | m_timeLine.reset(); | ||
156 | effects->addRepaintFull(); | 157 | effects->addRepaintFull(); | ||
157 | return; | 158 | return; | ||
158 | } | 159 | } | ||
159 | if (data[0] == 3) { | 160 | if (data[0] == 3) { | ||
160 | // kscreen wants KWin to fade in again | 161 | // kscreen wants KWin to fade in again | ||
161 | m_state = StateFadingIn; | 162 | m_state = StateFadingIn; | ||
162 | m_timeLine.setCurrentTime(0); | 163 | m_timeLine.reset(); | ||
163 | effects->addRepaintFull(); | 164 | effects->addRepaintFull(); | ||
164 | return; | 165 | return; | ||
165 | } | 166 | } | ||
166 | qCDebug(KWINEFFECTS) << "Incorrect Property state, immediate stop: " << data[0]; | 167 | qCDebug(KWINEFFECTS) << "Incorrect Property state, immediate stop: " << data[0]; | ||
167 | m_state = StateNormal; | 168 | m_state = StateNormal; | ||
168 | effects->addRepaintFull(); | 169 | effects->addRepaintFull(); | ||
169 | } | 170 | } | ||
170 | 171 | | |||
Show All 21 Lines |