Merge lp:~mc-return/compiz/compiz0.9.9.merge-plugin-screensaver into lp:compiz/0.9.11
- compiz0.9.9.merge-plugin-screensaver
- Merge into 0.9.11
Proposed by
MC Return
Status: | Work in progress | ||||
---|---|---|---|---|---|
Proposed branch: | lp:~mc-return/compiz/compiz0.9.9.merge-plugin-screensaver | ||||
Merge into: | lp:compiz/0.9.11 | ||||
Diff against target: |
1884 lines (+1781/-0) 18 files modified
debian/compiz-plugins.install (+1/-0) plugins/CMakeLists.txt (+1/-0) plugins/screensaver/CMakeLists.txt (+5/-0) plugins/screensaver/screensaver.xml.in (+132/-0) plugins/screensaver/src/effect.cpp (+63/-0) plugins/screensaver/src/effect.h (+6/-0) plugins/screensaver/src/flyingwindows.cpp (+393/-0) plugins/screensaver/src/flyingwindows.h (+94/-0) plugins/screensaver/src/matrix.cpp (+60/-0) plugins/screensaver/src/matrix.h (+69/-0) plugins/screensaver/src/rotatingcube.cpp (+104/-0) plugins/screensaver/src/rotatingcube.h (+34/-0) plugins/screensaver/src/screensaver.cpp (+312/-0) plugins/screensaver/src/screensaver.h (+258/-0) plugins/screensaver/src/vector.cpp (+14/-0) plugins/screensaver/src/vector.h (+164/-0) plugins/screensaver/src/wrapper.cpp (+67/-0) plugins/screensaver/src/wrapper.h (+4/-0) |
||||
To merge this branch: | bzr merge lp:~mc-return/compiz/compiz0.9.9.merge-plugin-screensaver | ||||
Related bugs: |
|
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Compiz Maintainers | Pending | ||
Review via email: mp+176729@code.launchpad.net |
Description of the change
To post a comment you must log in.
Unmerged revisions
- 3311. By MC Return
-
Optimized ABI check here as well
- 3310. By MC Return
-
Merged latest lp:compiz
- 3309. By MC Return
-
Minor .xml improvements
- 3308. By MC Return
-
Merged latest lp:compiz
- 3307. By MC Return
-
More code cleanup
- 3306. By MC Return
-
Fixed indentation and improved readability
- 3305. By MC Return
-
Improved readability
Fixed indentation
Removed redundant brackets - 3304. By MC Return
-
Reenabled showmouse and splash plugins for GLES,
which were disabled by mistake - 3303. By MC Return
-
Merged latest lp:compiz and fixed conflicts
- 3302. By MC Return
-
Merged latest lp:compiz and fixed conflicts
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === modified file 'debian/compiz-plugins.install' | |||
2 | --- debian/compiz-plugins.install 2013-02-26 16:48:27 +0000 | |||
3 | +++ debian/compiz-plugins.install 2013-07-24 16:13:49 +0000 | |||
4 | @@ -32,6 +32,7 @@ | |||
5 | 32 | debian/tmp/usr/*/compiz/*rotate.* | 32 | debian/tmp/usr/*/compiz/*rotate.* |
6 | 33 | debian/tmp/usr/*/compiz/*scaleaddon.* | 33 | debian/tmp/usr/*/compiz/*scaleaddon.* |
7 | 34 | debian/tmp/usr/*/compiz/*scalefilter.* | 34 | debian/tmp/usr/*/compiz/*scalefilter.* |
8 | 35 | debian/tmp/usr/*/compiz/*screensaver.* | ||
9 | 35 | debian/tmp/usr/*/compiz/*screenshot.* | 36 | debian/tmp/usr/*/compiz/*screenshot.* |
10 | 36 | debian/tmp/usr/*/compiz/*shelf.* | 37 | debian/tmp/usr/*/compiz/*shelf.* |
11 | 37 | debian/tmp/usr/*/compiz/*shift.* | 38 | debian/tmp/usr/*/compiz/*shift.* |
12 | 38 | 39 | ||
13 | === modified file 'plugins/CMakeLists.txt' | |||
14 | --- plugins/CMakeLists.txt 2013-07-07 13:31:29 +0000 | |||
15 | +++ plugins/CMakeLists.txt 2013-07-24 16:13:49 +0000 | |||
16 | @@ -31,6 +31,7 @@ | |||
17 | 31 | set (COMPIZ_DISABLE_PLUGIN_BENCH ON) | 31 | set (COMPIZ_DISABLE_PLUGIN_BENCH ON) |
18 | 32 | set (COMPIZ_DISABLE_PLUGIN_SHOWREPAINT ON) | 32 | set (COMPIZ_DISABLE_PLUGIN_SHOWREPAINT ON) |
19 | 33 | set (COMPIZ_DISABLE_PLUGIN_WIDGET ON) | 33 | set (COMPIZ_DISABLE_PLUGIN_WIDGET ON) |
20 | 34 | set (COMPIZ_DISABLE_PLUGIN_SCREENSAVER ON) | ||
21 | 34 | set (COMPIZ_DISABLE_PLUGIN_THUMBNAIL ON) | 35 | set (COMPIZ_DISABLE_PLUGIN_THUMBNAIL ON) |
22 | 35 | 36 | ||
23 | 36 | endif (BUILD_GLES) | 37 | endif (BUILD_GLES) |
24 | 37 | 38 | ||
25 | === added directory 'plugins/screensaver' | |||
26 | === added file 'plugins/screensaver/CMakeLists.txt' | |||
27 | --- plugins/screensaver/CMakeLists.txt 1970-01-01 00:00:00 +0000 | |||
28 | +++ plugins/screensaver/CMakeLists.txt 2013-07-24 16:13:49 +0000 | |||
29 | @@ -0,0 +1,5 @@ | |||
30 | 1 | find_package (Compiz REQUIRED) | ||
31 | 2 | |||
32 | 3 | include (CompizPlugin) | ||
33 | 4 | |||
34 | 5 | compiz_plugin (screensaver PLUGINDEPS composite opengl cube PKGDEPS xscrnsaver) | ||
35 | 0 | 6 | ||
36 | === added file 'plugins/screensaver/screensaver.xml.in' | |||
37 | --- plugins/screensaver/screensaver.xml.in 1970-01-01 00:00:00 +0000 | |||
38 | +++ plugins/screensaver/screensaver.xml.in 2013-07-24 16:13:49 +0000 | |||
39 | @@ -0,0 +1,132 @@ | |||
40 | 1 | <?xml version="1.0"?> | ||
41 | 2 | <compiz> | ||
42 | 3 | <plugin name="screensaver" useBcop="true"> | ||
43 | 4 | <_short>Screen Saver</_short> | ||
44 | 5 | <_long>Let windows take flight or the cube rotate</_long> | ||
45 | 6 | <deps> | ||
46 | 7 | <requirement> | ||
47 | 8 | <plugin>opengl</plugin> | ||
48 | 9 | <plugin>cube</plugin> | ||
49 | 10 | </requirement> | ||
50 | 11 | <relation type="after"> | ||
51 | 12 | <plugin>opengl</plugin> | ||
52 | 13 | <plugin>cube</plugin> | ||
53 | 14 | </relation> | ||
54 | 15 | </deps> | ||
55 | 16 | <category>Extras</category> | ||
56 | 17 | <options> | ||
57 | 18 | <group> | ||
58 | 19 | <_short>Bindings</_short> | ||
59 | 20 | <option name="initiate_key" type="key"> | ||
60 | 21 | <_short>Initiate Key</_short> | ||
61 | 22 | <_long>Key to manually start and stop the screensaver.</_long> | ||
62 | 23 | </option> | ||
63 | 24 | <option name="initiate_button" type="button"> | ||
64 | 25 | <_short>Initiate Button</_short> | ||
65 | 26 | <_long>Mouse button to start and stop the screensaver.</_long> | ||
66 | 27 | </option> | ||
67 | 28 | <option name="initiate_edge" type="edge"> | ||
68 | 29 | <_short>Initiate Corner / Edge</_short> | ||
69 | 30 | <_long>Start and stop the screensaver via screen corner or edge.</_long> | ||
70 | 31 | </option> | ||
71 | 32 | </group> | ||
72 | 33 | <option name="mode" type="int"> | ||
73 | 34 | <_short>Screensaver Mode</_short> | ||
74 | 35 | <_long>Choose between flying windows or rotating cube as screensaver.</_long> | ||
75 | 36 | <default>0</default> | ||
76 | 37 | <min>0</min> | ||
77 | 38 | <max>1</max> | ||
78 | 39 | <desc> | ||
79 | 40 | <value>0</value> | ||
80 | 41 | <name>Flying Windows</name> | ||
81 | 42 | </desc> | ||
82 | 43 | <desc> | ||
83 | 44 | <value>1</value> | ||
84 | 45 | <name>Rotating Cube</name> | ||
85 | 46 | </desc> | ||
86 | 47 | </option> | ||
87 | 48 | <option name="start_automatically" type="bool"> | ||
88 | 49 | <_short>Start Automatically</_short> | ||
89 | 50 | <_long>Start the chosen screensaver after a specified time period.</_long> | ||
90 | 51 | <default>true</default> | ||
91 | 52 | </option> | ||
92 | 53 | <option name="after" type="float"> | ||
93 | 54 | <_short>After (min)</_short> | ||
94 | 55 | <_long>Amount of time before the screensaver starts automatically (in minutes).</_long> | ||
95 | 56 | <default>5.0</default> | ||
96 | 57 | <min>0.1</min> | ||
97 | 58 | <max>1000.0</max> | ||
98 | 59 | <precision>0.01</precision> | ||
99 | 60 | </option> | ||
100 | 61 | <option name="fade_in_duration" type="float"> | ||
101 | 62 | <_short>Fade In Duration (sec)</_short> | ||
102 | 63 | <_long>Length of the fade in (in seconds).</_long> | ||
103 | 64 | <default>3.0</default> | ||
104 | 65 | <min>0.0</min> | ||
105 | 66 | <max>10.0</max> | ||
106 | 67 | <precision>0.01</precision> | ||
107 | 68 | </option> | ||
108 | 69 | <option name="fade_out_duration" type="float"> | ||
109 | 70 | <_short>Fade Out Duration (sec)</_short> | ||
110 | 71 | <_long>Length of the fade out (in seconds).</_long> | ||
111 | 72 | <default>1.0</default> | ||
112 | 73 | <min>0.0</min> | ||
113 | 74 | <max>10.0</max> | ||
114 | 75 | <precision>0.01</precision> | ||
115 | 76 | </option> | ||
116 | 77 | <group> | ||
117 | 78 | <_short>Flying Windows</_short> | ||
118 | 79 | <option name="window_match" type="match"> | ||
119 | 80 | <_short>Screen Saver Windows</_short> | ||
120 | 81 | <_long>The window types which should fly.</_long> | ||
121 | 82 | <default>type=Normal | Dialog | ModalDialog | Utility | Unknown</default> | ||
122 | 83 | </option> | ||
123 | 84 | <option name="mipmaps" type="bool"> | ||
124 | 85 | <_short>Mipmaps</_short> | ||
125 | 86 | <_long>Generate mipmaps for higher quality scaling.</_long> | ||
126 | 87 | <default>false</default> | ||
127 | 88 | </option> | ||
128 | 89 | <option name="attraction_depth" type="float"> | ||
129 | 90 | <_short>Attraction Depth</_short> | ||
130 | 91 | <_long>Attraction depth of the windows.</_long> | ||
131 | 92 | <default>1.5</default> | ||
132 | 93 | <min>0.0</min> | ||
133 | 94 | <max>10.0</max> | ||
134 | 95 | <precision>0.01</precision> | ||
135 | 96 | </option> | ||
136 | 97 | <option name="attraction_repulsion_ratio" type="float"> | ||
137 | 98 | <_short>Attraction / Repulsion Ratio</_short> | ||
138 | 99 | <_long>Attraction/Repulsion ratio of the windows.</_long> | ||
139 | 100 | <default>50.0</default> | ||
140 | 101 | <min>0.0</min> | ||
141 | 102 | <max>100.0</max> | ||
142 | 103 | <precision>0.01</precision> | ||
143 | 104 | </option> | ||
144 | 105 | <option name="bounce" type="bool"> | ||
145 | 106 | <_short>Bounce</_short> | ||
146 | 107 | <_long>Make windows bounce on the floor, still buggy, but essential with cube reflexion.</_long> | ||
147 | 108 | <default>true</default> | ||
148 | 109 | </option> | ||
149 | 110 | </group> | ||
150 | 111 | <group> | ||
151 | 112 | <_short>Rotating Cube</_short> | ||
152 | 113 | <option name="cube_rotation_speed" type="float"> | ||
153 | 114 | <_short>Cube Rotation Speed</_short> | ||
154 | 115 | <_long>The speed of the cube's rotation.</_long> | ||
155 | 116 | <default>1.0</default> | ||
156 | 117 | <min>-10.0</min> | ||
157 | 118 | <max>10.0</max> | ||
158 | 119 | <precision>0.01</precision> | ||
159 | 120 | </option> | ||
160 | 121 | <option name="cube_zoom" type="float"> | ||
161 | 122 | <_short>Zoom</_short> | ||
162 | 123 | <_long>The zoom applied.</_long> | ||
163 | 124 | <default>0.5</default> | ||
164 | 125 | <min>0.0</min> | ||
165 | 126 | <max>2.0</max> | ||
166 | 127 | <precision>0.1</precision> | ||
167 | 128 | </option> | ||
168 | 129 | </group> | ||
169 | 130 | </options> | ||
170 | 131 | </plugin> | ||
171 | 132 | </compiz> | ||
172 | 0 | 133 | ||
173 | === added directory 'plugins/screensaver/src' | |||
174 | === added file 'plugins/screensaver/src/effect.cpp' | |||
175 | --- plugins/screensaver/src/effect.cpp 1970-01-01 00:00:00 +0000 | |||
176 | +++ plugins/screensaver/src/effect.cpp 2013-07-24 16:13:49 +0000 | |||
177 | @@ -0,0 +1,63 @@ | |||
178 | 1 | #include "screensaver.h" | ||
179 | 2 | #include <cmath> | ||
180 | 3 | |||
181 | 4 | #define sigmoid(x) (1.0f / (1.0f + exp (-5.5f * 2 * ((x) - 0.5)))) | ||
182 | 5 | #define sigmoidProgress(x) ((sigmoid(x) - sigmoid(0)) / (sigmoid(1) - sigmoid(0))) | ||
183 | 6 | |||
184 | 7 | void | ||
185 | 8 | ScreenEffect::handleEvent (XEvent *event) | ||
186 | 9 | { | ||
187 | 10 | ScreenWrapper::handleEvent (event); | ||
188 | 11 | } | ||
189 | 12 | |||
190 | 13 | void | ||
191 | 14 | ScreenEffect::cubeGetRotation (float &x, float &v, float &progress) | ||
192 | 15 | { | ||
193 | 16 | ScreenWrapper::cubeGetRotation (x, v, progress); | ||
194 | 17 | } | ||
195 | 18 | |||
196 | 19 | bool ScreenEffect::enable () | ||
197 | 20 | { | ||
198 | 21 | progress = 0.0; | ||
199 | 22 | return true; | ||
200 | 23 | } | ||
201 | 24 | |||
202 | 25 | void ScreenEffect::preparePaint (int msSinceLastPaint) | ||
203 | 26 | { | ||
204 | 27 | if (ss->mState.running) | ||
205 | 28 | { | ||
206 | 29 | if (ss->mState.fadingIn) | ||
207 | 30 | { | ||
208 | 31 | float fadeDuration = ss->optionGetFadeInDuration () * 1000.0; | ||
209 | 32 | progress = sigmoidProgress (((float)ss->mTime) / fadeDuration); | ||
210 | 33 | ss->mTime += msSinceLastPaint; | ||
211 | 34 | |||
212 | 35 | if (ss->mTime >= fadeDuration) | ||
213 | 36 | { | ||
214 | 37 | if (ss->optionGetStartAutomatically ()) | ||
215 | 38 | XActivateScreenSaver(screen->dpy ()); | ||
216 | 39 | |||
217 | 40 | ss->mState.fadingIn = FALSE; | ||
218 | 41 | ss->mTime = 0; | ||
219 | 42 | } | ||
220 | 43 | } | ||
221 | 44 | else if (ss->mState.fadingOut) | ||
222 | 45 | { | ||
223 | 46 | float fadeDuration = ss->optionGetFadeOutDuration () * 1000.0; | ||
224 | 47 | progress = sigmoidProgress (((float)ss->mTime) / fadeDuration); | ||
225 | 48 | ss->mTime += msSinceLastPaint; | ||
226 | 49 | |||
227 | 50 | if (ss->mTime >= fadeDuration) | ||
228 | 51 | { | ||
229 | 52 | clean (); | ||
230 | 53 | ss->mEffect->cleanEffect = true; | ||
231 | 54 | ss->mState.running = FALSE; | ||
232 | 55 | ss->cScreen->damageScreen (); | ||
233 | 56 | } | ||
234 | 57 | } | ||
235 | 58 | else | ||
236 | 59 | progress = 1.0; | ||
237 | 60 | } | ||
238 | 61 | |||
239 | 62 | ScreenWrapper::preparePaint (msSinceLastPaint); | ||
240 | 63 | } | ||
241 | 0 | 64 | ||
242 | === added file 'plugins/screensaver/src/effect.h' | |||
243 | --- plugins/screensaver/src/effect.h 1970-01-01 00:00:00 +0000 | |||
244 | +++ plugins/screensaver/src/effect.h 2013-07-24 16:13:49 +0000 | |||
245 | @@ -0,0 +1,6 @@ | |||
246 | 1 | #ifndef EFFECT_H | ||
247 | 2 | #define EFFECT_H | ||
248 | 3 | |||
249 | 4 | #include "screensaver_internal.h" | ||
250 | 5 | |||
251 | 6 | #endif | ||
252 | 0 | 7 | ||
253 | === added file 'plugins/screensaver/src/flyingwindows.cpp' | |||
254 | --- plugins/screensaver/src/flyingwindows.cpp 1970-01-01 00:00:00 +0000 | |||
255 | +++ plugins/screensaver/src/flyingwindows.cpp 2013-07-24 16:13:49 +0000 | |||
256 | @@ -0,0 +1,393 @@ | |||
257 | 1 | #include "flyingwindows.h" | ||
258 | 2 | |||
259 | 3 | #define NE 0 | ||
260 | 4 | #define NO 1 | ||
261 | 5 | #define SE 2 | ||
262 | 6 | #define SO 3 | ||
263 | 7 | #define C 4 | ||
264 | 8 | |||
265 | 9 | void ScreenFlyingWindows::handleEvent (XEvent *event) | ||
266 | 10 | { | ||
267 | 11 | ScreenEffect::handleEvent (event); | ||
268 | 12 | |||
269 | 13 | if (event->type == MapNotify) | ||
270 | 14 | { | ||
271 | 15 | CompWindow* w = screen->findWindow (event->xmap.window); | ||
272 | 16 | |||
273 | 17 | if (w) | ||
274 | 18 | WindowFlyingWindows::getInstance(w).initWindow(); | ||
275 | 19 | } | ||
276 | 20 | } | ||
277 | 21 | |||
278 | 22 | bool ScreenFlyingWindows::enable () | ||
279 | 23 | { | ||
280 | 24 | ss->mAngleCam = 0.0; | ||
281 | 25 | ss->mScreenCenter = Vector (0.0, ss->optionGetBounce () ? 0.2 : 0.0, | ||
282 | 26 | -ss->optionGetAttractionDepth ()); | ||
283 | 27 | ss->mCamera = Matrix::identity; | ||
284 | 28 | ss->mDesktopOpacity = OPAQUE; | ||
285 | 29 | |||
286 | 30 | foreach (CompWindow *w, screen->windows ()) | ||
287 | 31 | { | ||
288 | 32 | WindowFlyingWindows::getInstance(w).initWindow (); | ||
289 | 33 | } | ||
290 | 34 | |||
291 | 35 | return ScreenEffect::enable (); | ||
292 | 36 | } | ||
293 | 37 | |||
294 | 38 | void ScreenFlyingWindows::disable () | ||
295 | 39 | { | ||
296 | 40 | foreach (CompWindow *w, screen->windows ()) | ||
297 | 41 | { | ||
298 | 42 | WindowFlyingWindows& sw = WindowFlyingWindows::getInstance (w); | ||
299 | 43 | |||
300 | 44 | if (sw.active) | ||
301 | 45 | sw.transformFadeOut = ss->mCameraMat * sw.transform; | ||
302 | 46 | |||
303 | 47 | else sw.opacityFadeOut = sw.opacity; | ||
304 | 48 | } | ||
305 | 49 | |||
306 | 50 | ss->mCameraMat = Matrix::identity; | ||
307 | 51 | ScreenEffect::disable (); | ||
308 | 52 | } | ||
309 | 53 | |||
310 | 54 | void ScreenFlyingWindows::addForce (const Point& p1, const Point& p2, const Point& center, Vector& resultante, Vector& couple, float w, bool attract) | ||
311 | 55 | { | ||
312 | 56 | Vector u = p2 - p1; | ||
313 | 57 | float d = u.norm (); | ||
314 | 58 | u.normalize (); | ||
315 | 59 | |||
316 | 60 | if (d < 1e-5) | ||
317 | 61 | d = 1e-5; | ||
318 | 62 | |||
319 | 63 | Vector force = attract ? w * u * d * d : -w * u / (d * d); | ||
320 | 64 | resultante += force; | ||
321 | 65 | |||
322 | 66 | couple += (center - p1) ^ force; | ||
323 | 67 | } | ||
324 | 68 | |||
325 | 69 | void ScreenFlyingWindows::preparePaint (int msSinceLastPaint) | ||
326 | 70 | { | ||
327 | 71 | ScreenEffect::preparePaint (msSinceLastPaint); | ||
328 | 72 | |||
329 | 73 | float ratio = ss->optionGetAttractionRepulsionRatio() / 100.0; | ||
330 | 74 | float wAt = ratio; | ||
331 | 75 | float wRt = 1-ratio; | ||
332 | 76 | |||
333 | 77 | if (ss->mState.fadingIn) | ||
334 | 78 | { | ||
335 | 79 | wAt *= getProgress(); | ||
336 | 80 | wRt *= getProgress(); | ||
337 | 81 | |||
338 | 82 | ss->mDesktopOpacity = (GLushort)(OPAQUE * (1.0 - getProgress ())); | ||
339 | 83 | } | ||
340 | 84 | |||
341 | 85 | if (ss->mState.fadingOut) | ||
342 | 86 | ss->mDesktopOpacity = (GLushort)(OPAQUE * getProgress ()); | ||
343 | 87 | |||
344 | 88 | if (!ss->mState.fadingOut) | ||
345 | 89 | { | ||
346 | 90 | ss->mAngleCam += ((float)msSinceLastPaint) / 100000.0; | ||
347 | 91 | |||
348 | 92 | if (ss->mAngleCam > 0.03) | ||
349 | 93 | ss->mAngleCam = 0.03; | ||
350 | 94 | |||
351 | 95 | ss->mCamera.rotate (ss->mAngleCam*msSinceLastPaint, 0.0, 1.0, 0.0); | ||
352 | 96 | |||
353 | 97 | Matrix centerTrans = Matrix::identity; | ||
354 | 98 | Matrix centerTransInv = Matrix::identity; | ||
355 | 99 | |||
356 | 100 | Vector screenCenterTranslated = ss->mScreenCenter.toCoordsSpace (); | ||
357 | 101 | screenCenterTranslated[z] *= screen->width (); | ||
358 | 102 | |||
359 | 103 | centerTrans.scale (1.0, 1.0, 1.0 / screen->width ()); | ||
360 | 104 | centerTrans.translate (screenCenterTranslated); | ||
361 | 105 | centerTransInv.translate (-screenCenterTranslated); | ||
362 | 106 | centerTransInv.scale (1.0, 1.0, 1.0 * screen->width ()); | ||
363 | 107 | |||
364 | 108 | ss->mCameraMat = centerTrans * ss->mCamera * centerTransInv; | ||
365 | 109 | } | ||
366 | 110 | |||
367 | 111 | foreach (CompWindow *w, screen->windows ()) | ||
368 | 112 | { | ||
369 | 113 | WindowFlyingWindows& sw = WindowFlyingWindows::getInstance(w); | ||
370 | 114 | |||
371 | 115 | if (sw.active) | ||
372 | 116 | { | ||
373 | 117 | if (ss->mState.fadingOut) | ||
374 | 118 | sw.transform = interpolate (sw.transformFadeOut, Matrix::identity, getProgress ()); | ||
375 | 119 | else | ||
376 | 120 | { | ||
377 | 121 | int collisionVertex = -1; | ||
378 | 122 | int collisionIteration = 1; | ||
379 | 123 | Vector a, p, o, omega; | ||
380 | 124 | |||
381 | 125 | do | ||
382 | 126 | { | ||
383 | 127 | Vector resultante, couple, resultanteA, coupleA; | ||
384 | 128 | resultante = couple = resultanteA = coupleA = Vector::null; | ||
385 | 129 | Vector windowcenter = sw.vertex[C]; | ||
386 | 130 | float mass = sqrt (((float)(WIN_W(w) * WIN_H(w))) / (screen->width () * screen->height ())); | ||
387 | 131 | |||
388 | 132 | float wR = 1e-8 / mass * wRt; | ||
389 | 133 | float wA = 1e-8 / mass * wAt; | ||
390 | 134 | |||
391 | 135 | int numPoint = 0; | ||
392 | 136 | |||
393 | 137 | for (int i = 0; i < 5; ++i) | ||
394 | 138 | { | ||
395 | 139 | foreach (CompWindow *w2, screen->windows ()) | ||
396 | 140 | { | ||
397 | 141 | WindowFlyingWindows& sw2 = WindowFlyingWindows::getInstance (w2); | ||
398 | 142 | |||
399 | 143 | if (w2 != w && sw2.active) | ||
400 | 144 | { | ||
401 | 145 | ++numPoint; | ||
402 | 146 | |||
403 | 147 | for (int j = 0; j < 5; ++j) | ||
404 | 148 | addForce (sw.vertex[i], sw2.vertex[j], windowcenter, resultante, couple, wR, FALSE); | ||
405 | 149 | } | ||
406 | 150 | } | ||
407 | 151 | |||
408 | 152 | addForce (sw.vertex[i], ss->mScreenCenter, windowcenter, resultanteA, coupleA, wA, TRUE); | ||
409 | 153 | } | ||
410 | 154 | |||
411 | 155 | if (numPoint < 1) | ||
412 | 156 | numPoint = 1; | ||
413 | 157 | |||
414 | 158 | resultante += resultanteA*numPoint; | ||
415 | 159 | couple += coupleA*numPoint; | ||
416 | 160 | |||
417 | 161 | if (collisionVertex != -1) | ||
418 | 162 | { | ||
419 | 163 | float wb = sw.vertex[collisionVertex][y] / msSinceLastPaint * 5e-4; | ||
420 | 164 | resultante[y] = -wb; | ||
421 | 165 | float tmp = couple[z]; | ||
422 | 166 | couple = (sw.vertex[collisionVertex] - windowcenter) ^ Vector (0.0, -wb, 0.0); | ||
423 | 167 | couple[z] = tmp; | ||
424 | 168 | sw.speed[y] = 0; | ||
425 | 169 | } | ||
426 | 170 | |||
427 | 171 | a = resultante - 5e-4 * mass * sw.speed; | ||
428 | 172 | omega = couple * 1000 - 5e-3 * mass * sw.speedrot; | ||
429 | 173 | |||
430 | 174 | p = msSinceLastPaint * msSinceLastPaint * a + msSinceLastPaint * sw.speed; | ||
431 | 175 | sw.speed += msSinceLastPaint * a; | ||
432 | 176 | |||
433 | 177 | o = msSinceLastPaint * msSinceLastPaint * omega + msSinceLastPaint * sw.speedrot; | ||
434 | 178 | sw.speedrot += msSinceLastPaint * omega; | ||
435 | 179 | |||
436 | 180 | sw.transformTrans.translate (p[x]*screen->width (), -p[y]*screen->height (), p[z]); | ||
437 | 181 | sw.transformRot.rotate (o.norm(), o); | ||
438 | 182 | |||
439 | 183 | sw.transform = sw.transformTrans * sw.centerTrans * sw.transformRot * sw.centerTransInv; | ||
440 | 184 | |||
441 | 185 | sw.recalcVertices (); | ||
442 | 186 | |||
443 | 187 | if (ss->optionGetBounce ()) | ||
444 | 188 | for (int i = 0; i < 4; ++i) | ||
445 | 189 | { | ||
446 | 190 | if (sw.vertex[i][y] < -0.5) | ||
447 | 191 | collisionVertex = i; | ||
448 | 192 | } | ||
449 | 193 | |||
450 | 194 | } while (collisionVertex != -1 && --collisionIteration); | ||
451 | 195 | } | ||
452 | 196 | } | ||
453 | 197 | else | ||
454 | 198 | { | ||
455 | 199 | if (ss->mState.fadingOut) | ||
456 | 200 | sw.opacity = (GLushort)(sw.opacityOld * getProgress() + | ||
457 | 201 | sw.opacityFadeOut * (1 - getProgress())); | ||
458 | 202 | else | ||
459 | 203 | sw.steps = (int)((msSinceLastPaint * OPAQUE) / | ||
460 | 204 | (ss->optionGetFadeInDuration() * 1000.0)); | ||
461 | 205 | } | ||
462 | 206 | } | ||
463 | 207 | } | ||
464 | 208 | |||
465 | 209 | void ScreenFlyingWindows::donePaint () | ||
466 | 210 | { | ||
467 | 211 | ss->cScreen->damageScreen (); | ||
468 | 212 | ScreenEffect::donePaint (); | ||
469 | 213 | } | ||
470 | 214 | |||
471 | 215 | void ScreenFlyingWindows::paint (CompOutput::ptrList &outputs, | ||
472 | 216 | unsigned int mask) | ||
473 | 217 | { | ||
474 | 218 | CompOutput::ptrList newOutputs; | ||
475 | 219 | newOutputs.push_back (&screen->fullscreenOutput ()); | ||
476 | 220 | |||
477 | 221 | ScreenEffect::paint (newOutputs, mask); | ||
478 | 222 | } | ||
479 | 223 | |||
480 | 224 | bool | ||
481 | 225 | ScreenFlyingWindows::glPaintOutput(const GLScreenPaintAttrib &attrib, | ||
482 | 226 | const GLMatrix &transform, | ||
483 | 227 | const CompRegion ®ion, | ||
484 | 228 | CompOutput *output, | ||
485 | 229 | unsigned int mask) | ||
486 | 230 | { | ||
487 | 231 | ss->gScreen->clearTargetOutput (GL_COLOR_BUFFER_BIT); | ||
488 | 232 | return ScreenEffect::glPaintOutput (attrib, transform, region, output, mask | PAINT_SCREEN_TRANSFORMED_MASK); | ||
489 | 233 | } | ||
490 | 234 | |||
491 | 235 | void | ||
492 | 236 | ScreenFlyingWindows::glPaintTransformedOutput (const GLScreenPaintAttrib &attrib, | ||
493 | 237 | const GLMatrix &transform, | ||
494 | 238 | const CompRegion ®ion, | ||
495 | 239 | CompOutput *output, | ||
496 | 240 | unsigned int mask) | ||
497 | 241 | { | ||
498 | 242 | bool wasCulled = glIsEnabled (GL_CULL_FACE); | ||
499 | 243 | |||
500 | 244 | if (wasCulled) | ||
501 | 245 | glDisable (GL_CULL_FACE); | ||
502 | 246 | |||
503 | 247 | GLenum oldFilter = ss->gScreen->textureFilter (); | ||
504 | 248 | |||
505 | 249 | if (ss->optionGetMipmaps ()) | ||
506 | 250 | ss->gScreen->setTextureFilter (GL_LINEAR_MIPMAP_LINEAR); | ||
507 | 251 | |||
508 | 252 | mask &= ~PAINT_SCREEN_WITH_TRANSFORMED_WINDOWS_MASK; | ||
509 | 253 | |||
510 | 254 | GLboolean bTwoSite; | ||
511 | 255 | glGetBooleanv (GL_LIGHT_MODEL_TWO_SIDE, &bTwoSite); | ||
512 | 256 | glLightModeli (GL_LIGHT_MODEL_TWO_SIDE, ss->gScreen->lighting ()); | ||
513 | 257 | |||
514 | 258 | ScreenEffect::glPaintTransformedOutput (attrib, transform, region, output, mask); | ||
515 | 259 | |||
516 | 260 | glLightModeli (GL_LIGHT_MODEL_TWO_SIDE, bTwoSite); | ||
517 | 261 | |||
518 | 262 | ss->gScreen->setFilter (SCREEN_TRANS_FILTER, GLTexture::Good); | ||
519 | 263 | ss->gScreen->setTextureFilter (oldFilter); | ||
520 | 264 | |||
521 | 265 | if (wasCulled) | ||
522 | 266 | glEnable (GL_CULL_FACE); | ||
523 | 267 | } | ||
524 | 268 | |||
525 | 269 | WindowFlyingWindows::WindowFlyingWindows (CompWindow* w) : | ||
526 | 270 | WindowEffect(w), | ||
527 | 271 | active (FALSE), | ||
528 | 272 | opacity (GLWindow::get (w)->paintAttrib ().opacity), | ||
529 | 273 | opacityFadeOut (0), | ||
530 | 274 | opacityOld (0), | ||
531 | 275 | steps (0) | ||
532 | 276 | { | ||
533 | 277 | } | ||
534 | 278 | |||
535 | 279 | // Returns true if w is a flying window | ||
536 | 280 | bool WindowFlyingWindows::isActiveWin() | ||
537 | 281 | { | ||
538 | 282 | return !w->overrideRedirect () && \ | ||
539 | 283 | w->mapNum () && \ | ||
540 | 284 | w->isViewable () && \ | ||
541 | 285 | !(w->wmType () & ( CompWindowTypeDockMask | CompWindowTypeDesktopMask)) && \ | ||
542 | 286 | /* !( w->state & ( CompWindowStateSkipPagerMask | CompWindowStateShadedMask )) && \*/ | ||
543 | 287 | ScreenSaverScreen::get (screen)->optionGetWindowMatch ().evaluate (w); | ||
544 | 288 | } | ||
545 | 289 | |||
546 | 290 | // Initialize window transformation matrices and vertices | ||
547 | 291 | void WindowFlyingWindows::initWindow () | ||
548 | 292 | { | ||
549 | 293 | active = isActiveWin (); | ||
550 | 294 | |||
551 | 295 | if (active) | ||
552 | 296 | { | ||
553 | 297 | float x = WIN_X (this->w); | ||
554 | 298 | float y = WIN_Y (this->w); | ||
555 | 299 | float w = WIN_W (this->w); | ||
556 | 300 | float h = WIN_H (this->w); | ||
557 | 301 | |||
558 | 302 | transform = transformRot = transformTrans = Matrix::identity; | ||
559 | 303 | centerTrans = centerTransInv = Matrix::identity; | ||
560 | 304 | |||
561 | 305 | centerTrans.scale (1.0, 1.0, 1.0 / screen->width ()); | ||
562 | 306 | centerTrans.translate (x + w/2.0, y + h/2.0, 0.0); | ||
563 | 307 | centerTransInv.translate (-(x + w / 2.0), -(y + h / 2.0), 0.0); | ||
564 | 308 | centerTransInv.scale (1.0f, 1.0f, 1.0f * screen->width ()); | ||
565 | 309 | |||
566 | 310 | recalcVertices (); | ||
567 | 311 | speed = speedrot = Vector::null; | ||
568 | 312 | } | ||
569 | 313 | else | ||
570 | 314 | opacityOld = opacity; | ||
571 | 315 | } | ||
572 | 316 | |||
573 | 317 | // Update window vertices | ||
574 | 318 | void WindowFlyingWindows::recalcVertices () | ||
575 | 319 | { | ||
576 | 320 | float x = WIN_X (this->w); | ||
577 | 321 | float y = WIN_Y (this->w); | ||
578 | 322 | float w = WIN_W (this->w); | ||
579 | 323 | float h = WIN_H (this->w); | ||
580 | 324 | |||
581 | 325 | vertex[NO] = Point (x, y, 0.0); | ||
582 | 326 | vertex[NE] = Point (x + w, y, 0.0); | ||
583 | 327 | vertex[SO] = Point (x, y + h, 0.0); | ||
584 | 328 | vertex[SE] = Point (x + w, y + h, 0.0); | ||
585 | 329 | vertex[C] = Point (x + w/2.0, y + h/2.0, 0.0); | ||
586 | 330 | |||
587 | 331 | // Apply the window transformation and normalize | ||
588 | 332 | for (int i = 0; i < 5; ++i) | ||
589 | 333 | vertex[i] = (transform * vertex[i]).toScreenSpace (); | ||
590 | 334 | } | ||
591 | 335 | |||
592 | 336 | bool WindowFlyingWindows::glPaint (const GLWindowPaintAttrib &attrib, | ||
593 | 337 | const GLMatrix &transform, | ||
594 | 338 | const CompRegion ®ion, | ||
595 | 339 | unsigned int mask) | ||
596 | 340 | { | ||
597 | 341 | GLWindowPaintAttrib sAttrib (attrib); | ||
598 | 342 | Matrix wTransform; | ||
599 | 343 | |||
600 | 344 | if (!active) | ||
601 | 345 | { | ||
602 | 346 | SCREENSAVER_SCREEN (screen); | ||
603 | 347 | |||
604 | 348 | if (opacity && steps && !ss->mState.fadingOut) | ||
605 | 349 | { | ||
606 | 350 | if (opacity < steps) | ||
607 | 351 | opacity = 0; | ||
608 | 352 | else | ||
609 | 353 | opacity -= steps; | ||
610 | 354 | steps = 0; | ||
611 | 355 | } | ||
612 | 356 | |||
613 | 357 | sAttrib.opacity = opacity; | ||
614 | 358 | wTransform = transform; | ||
615 | 359 | } | ||
616 | 360 | else | ||
617 | 361 | { | ||
618 | 362 | SCREENSAVER_SCREEN (screen); | ||
619 | 363 | wTransform = transform * ss->mCameraMat * this->transform; | ||
620 | 364 | mask |= PAINT_WINDOW_TRANSFORMED_MASK; | ||
621 | 365 | |||
622 | 366 | if (w->state () & CompWindowStateSkipPagerMask) | ||
623 | 367 | return WindowEffect::glPaint (sAttrib, wTransform.m, region, mask); | ||
624 | 368 | } | ||
625 | 369 | |||
626 | 370 | if (w->alpha () || sAttrib.opacity != OPAQUE) | ||
627 | 371 | mask |= PAINT_WINDOW_TRANSLUCENT_MASK; | ||
628 | 372 | |||
629 | 373 | // from paint.cpp | ||
630 | 374 | if (mask & PAINT_WINDOW_OCCLUSION_DETECTION_MASK) | ||
631 | 375 | { | ||
632 | 376 | if (mask & PAINT_WINDOW_TRANSFORMED_MASK || | ||
633 | 377 | mask & PAINT_WINDOW_NO_CORE_INSTANCE_MASK || | ||
634 | 378 | mask & PAINT_WINDOW_TRANSLUCENT_MASK || | ||
635 | 379 | w->shaded ()) | ||
636 | 380 | return false; | ||
637 | 381 | |||
638 | 382 | return true; | ||
639 | 383 | } | ||
640 | 384 | |||
641 | 385 | GLWindowPaintAttrib fragment (sAttrib); | ||
642 | 386 | |||
643 | 387 | glPushMatrix (); | ||
644 | 388 | glLoadMatrixf (wTransform.m); | ||
645 | 389 | bool status = sw->gWindow->glDraw (wTransform.m, fragment, region, mask); | ||
646 | 390 | glPopMatrix (); | ||
647 | 391 | |||
648 | 392 | return status; | ||
649 | 393 | } | ||
650 | 0 | 394 | ||
651 | === added file 'plugins/screensaver/src/flyingwindows.h' | |||
652 | --- plugins/screensaver/src/flyingwindows.h 1970-01-01 00:00:00 +0000 | |||
653 | +++ plugins/screensaver/src/flyingwindows.h 2013-07-24 16:13:49 +0000 | |||
654 | @@ -0,0 +1,94 @@ | |||
655 | 1 | #ifndef FLYINGWINDOWS_H | ||
656 | 2 | #define FLYINGWINDOWS_H | ||
657 | 3 | |||
658 | 4 | #include "screensaver.h" | ||
659 | 5 | |||
660 | 6 | class ScreenFlyingWindows : public ScreenEffect | ||
661 | 7 | { | ||
662 | 8 | public: | ||
663 | 9 | |||
664 | 10 | ScreenFlyingWindows () : ScreenEffect () {} | ||
665 | 11 | virtual ~ScreenFlyingWindows () {} | ||
666 | 12 | |||
667 | 13 | virtual void handleEvent (XEvent *event); | ||
668 | 14 | virtual bool enable (); | ||
669 | 15 | virtual void disable (); | ||
670 | 16 | virtual void preparePaint (int); | ||
671 | 17 | virtual void donePaint (); | ||
672 | 18 | virtual void glPaintTransformedOutput (const GLScreenPaintAttrib &, | ||
673 | 19 | const GLMatrix &, | ||
674 | 20 | const CompRegion &, | ||
675 | 21 | CompOutput *, | ||
676 | 22 | unsigned int ); | ||
677 | 23 | virtual bool glPaintOutput (const GLScreenPaintAttrib &, | ||
678 | 24 | const GLMatrix &, | ||
679 | 25 | const CompRegion &, | ||
680 | 26 | CompOutput *, | ||
681 | 27 | unsigned int ); | ||
682 | 28 | virtual void paint (CompOutput::ptrList &, | ||
683 | 29 | unsigned int ); | ||
684 | 30 | private: | ||
685 | 31 | void initWindow (CompWindow* _w); | ||
686 | 32 | void recalcVertices (CompWindow* _w); | ||
687 | 33 | void addForce (const Point& p1, | ||
688 | 34 | const Point& p2, | ||
689 | 35 | const Point& center, | ||
690 | 36 | Vector& resultante, | ||
691 | 37 | Vector& couple, | ||
692 | 38 | float w, | ||
693 | 39 | bool attract); | ||
694 | 40 | }; | ||
695 | 41 | |||
696 | 42 | class WindowFlyingWindows : public WindowEffect | ||
697 | 43 | { | ||
698 | 44 | friend class ScreenFlyingWindows; | ||
699 | 45 | |||
700 | 46 | public: | ||
701 | 47 | |||
702 | 48 | WindowFlyingWindows (CompWindow* w); | ||
703 | 49 | virtual ~WindowFlyingWindows () {} | ||
704 | 50 | void initWindow (); | ||
705 | 51 | virtual bool glPaint (const GLWindowPaintAttrib &, | ||
706 | 52 | const GLMatrix &, | ||
707 | 53 | const CompRegion &, | ||
708 | 54 | unsigned int ); | ||
709 | 55 | void recalcVertices (); | ||
710 | 56 | |||
711 | 57 | static WindowFlyingWindows& getInstance (CompWindow* w) { return (WindowFlyingWindows&)*ScreenSaverWindow::get (w)->mEffect; } | ||
712 | 58 | |||
713 | 59 | private: | ||
714 | 60 | |||
715 | 61 | bool isActiveWin (); | ||
716 | 62 | |||
717 | 63 | // isScreenSaverWin() | ||
718 | 64 | bool active; | ||
719 | 65 | |||
720 | 66 | // used for non-active window like the desktop | ||
721 | 67 | GLushort opacity; | ||
722 | 68 | GLushort opacityFadeOut; | ||
723 | 69 | GLushort opacityOld; | ||
724 | 70 | int steps; | ||
725 | 71 | |||
726 | 72 | // used for active window | ||
727 | 73 | // translate matrix | ||
728 | 74 | Matrix transformTrans; | ||
729 | 75 | |||
730 | 76 | // rotation matrix | ||
731 | 77 | Matrix centerTrans; | ||
732 | 78 | Matrix transformRot; | ||
733 | 79 | Matrix centerTransInv; | ||
734 | 80 | |||
735 | 81 | // precomputed transform matrix | ||
736 | 82 | Matrix transform; | ||
737 | 83 | |||
738 | 84 | Matrix transformFadeOut; | ||
739 | 85 | |||
740 | 86 | // 5 normalized vertices are stored, the four corners and the center | ||
741 | 87 | Point vertex[5]; | ||
742 | 88 | |||
743 | 89 | // normalized speed vectors | ||
744 | 90 | Vector speed; | ||
745 | 91 | Vector speedrot; | ||
746 | 92 | }; | ||
747 | 93 | |||
748 | 94 | #endif | ||
749 | 0 | 95 | ||
750 | === added file 'plugins/screensaver/src/matrix.cpp' | |||
751 | --- plugins/screensaver/src/matrix.cpp 1970-01-01 00:00:00 +0000 | |||
752 | +++ plugins/screensaver/src/matrix.cpp 2013-07-24 16:13:49 +0000 | |||
753 | @@ -0,0 +1,60 @@ | |||
754 | 1 | #include "screensaver.h" | ||
755 | 2 | |||
756 | 3 | static const float _identity[16] = | ||
757 | 4 | { | ||
758 | 5 | 1.0, 0.0, 0.0, 0.0, | ||
759 | 6 | 0.0, 1.0, 0.0, 0.0, | ||
760 | 7 | 0.0, 0.0, 1.0, 0.0, | ||
761 | 8 | 0.0, 0.0, 0.0, 1.0 | ||
762 | 9 | }; | ||
763 | 10 | |||
764 | 11 | const Matrix Matrix::identity = _identity; | ||
765 | 12 | |||
766 | 13 | Matrix operator* (const Matrix& lhs, const Matrix& rhs) | ||
767 | 14 | { | ||
768 | 15 | Matrix res; | ||
769 | 16 | res[0] = lhs[0] * rhs[0] + lhs[4] * rhs[1] + lhs[8] * rhs[2] + lhs[12] * rhs[3]; | ||
770 | 17 | res[1] = lhs[1] * rhs[0] + lhs[5] * rhs[1] + lhs[9] * rhs[2] + lhs[13] * rhs[3]; | ||
771 | 18 | res[2] = lhs[2] * rhs[0] + lhs[6] * rhs[1] + lhs[10] * rhs[2] + lhs[14] * rhs[3]; | ||
772 | 19 | res[3] = lhs[3] * rhs[0] + lhs[7] * rhs[1] + lhs[11] * rhs[2] + lhs[15] * rhs[3]; | ||
773 | 20 | res[4] = lhs[0] * rhs[4] + lhs[4] * rhs[5] + lhs[8] * rhs[6] + lhs[12] * rhs[7]; | ||
774 | 21 | res[5] = lhs[1] * rhs[4] + lhs[5] * rhs[5] + lhs[9] * rhs[6] + lhs[13] * rhs[7]; | ||
775 | 22 | res[6] = lhs[2] * rhs[4] + lhs[6] * rhs[5] + lhs[10] * rhs[6] + lhs[14] * rhs[7]; | ||
776 | 23 | res[7] = lhs[3] * rhs[4] + lhs[7] * rhs[5] + lhs[11] * rhs[6] + lhs[15] * rhs[7]; | ||
777 | 24 | res[8] = lhs[0] * rhs[8] + lhs[4] * rhs[9] + lhs[8] * rhs[10] + lhs[12] * rhs[11]; | ||
778 | 25 | res[9] = lhs[1] * rhs[8] + lhs[5] * rhs[9] + lhs[9] * rhs[10] + lhs[13] * rhs[11]; | ||
779 | 26 | res[10] = lhs[2] * rhs[8] + lhs[6] * rhs[9] + lhs[10] * rhs[10] + lhs[14] * rhs[11]; | ||
780 | 27 | res[11] = lhs[3] * rhs[8] + lhs[7] * rhs[9] + lhs[11] * rhs[10] + lhs[15] * rhs[11]; | ||
781 | 28 | res[12] = lhs[0] * rhs[12] + lhs[4] * rhs[13] + lhs[8] * rhs[14] + lhs[12] * rhs[15]; | ||
782 | 29 | res[13] = lhs[1] * rhs[12] + lhs[5] * rhs[13] + lhs[9] * rhs[14] + lhs[13] * rhs[15]; | ||
783 | 30 | res[14] = lhs[2] * rhs[12] + lhs[6] * rhs[13] + lhs[10] * rhs[14] + lhs[14] * rhs[15]; | ||
784 | 31 | res[15] = lhs[3] * rhs[12] + lhs[7] * rhs[13] + lhs[11] * rhs[14] + lhs[15] * rhs[15]; | ||
785 | 32 | |||
786 | 33 | return res; | ||
787 | 34 | } | ||
788 | 35 | |||
789 | 36 | Vector operator* (const Matrix& mat, const Vector& vect) | ||
790 | 37 | { | ||
791 | 38 | Vector res; | ||
792 | 39 | |||
793 | 40 | res[0] = mat[0] * vect[0] + mat[4] * vect[1] + mat[8] * vect[2] + mat[12]; | ||
794 | 41 | res[1] = mat[1] * vect[0] + mat[5] * vect[1] + mat[9] * vect[2] + mat[13]; | ||
795 | 42 | res[2] = mat[2] * vect[0] + mat[6] * vect[1] + mat[10] * vect[2] + mat[14]; | ||
796 | 43 | float w = mat[3] * vect[0] + mat[7] * vect[1] + mat[11] * vect[2] + mat[15]; | ||
797 | 44 | |||
798 | 45 | res[0] /= w; | ||
799 | 46 | res[1] /= w; | ||
800 | 47 | res[2] /= w; | ||
801 | 48 | |||
802 | 49 | return res; | ||
803 | 50 | } | ||
804 | 51 | |||
805 | 52 | Matrix interpolate (const Matrix& from, const Matrix& to, float position) | ||
806 | 53 | { | ||
807 | 54 | Matrix res; | ||
808 | 55 | |||
809 | 56 | for (int i = 0; i < 16; ++i) | ||
810 | 57 | res[i] = from[i] * (1 - position) + to[i] * position; | ||
811 | 58 | |||
812 | 59 | return res; | ||
813 | 60 | } | ||
814 | 0 | 61 | ||
815 | === added file 'plugins/screensaver/src/matrix.h' | |||
816 | --- plugins/screensaver/src/matrix.h 1970-01-01 00:00:00 +0000 | |||
817 | +++ plugins/screensaver/src/matrix.h 2013-07-24 16:13:49 +0000 | |||
818 | @@ -0,0 +1,69 @@ | |||
819 | 1 | #ifndef MATRIX_H | ||
820 | 2 | #define MATRIX_H | ||
821 | 3 | |||
822 | 4 | #include <core/core.h> | ||
823 | 5 | #include <opengl/opengl.h> | ||
824 | 6 | #include <cmath> | ||
825 | 7 | #include "vector.h" | ||
826 | 8 | |||
827 | 9 | class Matrix | ||
828 | 10 | { | ||
829 | 11 | public: | ||
830 | 12 | |||
831 | 13 | static const Matrix identity; | ||
832 | 14 | |||
833 | 15 | Matrix() | ||
834 | 16 | { | ||
835 | 17 | for (int i = 0; i < 16; ++i) | ||
836 | 18 | { | ||
837 | 19 | m[i] = 0; | ||
838 | 20 | } | ||
839 | 21 | } | ||
840 | 22 | |||
841 | 23 | Matrix (const GLMatrix &mat) { memcpy (m, mat.getMatrix (), sizeof(m)); } | ||
842 | 24 | Matrix (const Matrix& mat) { memcpy (m, mat.m, sizeof(m)); } | ||
843 | 25 | Matrix (const float* mat) { memcpy (m, mat, sizeof(m)); } | ||
844 | 26 | |||
845 | 27 | const float& operator[] (int i) const { return m[i]; } | ||
846 | 28 | float& operator[] (int i) { return m[i]; } | ||
847 | 29 | |||
848 | 30 | Matrix& operator*= (const Matrix& rhs) { Matrix res; *this = *this * rhs; return *this; } | ||
849 | 31 | friend Matrix operator* (const Matrix& lhs, const Matrix& rhs); | ||
850 | 32 | friend Vector operator* (const Matrix& mat, const Vector& vect); | ||
851 | 33 | |||
852 | 34 | friend Matrix interpolate (const Matrix& from, const Matrix& to, float position); | ||
853 | 35 | |||
854 | 36 | Matrix& rotate (float angle, float x, float y, float z) | ||
855 | 37 | { | ||
856 | 38 | GLMatrix t (m); | ||
857 | 39 | t.rotate (angle, x, y, z); | ||
858 | 40 | memcpy ((void *)m, (const void *) t.getMatrix (), sizeof (float) * 16); | ||
859 | 41 | return *this; | ||
860 | 42 | } | ||
861 | 43 | |||
862 | 44 | Matrix& rotate (float angle, const Vector& vect) { return rotate (angle, vect[x], vect[y], vect[z]); } | ||
863 | 45 | |||
864 | 46 | Matrix& scale (float x, float y, float z) | ||
865 | 47 | { | ||
866 | 48 | GLMatrix t (m); | ||
867 | 49 | t.scale (x, y, z); | ||
868 | 50 | memcpy ((void *)m, (const void *) t.getMatrix (), sizeof (float) * 16); | ||
869 | 51 | return *this; | ||
870 | 52 | } | ||
871 | 53 | |||
872 | 54 | Matrix& scale (const Vector& vect) { return scale (vect[x], vect[y], vect[z]); } | ||
873 | 55 | |||
874 | 56 | Matrix& translate (float x, float y, float z) | ||
875 | 57 | { | ||
876 | 58 | GLMatrix t (m); | ||
877 | 59 | t.translate (x, y, z); | ||
878 | 60 | memcpy ((void *)m, (const void *) t.getMatrix (), sizeof (float) * 16); | ||
879 | 61 | return *this; | ||
880 | 62 | } | ||
881 | 63 | |||
882 | 64 | Matrix& translate (const Vector& vect) { return translate (vect[x], vect[y], vect[z]); } | ||
883 | 65 | |||
884 | 66 | float m[16]; | ||
885 | 67 | }; | ||
886 | 68 | |||
887 | 69 | #endif | ||
888 | 0 | 70 | ||
889 | === added file 'plugins/screensaver/src/rotatingcube.cpp' | |||
890 | --- plugins/screensaver/src/rotatingcube.cpp 1970-01-01 00:00:00 +0000 | |||
891 | +++ plugins/screensaver/src/rotatingcube.cpp 2013-07-24 16:13:49 +0000 | |||
892 | @@ -0,0 +1,104 @@ | |||
893 | 1 | #include "rotatingcube.h" | ||
894 | 2 | |||
895 | 3 | bool ScreenRotatingCube::loadCubePlugin() | ||
896 | 4 | { | ||
897 | 5 | if (!CompPlugin::checkPluginABI ("cube", COMPIZ_CUBE_ABI)) | ||
898 | 6 | return false; | ||
899 | 7 | |||
900 | 8 | return true; | ||
901 | 9 | } | ||
902 | 10 | |||
903 | 11 | bool ScreenRotatingCube::enable () | ||
904 | 12 | { | ||
905 | 13 | if (!loadCubePlugin ()) | ||
906 | 14 | return false; | ||
907 | 15 | |||
908 | 16 | CubeScreen *cs = ss->cubeScreen; | ||
909 | 17 | |||
910 | 18 | ss->mZCamera = 0.0; | ||
911 | 19 | ss->mCubeRotX = 0.0; | ||
912 | 20 | ss->mCubeRotV = 0.0; | ||
913 | 21 | cs->rotationState (CubeScreen::RotationManual); | ||
914 | 22 | |||
915 | 23 | ss->cubeScreen->cubeGetRotationSetEnabled (ss, true); | ||
916 | 24 | |||
917 | 25 | return ScreenEffect::enable (); | ||
918 | 26 | } | ||
919 | 27 | |||
920 | 28 | void ScreenRotatingCube::disable () | ||
921 | 29 | { | ||
922 | 30 | ss->mZCameraFadeOut = ss->mZCamera; | ||
923 | 31 | ss->mCubeRotXFadeOut = ss->mCubeRotX; | ||
924 | 32 | ss->mCubeRotVFadeOut = ss->mCubeRotV; | ||
925 | 33 | |||
926 | 34 | ScreenEffect::disable (); | ||
927 | 35 | } | ||
928 | 36 | |||
929 | 37 | void ScreenRotatingCube::clean () | ||
930 | 38 | { | ||
931 | 39 | ss->cubeScreen->rotationState (CubeScreen::RotationNone); | ||
932 | 40 | } | ||
933 | 41 | |||
934 | 42 | void ScreenRotatingCube::cubeGetRotation (float& x, float& v, float &progress) | ||
935 | 43 | { | ||
936 | 44 | ScreenEffect::cubeGetRotation (x, v, progress); | ||
937 | 45 | |||
938 | 46 | x += ss->mCubeRotX; | ||
939 | 47 | v += ss->mCubeRotV; | ||
940 | 48 | progress = MAX (progress, ss->mCubeProgress); | ||
941 | 49 | } | ||
942 | 50 | |||
943 | 51 | void ScreenRotatingCube::preparePaint (int msSinceLastPaint) | ||
944 | 52 | { | ||
945 | 53 | ScreenEffect::preparePaint (msSinceLastPaint); | ||
946 | 54 | |||
947 | 55 | float rotX = ss->optionGetCubeRotationSpeed () / 100.0; | ||
948 | 56 | |||
949 | 57 | if (ss->mState.fadingIn) | ||
950 | 58 | { | ||
951 | 59 | rotX *= getProgress(); | ||
952 | 60 | ss->mZCamera = -ss->optionGetCubeZoom() * getProgress(); | ||
953 | 61 | ss->mCubeProgress = getProgress(); | ||
954 | 62 | } | ||
955 | 63 | else if (ss->mState.fadingOut) | ||
956 | 64 | { | ||
957 | 65 | ss->mZCamera = ss->mZCameraFadeOut * (1 - getProgress()); | ||
958 | 66 | ss->mCubeRotX = ss->mCubeRotXFadeOut * (1 - getProgress()); | ||
959 | 67 | ss->mCubeRotV = ss->mCubeRotVFadeOut * (1 - getProgress()); | ||
960 | 68 | ss->mCubeProgress = 1 - getProgress(); | ||
961 | 69 | } | ||
962 | 70 | |||
963 | 71 | if (!ss->mState.fadingOut) | ||
964 | 72 | { | ||
965 | 73 | float rotV = 0.0; | ||
966 | 74 | ss->mCubeRotX += rotX * msSinceLastPaint; | ||
967 | 75 | ss->mCubeRotV += rotV * msSinceLastPaint; | ||
968 | 76 | } | ||
969 | 77 | |||
970 | 78 | if (ss->mCubeRotX > 180.0) | ||
971 | 79 | ss->mCubeRotX -= 360.0; | ||
972 | 80 | |||
973 | 81 | if (ss->mCubeRotX < -180.0) | ||
974 | 82 | ss->mCubeRotX += 360.0; | ||
975 | 83 | } | ||
976 | 84 | |||
977 | 85 | void ScreenRotatingCube::donePaint() | ||
978 | 86 | { | ||
979 | 87 | ss->cScreen->damageScreen(); | ||
980 | 88 | ScreenEffect::donePaint(); | ||
981 | 89 | } | ||
982 | 90 | |||
983 | 91 | bool ScreenRotatingCube::glPaintOutput (const GLScreenPaintAttrib &attrib, | ||
984 | 92 | const GLMatrix &transform, | ||
985 | 93 | const CompRegion ®ion, | ||
986 | 94 | CompOutput *output, | ||
987 | 95 | unsigned int mask) | ||
988 | 96 | { | ||
989 | 97 | GLScreenPaintAttrib sA (attrib); | ||
990 | 98 | sA.zCamera += ss->mZCamera; | ||
991 | 99 | |||
992 | 100 | mask &= ~PAINT_SCREEN_REGION_MASK; | ||
993 | 101 | mask |= PAINT_SCREEN_TRANSFORMED_MASK; | ||
994 | 102 | |||
995 | 103 | return ScreenEffect::glPaintOutput (sA, transform, region, output, mask); | ||
996 | 104 | } | ||
997 | 0 | 105 | ||
998 | === added file 'plugins/screensaver/src/rotatingcube.h' | |||
999 | --- plugins/screensaver/src/rotatingcube.h 1970-01-01 00:00:00 +0000 | |||
1000 | +++ plugins/screensaver/src/rotatingcube.h 2013-07-24 16:13:49 +0000 | |||
1001 | @@ -0,0 +1,34 @@ | |||
1002 | 1 | #ifndef ROTATINGCUBE_H | ||
1003 | 2 | #define ROTATINGCUBE_H | ||
1004 | 3 | |||
1005 | 4 | #include "screensaver.h" | ||
1006 | 5 | |||
1007 | 6 | class ScreenRotatingCube : public ScreenEffect | ||
1008 | 7 | { | ||
1009 | 8 | public: | ||
1010 | 9 | |||
1011 | 10 | ScreenRotatingCube () : ScreenEffect () {} | ||
1012 | 11 | virtual ~ScreenRotatingCube () {} | ||
1013 | 12 | |||
1014 | 13 | virtual bool enable (); | ||
1015 | 14 | virtual void disable (); | ||
1016 | 15 | virtual void cubeGetRotation (float &x, | ||
1017 | 16 | float &v, | ||
1018 | 17 | float &progress); | ||
1019 | 18 | virtual void preparePaint (int msSinceLastPaint); | ||
1020 | 19 | virtual void donePaint (); | ||
1021 | 20 | virtual bool glPaintOutput (const GLScreenPaintAttrib &, | ||
1022 | 21 | const GLMatrix &, | ||
1023 | 22 | const CompRegion &, | ||
1024 | 23 | CompOutput *, | ||
1025 | 24 | unsigned int ); | ||
1026 | 25 | protected: | ||
1027 | 26 | |||
1028 | 27 | virtual void clean (); | ||
1029 | 28 | |||
1030 | 29 | private: | ||
1031 | 30 | |||
1032 | 31 | bool loadCubePlugin (); | ||
1033 | 32 | }; | ||
1034 | 33 | |||
1035 | 34 | #endif | ||
1036 | 0 | 35 | ||
1037 | === added file 'plugins/screensaver/src/screensaver.cpp' | |||
1038 | --- plugins/screensaver/src/screensaver.cpp 1970-01-01 00:00:00 +0000 | |||
1039 | +++ plugins/screensaver/src/screensaver.cpp 2013-07-24 16:13:49 +0000 | |||
1040 | @@ -0,0 +1,312 @@ | |||
1041 | 1 | /** | ||
1042 | 2 | * | ||
1043 | 3 | * Compiz screensaver plugin | ||
1044 | 4 | * | ||
1045 | 5 | * screensaver.cpp | ||
1046 | 6 | * | ||
1047 | 7 | * Copyright (c) 2007 Nicolas Viennot <nicolas@viennot.biz> | ||
1048 | 8 | * | ||
1049 | 9 | * This program is free software; you can redistribute it and/or | ||
1050 | 10 | * modify it under the terms of the GNU General Public License | ||
1051 | 11 | * as published by the Free Software Foundation; either version 2 | ||
1052 | 12 | * of the License, or (at your option) any later version. | ||
1053 | 13 | * | ||
1054 | 14 | * This program is distributed in the hope that it will be useful, | ||
1055 | 15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
1056 | 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
1057 | 17 | * GNU General Public License for more details. | ||
1058 | 18 | * | ||
1059 | 19 | **/ | ||
1060 | 20 | |||
1061 | 21 | #include <stdlib.h> | ||
1062 | 22 | #include <string.h> | ||
1063 | 23 | #include <math.h> | ||
1064 | 24 | |||
1065 | 25 | #include "screensaver.h" | ||
1066 | 26 | #include "rotatingcube.h" | ||
1067 | 27 | #include "flyingwindows.h" | ||
1068 | 28 | |||
1069 | 29 | COMPIZ_PLUGIN_20090315 (screensaver, ScreenSaverPluginVTable); | ||
1070 | 30 | |||
1071 | 31 | template <typename _ScreenEffect, typename _WindowEffect> | ||
1072 | 32 | static void screenSaverEffectInstance () | ||
1073 | 33 | { | ||
1074 | 34 | SCREENSAVER_SCREEN (screen); | ||
1075 | 35 | delete ss->mEffect; | ||
1076 | 36 | ss->mEffect = new _ScreenEffect (); | ||
1077 | 37 | |||
1078 | 38 | foreach (CompWindow *w, screen->windows ()) | ||
1079 | 39 | { | ||
1080 | 40 | SCREENSAVER_WINDOW (w); | ||
1081 | 41 | delete sw->mEffect; | ||
1082 | 42 | sw->mEffect = new _WindowEffect (w); | ||
1083 | 43 | } | ||
1084 | 44 | } | ||
1085 | 45 | |||
1086 | 46 | void | ||
1087 | 47 | ScreenSaverScreen::enableEffect () | ||
1088 | 48 | { | ||
1089 | 49 | enum ScreensaverOptions::Mode mode = (enum ScreensaverOptions::Mode) optionGetMode (); | ||
1090 | 50 | |||
1091 | 51 | if (mode == ModeFlyingWindows) | ||
1092 | 52 | screenSaverEffectInstance <ScreenFlyingWindows, WindowFlyingWindows> (); | ||
1093 | 53 | |||
1094 | 54 | if (mode == ScreensaverOptions::ModeRotatingCube) | ||
1095 | 55 | screenSaverEffectInstance <ScreenRotatingCube, WindowEffect> (); | ||
1096 | 56 | |||
1097 | 57 | mTime = 0; | ||
1098 | 58 | |||
1099 | 59 | if (!mEffect->enable ()) | ||
1100 | 60 | { | ||
1101 | 61 | fprintf (stderr, "Fail\n"); | ||
1102 | 62 | screenSaverEffectInstance <ScreenEffect, WindowEffect> (); | ||
1103 | 63 | return; | ||
1104 | 64 | } | ||
1105 | 65 | |||
1106 | 66 | mState.fadingOut = false; | ||
1107 | 67 | mState.fadingIn = true; | ||
1108 | 68 | mState.running = true; | ||
1109 | 69 | } | ||
1110 | 70 | |||
1111 | 71 | void | ||
1112 | 72 | ScreenSaverScreen::disableEffect () | ||
1113 | 73 | { | ||
1114 | 74 | mEffect->disable (); | ||
1115 | 75 | mTime = 0; | ||
1116 | 76 | |||
1117 | 77 | mState.fadingOut = true; | ||
1118 | 78 | mState.fadingIn = false; | ||
1119 | 79 | } | ||
1120 | 80 | |||
1121 | 81 | void | ||
1122 | 82 | ScreenSaverScreen::cleanEffect () | ||
1123 | 83 | { | ||
1124 | 84 | screenSaverEffectInstance <ScreenEffect, WindowEffect> (); | ||
1125 | 85 | } | ||
1126 | 86 | |||
1127 | 87 | void | ||
1128 | 88 | ScreenSaverScreen::setState (bool enable) | ||
1129 | 89 | { | ||
1130 | 90 | if (!mState.running && enable) | ||
1131 | 91 | mEffect->loadEffect = true; | ||
1132 | 92 | |||
1133 | 93 | if (mState.running && !enable && !mState.fadingOut) | ||
1134 | 94 | disableEffect (); | ||
1135 | 95 | } | ||
1136 | 96 | |||
1137 | 97 | bool | ||
1138 | 98 | ScreenSaverScreen::initiate (CompAction *action, | ||
1139 | 99 | CompAction::State state, | ||
1140 | 100 | CompOption::Vector options) | ||
1141 | 101 | { | ||
1142 | 102 | setState (!mState.running); | ||
1143 | 103 | return true; | ||
1144 | 104 | } | ||
1145 | 105 | |||
1146 | 106 | void | ||
1147 | 107 | ScreenSaverScreen::cubeGetRotation (float &x, float &v, float &progress) | ||
1148 | 108 | { | ||
1149 | 109 | mEffect->cubeGetRotation (x, v, progress); | ||
1150 | 110 | } | ||
1151 | 111 | |||
1152 | 112 | bool | ||
1153 | 113 | ScreenSaverWindow::glPaint (const GLWindowPaintAttrib &attrib, | ||
1154 | 114 | const GLMatrix &transform, | ||
1155 | 115 | const CompRegion ®ion, | ||
1156 | 116 | unsigned int mask) | ||
1157 | 117 | { | ||
1158 | 118 | return mEffect->glPaint (attrib, transform, region, mask); | ||
1159 | 119 | } | ||
1160 | 120 | |||
1161 | 121 | bool | ||
1162 | 122 | ScreenSaverScreen::glPaintOutput (const GLScreenPaintAttrib &attrib, | ||
1163 | 123 | const GLMatrix &transform, | ||
1164 | 124 | const CompRegion ®ion, | ||
1165 | 125 | CompOutput *output, | ||
1166 | 126 | unsigned int mask) | ||
1167 | 127 | { | ||
1168 | 128 | return mEffect->glPaintOutput (attrib, transform, region, output, mask); | ||
1169 | 129 | } | ||
1170 | 130 | |||
1171 | 131 | void | ||
1172 | 132 | ScreenSaverScreen::preparePaint (int ms) | ||
1173 | 133 | { | ||
1174 | 134 | mEffect->preparePaint (ms); | ||
1175 | 135 | } | ||
1176 | 136 | |||
1177 | 137 | void | ||
1178 | 138 | ScreenSaverScreen::glPaintTransformedOutput (const GLScreenPaintAttrib &attrib, | ||
1179 | 139 | const GLMatrix &transform, | ||
1180 | 140 | const CompRegion ®ion, | ||
1181 | 141 | CompOutput *output, | ||
1182 | 142 | unsigned int mask) | ||
1183 | 143 | { | ||
1184 | 144 | mEffect->glPaintTransformedOutput (attrib, transform, region, output, mask); | ||
1185 | 145 | } | ||
1186 | 146 | |||
1187 | 147 | void | ||
1188 | 148 | ScreenSaverScreen::donePaint () | ||
1189 | 149 | { | ||
1190 | 150 | mEffect->donePaint (); | ||
1191 | 151 | } | ||
1192 | 152 | |||
1193 | 153 | void | ||
1194 | 154 | ScreenSaverScreen::handleEvent (XEvent *event) | ||
1195 | 155 | { | ||
1196 | 156 | XScreenSaverNotifyEvent *xssEvent; | ||
1197 | 157 | |||
1198 | 158 | mEffect->handleEvent (event); | ||
1199 | 159 | |||
1200 | 160 | switch ((event->type & 0x7F) - mXSSContext.first_event) | ||
1201 | 161 | { | ||
1202 | 162 | case ScreenSaverNotify: | ||
1203 | 163 | xssEvent = (XScreenSaverNotifyEvent *) event; | ||
1204 | 164 | setState (xssEvent->state); | ||
1205 | 165 | break; | ||
1206 | 166 | |||
1207 | 167 | default: | ||
1208 | 168 | break; | ||
1209 | 169 | } | ||
1210 | 170 | |||
1211 | 171 | if (mEffect->loadEffect) | ||
1212 | 172 | { | ||
1213 | 173 | mEffect->loadEffect = false; | ||
1214 | 174 | enableEffect (); | ||
1215 | 175 | } | ||
1216 | 176 | else if (mEffect->cleanEffect) | ||
1217 | 177 | { | ||
1218 | 178 | mEffect->cleanEffect = false; | ||
1219 | 179 | cleanEffect (); | ||
1220 | 180 | } | ||
1221 | 181 | } | ||
1222 | 182 | |||
1223 | 183 | void | ||
1224 | 184 | ScreenSaverScreen::paint (CompOutput::ptrList &outputs, | ||
1225 | 185 | unsigned int mask) | ||
1226 | 186 | { | ||
1227 | 187 | mEffect->paint (outputs, mask); | ||
1228 | 188 | } | ||
1229 | 189 | |||
1230 | 190 | void | ||
1231 | 191 | ScreenSaverScreen::setXScreenSaver (bool enabled) | ||
1232 | 192 | { | ||
1233 | 193 | Window root = screen->root (); | ||
1234 | 194 | |||
1235 | 195 | if (enabled && !mXSSContext.init) | ||
1236 | 196 | { | ||
1237 | 197 | int dummy; | ||
1238 | 198 | long unsigned int mask = 0; | ||
1239 | 199 | XSetWindowAttributes attr; | ||
1240 | 200 | |||
1241 | 201 | if (!XScreenSaverQueryExtension (screen->dpy (), &mXSSContext.first_event, &dummy)) | ||
1242 | 202 | { | ||
1243 | 203 | compLogMessage ("screensaver", CompLogLevelWarn, | ||
1244 | 204 | "XScreenSaver Extension not available, cannot integrate with "\ | ||
1245 | 205 | "desktop settings!"); | ||
1246 | 206 | return; | ||
1247 | 207 | } | ||
1248 | 208 | |||
1249 | 209 | mXSSContext.init = true; | ||
1250 | 210 | |||
1251 | 211 | XGetScreenSaver (screen->dpy (), &mXSSContext.timeout, &mXSSContext.interval, | ||
1252 | 212 | &mXSSContext.prefer_blanking, &mXSSContext.allow_exposures); | ||
1253 | 213 | XSetScreenSaver (screen->dpy (), (int) (optionGetAfter () * 60.0), mXSSContext.interval, 0, AllowExposures); | ||
1254 | 214 | |||
1255 | 215 | XScreenSaverSetAttributes (screen->dpy (), root, -100, -100, 1, 1, 0, | ||
1256 | 216 | CopyFromParent, CopyFromParent, | ||
1257 | 217 | DefaultVisual (screen->dpy (), screen->screenNum ()), mask, &attr); | ||
1258 | 218 | |||
1259 | 219 | XScreenSaverSelectInput (screen->dpy (), root, ScreenSaverNotifyMask); | ||
1260 | 220 | |||
1261 | 221 | } | ||
1262 | 222 | if (!enabled && mXSSContext.init) | ||
1263 | 223 | { | ||
1264 | 224 | mXSSContext.init = false; | ||
1265 | 225 | |||
1266 | 226 | XSetScreenSaver (screen->dpy (), mXSSContext.timeout, mXSSContext.interval, | ||
1267 | 227 | mXSSContext.prefer_blanking, mXSSContext.allow_exposures); | ||
1268 | 228 | |||
1269 | 229 | XScreenSaverSelectInput (screen->dpy (), root, 0); | ||
1270 | 230 | XScreenSaverUnsetAttributes (screen->dpy (), root); | ||
1271 | 231 | } | ||
1272 | 232 | } | ||
1273 | 233 | |||
1274 | 234 | void | ||
1275 | 235 | ScreenSaverScreen::optionChanged (CompOption *opt, | ||
1276 | 236 | ScreensaverOptions::Options num) | ||
1277 | 237 | { | ||
1278 | 238 | setXScreenSaver (false); | ||
1279 | 239 | setXScreenSaver (optionGetStartAutomatically ()); | ||
1280 | 240 | } | ||
1281 | 241 | |||
1282 | 242 | ScreenSaverWindow::ScreenSaverWindow (CompWindow *w) : | ||
1283 | 243 | PluginClassHandler <ScreenSaverWindow, CompWindow> (w), | ||
1284 | 244 | mEffect (NULL), | ||
1285 | 245 | window (w), | ||
1286 | 246 | cWindow (CompositeWindow::get (w)), | ||
1287 | 247 | gWindow (GLWindow::get (w)) | ||
1288 | 248 | { | ||
1289 | 249 | ScreenSaverScreen *ss = ScreenSaverScreen::get (screen); | ||
1290 | 250 | |||
1291 | 251 | if(ss->mState.running && | ||
1292 | 252 | (enum ScreensaverOptions::Mode) ss->optionGetMode() == ScreensaverOptions::ModeFlyingWindows) | ||
1293 | 253 | mEffect = new WindowFlyingWindows (w); | ||
1294 | 254 | else | ||
1295 | 255 | mEffect = new WindowEffect (w); | ||
1296 | 256 | |||
1297 | 257 | GLWindowInterface::setHandler (gWindow); | ||
1298 | 258 | } | ||
1299 | 259 | |||
1300 | 260 | ScreenSaverWindow::~ScreenSaverWindow () | ||
1301 | 261 | { | ||
1302 | 262 | delete mEffect; | ||
1303 | 263 | } | ||
1304 | 264 | |||
1305 | 265 | ScreenSaverScreen::ScreenSaverScreen (CompScreen *s) : | ||
1306 | 266 | PluginClassHandler <ScreenSaverScreen, CompScreen> (s), | ||
1307 | 267 | cScreen (CompositeScreen::get (screen)), | ||
1308 | 268 | gScreen (GLScreen::get (screen)), | ||
1309 | 269 | cubeScreen (CubeScreen::get (screen)), | ||
1310 | 270 | mEffect (new ScreenEffect ()), | ||
1311 | 271 | mDesktopOpacity (OPAQUE) | ||
1312 | 272 | { | ||
1313 | 273 | ScreenInterface::setHandler (screen); | ||
1314 | 274 | GLScreenInterface::setHandler (gScreen); | ||
1315 | 275 | CompositeScreenInterface::setHandler (cScreen); | ||
1316 | 276 | CubeScreenInterface::setHandler (cubeScreen); | ||
1317 | 277 | |||
1318 | 278 | mState.running = false; | ||
1319 | 279 | mState.fadingOut = false; | ||
1320 | 280 | mState.fadingIn = false; | ||
1321 | 281 | |||
1322 | 282 | optionSetInitiateKeyInitiate (boost::bind (&ScreenSaverScreen::initiate, this, _1, _2, _3)); | ||
1323 | 283 | optionSetInitiateButtonInitiate (boost::bind (&ScreenSaverScreen::initiate, this, _1, _2, _3)); | ||
1324 | 284 | optionSetInitiateEdgeInitiate (boost::bind (&ScreenSaverScreen::initiate, this, _1, _2, _3)); | ||
1325 | 285 | |||
1326 | 286 | optionSetStartAutomaticallyNotify (boost::bind (&ScreenSaverScreen::optionChanged, this, _1, _2)); | ||
1327 | 287 | optionSetAfterNotify (boost::bind (&ScreenSaverScreen::optionChanged, this, _1, _2)); | ||
1328 | 288 | |||
1329 | 289 | mXSSContext.init = false; | ||
1330 | 290 | |||
1331 | 291 | mEffect->loadEffect = false; | ||
1332 | 292 | mEffect->cleanEffect = false; | ||
1333 | 293 | |||
1334 | 294 | setXScreenSaver (optionGetStartAutomatically ()); | ||
1335 | 295 | } | ||
1336 | 296 | |||
1337 | 297 | ScreenSaverScreen::~ScreenSaverScreen () | ||
1338 | 298 | { | ||
1339 | 299 | delete mEffect; | ||
1340 | 300 | } | ||
1341 | 301 | |||
1342 | 302 | bool | ||
1343 | 303 | ScreenSaverPluginVTable::init () | ||
1344 | 304 | { | ||
1345 | 305 | if (CompPlugin::checkPluginABI ("core", CORE_ABIVERSION) && | ||
1346 | 306 | CompPlugin::checkPluginABI ("composite", COMPIZ_COMPOSITE_ABI) && | ||
1347 | 307 | CompPlugin::checkPluginABI ("opengl", COMPIZ_OPENGL_ABI) && | ||
1348 | 308 | CompPlugin::checkPluginABI ("cube", COMPIZ_CUBE_ABI)) | ||
1349 | 309 | return true; | ||
1350 | 310 | |||
1351 | 311 | return false; | ||
1352 | 312 | } | ||
1353 | 0 | 313 | ||
1354 | === added file 'plugins/screensaver/src/screensaver.h' | |||
1355 | --- plugins/screensaver/src/screensaver.h 1970-01-01 00:00:00 +0000 | |||
1356 | +++ plugins/screensaver/src/screensaver.h 2013-07-24 16:13:49 +0000 | |||
1357 | @@ -0,0 +1,258 @@ | |||
1358 | 1 | #ifndef SCREENSAVER_INTERNAL_H | ||
1359 | 2 | #define SCREENSAVER_INTERNAL_H | ||
1360 | 3 | |||
1361 | 4 | #include <core/core.h> | ||
1362 | 5 | #include <composite/composite.h> | ||
1363 | 6 | #include <opengl/opengl.h> | ||
1364 | 7 | #include <cube/cube.h> | ||
1365 | 8 | |||
1366 | 9 | /* libxss-dev is needed, on Ubuntu: sudo apt-get install libxss-dev */ | ||
1367 | 10 | #include <X11/extensions/scrnsaver.h> | ||
1368 | 11 | |||
1369 | 12 | #include "screensaver_options.h" | ||
1370 | 13 | #include "matrix.h" | ||
1371 | 14 | #include "vector.h" | ||
1372 | 15 | |||
1373 | 16 | #define WIN_X(w) ((w)->x () - (w)->input ().left) | ||
1374 | 17 | #define WIN_Y(w) ((w)->y () - (w)->input ().top) | ||
1375 | 18 | #define WIN_W(w) ((w)->width () + (w)->input ().left + (w)->input ().right) | ||
1376 | 19 | #define WIN_H(w) ((w)->height () + (w)->input ().top + (w)->input ().bottom) | ||
1377 | 20 | |||
1378 | 21 | extern int displayPrivateIndex; | ||
1379 | 22 | |||
1380 | 23 | class ScreenSaverScreen; | ||
1381 | 24 | class ScreenSaverWindow; | ||
1382 | 25 | |||
1383 | 26 | class ScreenWrapper | ||
1384 | 27 | { | ||
1385 | 28 | public: | ||
1386 | 29 | |||
1387 | 30 | ScreenWrapper (); | ||
1388 | 31 | ~ScreenWrapper () {} | ||
1389 | 32 | |||
1390 | 33 | virtual void cubeGetRotation (float& x, float& v, float &progress); | ||
1391 | 34 | virtual void handleEvent (XEvent *); | ||
1392 | 35 | virtual void preparePaint (int); | ||
1393 | 36 | virtual void donePaint (); | ||
1394 | 37 | virtual void glPaintTransformedOutput (const GLScreenPaintAttrib &, | ||
1395 | 38 | const GLMatrix &, | ||
1396 | 39 | const CompRegion &, | ||
1397 | 40 | CompOutput *, | ||
1398 | 41 | unsigned int ); | ||
1399 | 42 | virtual bool glPaintOutput (const GLScreenPaintAttrib &, | ||
1400 | 43 | const GLMatrix &, | ||
1401 | 44 | const CompRegion &, | ||
1402 | 45 | CompOutput *, | ||
1403 | 46 | unsigned int ); | ||
1404 | 47 | virtual void paint (CompOutput::ptrList &, | ||
1405 | 48 | unsigned int ); | ||
1406 | 49 | |||
1407 | 50 | protected: | ||
1408 | 51 | |||
1409 | 52 | CompScreen* s; | ||
1410 | 53 | ScreenSaverScreen* ss; | ||
1411 | 54 | }; | ||
1412 | 55 | |||
1413 | 56 | class WindowWrapper | ||
1414 | 57 | { | ||
1415 | 58 | public: | ||
1416 | 59 | |||
1417 | 60 | WindowWrapper (CompWindow* w); | ||
1418 | 61 | virtual ~WindowWrapper () {} | ||
1419 | 62 | virtual bool glPaint (const GLWindowPaintAttrib &, | ||
1420 | 63 | const GLMatrix &, | ||
1421 | 64 | const CompRegion &, | ||
1422 | 65 | unsigned int ); | ||
1423 | 66 | protected: | ||
1424 | 67 | |||
1425 | 68 | CompWindow* w; | ||
1426 | 69 | ScreenSaverWindow* sw; | ||
1427 | 70 | }; | ||
1428 | 71 | |||
1429 | 72 | class ScreenEffect : public ScreenWrapper | ||
1430 | 73 | { | ||
1431 | 74 | public: | ||
1432 | 75 | |||
1433 | 76 | ScreenEffect() : ScreenWrapper(), progress (0) {} | ||
1434 | 77 | virtual ~ScreenEffect() {} | ||
1435 | 78 | float getProgress() { return progress; } | ||
1436 | 79 | virtual void handleEvent (XEvent *event); | ||
1437 | 80 | |||
1438 | 81 | virtual bool enable (); | ||
1439 | 82 | virtual void disable () {} | ||
1440 | 83 | virtual void preparePaint (int msSinceLastPaint); | ||
1441 | 84 | virtual void cubeGetRotation (float &, float &, float &); // TODO: get rid of this! | ||
1442 | 85 | |||
1443 | 86 | bool cleanEffect; | ||
1444 | 87 | bool loadEffect; | ||
1445 | 88 | |||
1446 | 89 | protected: | ||
1447 | 90 | |||
1448 | 91 | virtual void clean () {} | ||
1449 | 92 | |||
1450 | 93 | private: | ||
1451 | 94 | |||
1452 | 95 | float progress; | ||
1453 | 96 | }; | ||
1454 | 97 | |||
1455 | 98 | class WindowEffect : public WindowWrapper | ||
1456 | 99 | { | ||
1457 | 100 | public: | ||
1458 | 101 | |||
1459 | 102 | WindowEffect (CompWindow* w) : WindowWrapper (w) {} | ||
1460 | 103 | virtual ~WindowEffect () {} | ||
1461 | 104 | }; | ||
1462 | 105 | |||
1463 | 106 | class ScreenSaver | ||
1464 | 107 | { | ||
1465 | 108 | public: | ||
1466 | 109 | |||
1467 | 110 | class State | ||
1468 | 111 | { | ||
1469 | 112 | public: | ||
1470 | 113 | // when the screensaver is enabled, running and fadingIn are set to true | ||
1471 | 114 | // then, after fadingInDuration, fadingIn is set to false | ||
1472 | 115 | // when the screensaver is requested to stop, fadingOut is set to true | ||
1473 | 116 | // after fadingOutDuration, running is set to false | ||
1474 | 117 | bool running; | ||
1475 | 118 | bool fadingOut; | ||
1476 | 119 | bool fadingIn; | ||
1477 | 120 | }; | ||
1478 | 121 | |||
1479 | 122 | class XSSContext | ||
1480 | 123 | { | ||
1481 | 124 | public: | ||
1482 | 125 | |||
1483 | 126 | int timeout; | ||
1484 | 127 | int interval; | ||
1485 | 128 | int prefer_blanking; | ||
1486 | 129 | int allow_exposures; | ||
1487 | 130 | int first_event; | ||
1488 | 131 | bool init; | ||
1489 | 132 | }; | ||
1490 | 133 | }; | ||
1491 | 134 | |||
1492 | 135 | class ScreenSaverScreen : | ||
1493 | 136 | public PluginClassHandler <ScreenSaverScreen, CompScreen>, | ||
1494 | 137 | public ScreenInterface, | ||
1495 | 138 | public CompositeScreenInterface, | ||
1496 | 139 | public GLScreenInterface, | ||
1497 | 140 | public CubeScreenInterface, | ||
1498 | 141 | public ScreensaverOptions | ||
1499 | 142 | { | ||
1500 | 143 | public: | ||
1501 | 144 | |||
1502 | 145 | ScreenSaverScreen (CompScreen *s); | ||
1503 | 146 | ~ScreenSaverScreen (); | ||
1504 | 147 | |||
1505 | 148 | public: | ||
1506 | 149 | |||
1507 | 150 | CompositeScreen *cScreen; | ||
1508 | 151 | GLScreen *gScreen; | ||
1509 | 152 | CubeScreen *cubeScreen; | ||
1510 | 153 | |||
1511 | 154 | ScreenSaver::State mState; | ||
1512 | 155 | ScreenSaver::XSSContext mXSSContext; | ||
1513 | 156 | |||
1514 | 157 | ScreenEffect *mEffect; | ||
1515 | 158 | |||
1516 | 159 | void | ||
1517 | 160 | cubeGetRotation (float &x, | ||
1518 | 161 | float &v, | ||
1519 | 162 | float &progress); | ||
1520 | 163 | |||
1521 | 164 | void | ||
1522 | 165 | handleEvent (XEvent *); | ||
1523 | 166 | |||
1524 | 167 | void | ||
1525 | 168 | preparePaint (int); | ||
1526 | 169 | |||
1527 | 170 | void | ||
1528 | 171 | donePaint (); | ||
1529 | 172 | |||
1530 | 173 | void | ||
1531 | 174 | glPaintTransformedOutput (const GLScreenPaintAttrib &, | ||
1532 | 175 | const GLMatrix &, | ||
1533 | 176 | const CompRegion &, | ||
1534 | 177 | CompOutput *, | ||
1535 | 178 | unsigned int ); | ||
1536 | 179 | |||
1537 | 180 | bool glPaintOutput (const GLScreenPaintAttrib &, | ||
1538 | 181 | const GLMatrix &, | ||
1539 | 182 | const CompRegion &, | ||
1540 | 183 | CompOutput *, | ||
1541 | 184 | unsigned int ); | ||
1542 | 185 | |||
1543 | 186 | void | ||
1544 | 187 | paint (CompOutput::ptrList &outputs, | ||
1545 | 188 | unsigned int mask); | ||
1546 | 189 | |||
1547 | 190 | void enableEffect (); | ||
1548 | 191 | |||
1549 | 192 | void disableEffect (); | ||
1550 | 193 | |||
1551 | 194 | void cleanEffect (); | ||
1552 | 195 | |||
1553 | 196 | void setState (bool); | ||
1554 | 197 | |||
1555 | 198 | bool initiate (CompAction *, CompAction::State, CompOption::Vector); | ||
1556 | 199 | |||
1557 | 200 | void setXScreenSaver (bool); | ||
1558 | 201 | void optionChanged (CompOption *, ScreensaverOptions::Options); | ||
1559 | 202 | |||
1560 | 203 | int mTime; | ||
1561 | 204 | float mCubeRotX; | ||
1562 | 205 | float mCubeRotV; | ||
1563 | 206 | float mCubeProgress; | ||
1564 | 207 | float mZCamera; | ||
1565 | 208 | |||
1566 | 209 | float mCubeRotXFadeOut; | ||
1567 | 210 | float mCubeRotVFadeOut; | ||
1568 | 211 | float mZCameraFadeOut; | ||
1569 | 212 | |||
1570 | 213 | Point mScreenCenter; | ||
1571 | 214 | Matrix mCamera; | ||
1572 | 215 | Matrix mCameraMat; | ||
1573 | 216 | |||
1574 | 217 | float mAngleCam; | ||
1575 | 218 | GLushort mDesktopOpacity; | ||
1576 | 219 | }; | ||
1577 | 220 | |||
1578 | 221 | class ScreenSaverWindow : | ||
1579 | 222 | public PluginClassHandler <ScreenSaverWindow, CompWindow>, | ||
1580 | 223 | public GLWindowInterface | ||
1581 | 224 | { | ||
1582 | 225 | public: | ||
1583 | 226 | |||
1584 | 227 | ScreenSaverWindow (CompWindow *w); | ||
1585 | 228 | ~ScreenSaverWindow (); | ||
1586 | 229 | |||
1587 | 230 | WindowEffect *mEffect; | ||
1588 | 231 | |||
1589 | 232 | bool | ||
1590 | 233 | glPaint (const GLWindowPaintAttrib &, | ||
1591 | 234 | const GLMatrix &, | ||
1592 | 235 | const CompRegion &, | ||
1593 | 236 | unsigned int ); | ||
1594 | 237 | |||
1595 | 238 | CompWindow *window; | ||
1596 | 239 | CompositeWindow *cWindow; | ||
1597 | 240 | GLWindow *gWindow; | ||
1598 | 241 | |||
1599 | 242 | }; | ||
1600 | 243 | |||
1601 | 244 | #define SCREENSAVER_SCREEN(s) \ | ||
1602 | 245 | ScreenSaverScreen *ss = ScreenSaverScreen::get (s); | ||
1603 | 246 | |||
1604 | 247 | #define SCREENSAVER_WINDOW(w) \ | ||
1605 | 248 | ScreenSaverWindow *sw = ScreenSaverWindow::get (w); | ||
1606 | 249 | |||
1607 | 250 | class ScreenSaverPluginVTable : | ||
1608 | 251 | public CompPlugin::VTableForScreenAndWindow <ScreenSaverScreen, ScreenSaverWindow> | ||
1609 | 252 | { | ||
1610 | 253 | public: | ||
1611 | 254 | |||
1612 | 255 | bool init (); | ||
1613 | 256 | }; | ||
1614 | 257 | |||
1615 | 258 | #endif | ||
1616 | 0 | 259 | ||
1617 | === added file 'plugins/screensaver/src/vector.cpp' | |||
1618 | --- plugins/screensaver/src/vector.cpp 1970-01-01 00:00:00 +0000 | |||
1619 | +++ plugins/screensaver/src/vector.cpp 2013-07-24 16:13:49 +0000 | |||
1620 | @@ -0,0 +1,14 @@ | |||
1621 | 1 | #include "vector.h" | ||
1622 | 2 | |||
1623 | 3 | const Vector Vector::null (0.0, 0.0, 0.0); | ||
1624 | 4 | |||
1625 | 5 | Vector operator^ (const Vector& lhs, const Vector& rhs) | ||
1626 | 6 | { | ||
1627 | 7 | Vector res; | ||
1628 | 8 | |||
1629 | 9 | res[0] = lhs[1] * rhs[2] - lhs[2] * rhs[1]; | ||
1630 | 10 | res[1] = lhs[2] * rhs[0] - lhs[0] * rhs[2]; | ||
1631 | 11 | res[2] = lhs[0] * rhs[1] - lhs[1] * rhs[0]; | ||
1632 | 12 | |||
1633 | 13 | return res; | ||
1634 | 14 | } | ||
1635 | 0 | 15 | ||
1636 | === added file 'plugins/screensaver/src/vector.h' | |||
1637 | --- plugins/screensaver/src/vector.h 1970-01-01 00:00:00 +0000 | |||
1638 | +++ plugins/screensaver/src/vector.h 2013-07-24 16:13:49 +0000 | |||
1639 | @@ -0,0 +1,164 @@ | |||
1640 | 1 | #ifndef VECTOR_H | ||
1641 | 2 | #define VECTOR_H | ||
1642 | 3 | |||
1643 | 4 | #include <core/core.h> | ||
1644 | 5 | #include <opengl/opengl.h> | ||
1645 | 6 | #include <cmath> | ||
1646 | 7 | |||
1647 | 8 | typedef enum | ||
1648 | 9 | { | ||
1649 | 10 | x, | ||
1650 | 11 | y, | ||
1651 | 12 | z | ||
1652 | 13 | } VectorCoordsEnum; | ||
1653 | 14 | |||
1654 | 15 | class Vector | ||
1655 | 16 | { | ||
1656 | 17 | public: | ||
1657 | 18 | static const Vector null; | ||
1658 | 19 | |||
1659 | 20 | Vector () | ||
1660 | 21 | { | ||
1661 | 22 | for (int i = 0; i < 3; ++i) | ||
1662 | 23 | v[i] = 0; | ||
1663 | 24 | } | ||
1664 | 25 | |||
1665 | 26 | Vector (float x, float y, float z) { v[0] = x; v[1] = y; v[2] = z; } | ||
1666 | 27 | Vector (const float* vect) { v[0] = vect[0]; v[1] = vect[1]; v[2] = vect[2]; } | ||
1667 | 28 | Vector (const Vector& vect) { v[0] = vect[0]; v[1] = vect[1]; v[2] = vect[2]; } | ||
1668 | 29 | |||
1669 | 30 | float norm () { return sqrt ((*this) * (*this)); } | ||
1670 | 31 | |||
1671 | 32 | Vector& normalize () | ||
1672 | 33 | { | ||
1673 | 34 | float n = norm (); | ||
1674 | 35 | |||
1675 | 36 | if (n == 0.0) | ||
1676 | 37 | v[x] = v[y] = v[z] = 1.0; | ||
1677 | 38 | else | ||
1678 | 39 | *this /= n; | ||
1679 | 40 | |||
1680 | 41 | return *this; | ||
1681 | 42 | } | ||
1682 | 43 | |||
1683 | 44 | Vector toScreenSpace () const | ||
1684 | 45 | { | ||
1685 | 46 | Vector res; | ||
1686 | 47 | res[0] = v[0] / screen->width () - 0.5; | ||
1687 | 48 | res[1] = 0.5 - v[1] / screen->height (); | ||
1688 | 49 | res[2] = v[2]; | ||
1689 | 50 | return res; | ||
1690 | 51 | } | ||
1691 | 52 | |||
1692 | 53 | Vector toCoordsSpace () const | ||
1693 | 54 | { | ||
1694 | 55 | Vector res; | ||
1695 | 56 | res[0] = (v[0] + 0.5) * screen->width (); | ||
1696 | 57 | res[1] = (0.5 - v[1]) * screen->height (); | ||
1697 | 58 | res[2] = v[2]; | ||
1698 | 59 | return res; | ||
1699 | 60 | } | ||
1700 | 61 | |||
1701 | 62 | float& operator[] (int i) { return v[i]; } | ||
1702 | 63 | const float& operator[] (int i) const { return v[i]; } | ||
1703 | 64 | float& operator[] (VectorCoordsEnum c) { return v[(int)c]; } | ||
1704 | 65 | const float& operator[] (VectorCoordsEnum c) const { return v[(int)c]; } | ||
1705 | 66 | |||
1706 | 67 | Vector& operator+= (const Vector& rhs) | ||
1707 | 68 | { | ||
1708 | 69 | v[0] += rhs[0]; | ||
1709 | 70 | v[1] += rhs[1]; | ||
1710 | 71 | v[2] += rhs[2]; | ||
1711 | 72 | return *this; | ||
1712 | 73 | } | ||
1713 | 74 | |||
1714 | 75 | friend Vector operator+ (const Vector& lhs, const Vector& rhs) | ||
1715 | 76 | { | ||
1716 | 77 | Vector res; | ||
1717 | 78 | res[0] = lhs[0] + rhs[0]; | ||
1718 | 79 | res[1] = lhs[1] + rhs[1]; | ||
1719 | 80 | res[2] = lhs[2] + rhs[2]; | ||
1720 | 81 | return res; | ||
1721 | 82 | } | ||
1722 | 83 | |||
1723 | 84 | Vector& operator-= (const Vector& rhs) | ||
1724 | 85 | { | ||
1725 | 86 | v[0] -= rhs[0]; | ||
1726 | 87 | v[1] -= rhs[1]; | ||
1727 | 88 | v[2] -= rhs[2]; | ||
1728 | 89 | return *this; | ||
1729 | 90 | } | ||
1730 | 91 | |||
1731 | 92 | friend Vector operator- (const Vector& lhs, const Vector& rhs) | ||
1732 | 93 | { | ||
1733 | 94 | Vector res; | ||
1734 | 95 | res[0] = lhs[0] - rhs[0]; | ||
1735 | 96 | res[1] = lhs[1] - rhs[1]; | ||
1736 | 97 | res[2] = lhs[2] - rhs[2]; | ||
1737 | 98 | return res; | ||
1738 | 99 | } | ||
1739 | 100 | |||
1740 | 101 | friend Vector operator- (const Vector& vect) | ||
1741 | 102 | { | ||
1742 | 103 | Vector res; | ||
1743 | 104 | res[0] = -vect[0]; | ||
1744 | 105 | res[1] = -vect[1]; | ||
1745 | 106 | res[2] = -vect[2]; | ||
1746 | 107 | return res; | ||
1747 | 108 | } | ||
1748 | 109 | |||
1749 | 110 | Vector& operator*= (const float k) | ||
1750 | 111 | { | ||
1751 | 112 | v[0] *= k; | ||
1752 | 113 | v[1] *= k; | ||
1753 | 114 | v[2] *= k; | ||
1754 | 115 | return *this; | ||
1755 | 116 | } | ||
1756 | 117 | |||
1757 | 118 | friend float operator* (const Vector& lhs, const Vector& rhs) | ||
1758 | 119 | { | ||
1759 | 120 | return lhs[0] * rhs[0] + lhs[1] * rhs[1] + lhs[2] * rhs[2]; | ||
1760 | 121 | } | ||
1761 | 122 | |||
1762 | 123 | friend Vector operator* (const float k, const Vector& vect) | ||
1763 | 124 | { | ||
1764 | 125 | Vector res; | ||
1765 | 126 | res[0] = k * vect[0]; | ||
1766 | 127 | res[1] = k * vect[1]; | ||
1767 | 128 | res[2] = k * vect[2]; | ||
1768 | 129 | return res; | ||
1769 | 130 | } | ||
1770 | 131 | |||
1771 | 132 | friend Vector operator* (const Vector& v, const float k) { return k*v; } | ||
1772 | 133 | |||
1773 | 134 | Vector& operator/= (const float k) | ||
1774 | 135 | { | ||
1775 | 136 | v[0] /= k; | ||
1776 | 137 | v[1] /= k; | ||
1777 | 138 | v[2] /= k; | ||
1778 | 139 | return *this; | ||
1779 | 140 | } | ||
1780 | 141 | |||
1781 | 142 | friend Vector operator/ (const Vector& vect, const float k) | ||
1782 | 143 | { | ||
1783 | 144 | Vector res; | ||
1784 | 145 | res[0] = vect[0] / k; | ||
1785 | 146 | res[1] = vect[1] / k; | ||
1786 | 147 | res[2] = vect[2] / k; | ||
1787 | 148 | return res; | ||
1788 | 149 | } | ||
1789 | 150 | |||
1790 | 151 | Vector& operator^= (const Vector& vect) | ||
1791 | 152 | { | ||
1792 | 153 | *this = *this ^ vect; | ||
1793 | 154 | return *this; | ||
1794 | 155 | } | ||
1795 | 156 | |||
1796 | 157 | friend Vector operator^ (const Vector& lhs, const Vector& rhs); | ||
1797 | 158 | |||
1798 | 159 | float v[3]; | ||
1799 | 160 | }; | ||
1800 | 161 | |||
1801 | 162 | typedef Vector Point; | ||
1802 | 163 | |||
1803 | 164 | #endif | ||
1804 | 0 | 165 | ||
1805 | === added file 'plugins/screensaver/src/wrapper.cpp' | |||
1806 | --- plugins/screensaver/src/wrapper.cpp 1970-01-01 00:00:00 +0000 | |||
1807 | +++ plugins/screensaver/src/wrapper.cpp 2013-07-24 16:13:49 +0000 | |||
1808 | @@ -0,0 +1,67 @@ | |||
1809 | 1 | #include "screensaver.h" | ||
1810 | 2 | |||
1811 | 3 | void ScreenWrapper::handleEvent (XEvent *event) | ||
1812 | 4 | { | ||
1813 | 5 | screen->handleEvent (event); | ||
1814 | 6 | } | ||
1815 | 7 | |||
1816 | 8 | ScreenWrapper::ScreenWrapper () | ||
1817 | 9 | { | ||
1818 | 10 | SCREENSAVER_SCREEN (screen); | ||
1819 | 11 | this->s = screen; | ||
1820 | 12 | this->ss = ss; | ||
1821 | 13 | } | ||
1822 | 14 | |||
1823 | 15 | void ScreenWrapper::cubeGetRotation (float& x, float& v, float &progress) | ||
1824 | 16 | { | ||
1825 | 17 | ss->cubeScreen->cubeGetRotation (x, v, progress); | ||
1826 | 18 | } | ||
1827 | 19 | |||
1828 | 20 | void ScreenWrapper::preparePaint (int msSinceLastPaint ) | ||
1829 | 21 | { | ||
1830 | 22 | ss->cScreen->preparePaint (msSinceLastPaint); | ||
1831 | 23 | } | ||
1832 | 24 | |||
1833 | 25 | void ScreenWrapper::donePaint () | ||
1834 | 26 | { | ||
1835 | 27 | ss->cScreen->donePaint (); | ||
1836 | 28 | } | ||
1837 | 29 | |||
1838 | 30 | void ScreenWrapper::glPaintTransformedOutput (const GLScreenPaintAttrib &attrib, | ||
1839 | 31 | const GLMatrix &transform, | ||
1840 | 32 | const CompRegion ®ion, | ||
1841 | 33 | CompOutput *output, | ||
1842 | 34 | unsigned int mask) | ||
1843 | 35 | { | ||
1844 | 36 | ss->gScreen->glPaintTransformedOutput (attrib, transform, region, output, mask); | ||
1845 | 37 | } | ||
1846 | 38 | |||
1847 | 39 | bool ScreenWrapper::glPaintOutput (const GLScreenPaintAttrib &attrib, | ||
1848 | 40 | const GLMatrix &transform, | ||
1849 | 41 | const CompRegion ®ion, | ||
1850 | 42 | CompOutput *output, | ||
1851 | 43 | unsigned int mask) | ||
1852 | 44 | { | ||
1853 | 45 | return ss->gScreen->glPaintOutput (attrib, transform, region, output, mask); | ||
1854 | 46 | } | ||
1855 | 47 | |||
1856 | 48 | void ScreenWrapper::paint (CompOutput::ptrList &outputs, | ||
1857 | 49 | unsigned int mask) | ||
1858 | 50 | { | ||
1859 | 51 | ss->cScreen->paint (outputs, mask); | ||
1860 | 52 | } | ||
1861 | 53 | |||
1862 | 54 | WindowWrapper::WindowWrapper (CompWindow* w) | ||
1863 | 55 | { | ||
1864 | 56 | SCREENSAVER_WINDOW (w); | ||
1865 | 57 | this->w = w; | ||
1866 | 58 | this->sw = sw; | ||
1867 | 59 | } | ||
1868 | 60 | |||
1869 | 61 | bool WindowWrapper::glPaint (const GLWindowPaintAttrib &attrib, | ||
1870 | 62 | const GLMatrix &transform, | ||
1871 | 63 | const CompRegion ®ion, | ||
1872 | 64 | unsigned int mask) | ||
1873 | 65 | { | ||
1874 | 66 | return sw->gWindow->glPaint (attrib, transform, region, mask); | ||
1875 | 67 | } | ||
1876 | 0 | 68 | ||
1877 | === added file 'plugins/screensaver/src/wrapper.h' | |||
1878 | --- plugins/screensaver/src/wrapper.h 1970-01-01 00:00:00 +0000 | |||
1879 | +++ plugins/screensaver/src/wrapper.h 2013-07-24 16:13:49 +0000 | |||
1880 | @@ -0,0 +1,4 @@ | |||
1881 | 1 | #ifndef WRAPPER_H | ||
1882 | 2 | #define WRAPPER_H | ||
1883 | 3 | |||
1884 | 4 | #endif |