Merge lp:~mniess/ubuntu/precise/compiz-plugins-main/lp953278 into lp:ubuntu/precise/compiz-plugins-main
- Precise (12.04)
- lp953278
- Merge into precise
Status: | Merged |
---|---|
Merge reported by: | Didier Roche-Tolomelli |
Merged at revision: | not available |
Proposed branch: | lp:~mniess/ubuntu/precise/compiz-plugins-main/lp953278 |
Merge into: | lp:ubuntu/precise/compiz-plugins-main |
Diff against target: |
17565 lines (+318/-16206) 47 files modified
.pc/applied-patches (+0/-10) .pc/expo.patch/expo/CMakeLists.txt (+0/-7) .pc/expo.patch/expo/expo.xml.in (+0/-257) .pc/expo.patch/expo/src/expo.cpp (+0/-1382) .pc/expo.patch/expo/src/expo.h (+0/-163) .pc/expo_api_931927.patch/expo/src/expo.cpp (+0/-1692) .pc/fix_930192.patch/animation/src/animation.cpp (+0/-2962) .pc/fix_broken_build.patch/wall/src/wall.h (+0/-208) .pc/fix_clipping_issues_in_expo.patch/expo/src/expo.cpp (+0/-1667) .pc/shift_954079.patch/shift/shift.xml.in (+0/-393) .pc/ubuntu_config.patch/animation/animation.xml.in (+0/-757) .pc/ubuntu_config.patch/ezoom/ezoom.xml.in (+0/-288) .pc/ubuntu_config.patch/grid/grid.xml.in (+0/-565) .pc/ubuntu_config.patch/staticswitcher/staticswitcher.xml.in (+0/-298) .pc/ubuntu_config.patch/vpswitch/vpswitch.xml.in (+0/-126) .pc/ubuntu_config.patch/wall/wall.xml.in (+0/-361) .pc/vpswitch_953834.patch/vpswitch/src/vpswitch.cpp (+0/-369) .pc/workarounds_923087.patch/workarounds/src/workarounds.cpp (+0/-1178) .pc/workarounds_931473.patch/workarounds/src/workarounds.cpp (+0/-1152) .pc/workarounds_931473.patch/workarounds/src/workarounds.h (+0/-215) .pc/workarounds_931473.patch/workarounds/workarounds.xml.in (+0/-106) animation/animation.xml.in (+23/-23) animation/src/animation.cpp (+0/-5) debian/changelog (+9/-0) debian/patches/fix-lp953278.patch (+16/-0) debian/patches/series (+1/-0) expo/CMakeLists.txt (+1/-1) expo/expo.xml.in (+11/-33) expo/src/expo.cpp (+167/-477) expo/src/expo.h (+2/-57) expo/src/glow.cpp (+0/-428) expo/src/glow.h (+0/-66) expo/src/group_glow.h (+0/-197) ezoom/ezoom.xml.in (+3/-0) glow.cpp (+0/-428) glow.h (+0/-66) grid/grid.xml.in (+4/-2) group_glow.h (+0/-197) shift/shift.xml.in (+5/-0) staticswitcher/staticswitcher.xml.in (+9/-8) vpswitch/src/vpswitch.cpp (+1/-1) vpswitch/vpswitch.xml.in (+2/-0) wall/src/wall.h (+1/-1) wall/wall.xml.in (+31/-31) workarounds/src/workarounds.cpp (+32/-20) workarounds/src/workarounds.h (+0/-4) workarounds/workarounds.xml.in (+0/-5) |
To merge this branch: | bzr merge lp:~mniess/ubuntu/precise/compiz-plugins-main/lp953278 |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Didier Roche-Tolomelli | Approve | ||
Ubuntu branches | Pending | ||
Review via email: mp+99407@code.launchpad.net |
Commit message
Description of the change
Disabled super+r as bad default for fit_to_window_key (LP: #953278)
- 31. By Matthias Niess
-
* debian/
patches/ fix-lp953278. patch:
- disable bad default of Super+r causing zoom to current window in
ezoom plugin (LP: #953278)
Matthias Niess (mniess) wrote : | # |
Didier Roche-Tolomelli (didrocks) wrote : | # |
Hey Matthias.
Thanks a lot for your patch!
However, I can't see it in the below diff (looked for a fix-lp953278.patch file).
The idea of the change is good, so I committed it under your name in the correct branch: http://
(look at the Vcs-Bzr tag in debian/control, the command "debcheckout <package_name>" should bzr branch from the right branch).
Also, you will notice I merged your change to debian/
Thanks again for your contribution :)
I'm marking this branch as merged then.
Matthias Niess (mniess) wrote : | # |
Hi Didier. I'll do better next time! ;) I already know where things went wrong (i.e. I followed the Fixing Ubuntu bugs guide to the letter and edit-patch changed behavior). Thanks for the tips.
Preview Diff
1 | === removed file '.pc/applied-patches' | |||
2 | --- .pc/applied-patches 2012-03-21 11:46:41 +0000 | |||
3 | +++ .pc/applied-patches 1970-01-01 00:00:00 +0000 | |||
4 | @@ -1,10 +0,0 @@ | |||
5 | 1 | expo.patch | ||
6 | 2 | fix_clipping_issues_in_expo.patch | ||
7 | 3 | ubuntu_config.patch | ||
8 | 4 | expo_api_931927.patch | ||
9 | 5 | workarounds_923087.patch | ||
10 | 6 | workarounds_931473.patch | ||
11 | 7 | shift_954079.patch | ||
12 | 8 | fix_broken_build.patch | ||
13 | 9 | vpswitch_953834.patch | ||
14 | 10 | fix_930192.patch | ||
15 | 11 | 0 | ||
16 | === removed directory '.pc/expo.patch' | |||
17 | === removed directory '.pc/expo.patch/expo' | |||
18 | === removed file '.pc/expo.patch/expo/CMakeLists.txt' | |||
19 | --- .pc/expo.patch/expo/CMakeLists.txt 2012-02-13 15:30:29 +0000 | |||
20 | +++ .pc/expo.patch/expo/CMakeLists.txt 1970-01-01 00:00:00 +0000 | |||
21 | @@ -1,7 +0,0 @@ | |||
22 | 1 | find_package (Compiz REQUIRED) | ||
23 | 2 | include (FindOpenGL) | ||
24 | 3 | include (CompizPlugin) | ||
25 | 4 | |||
26 | 5 | if (OPENGL_GLU_FOUND) | ||
27 | 6 | compiz_plugin (expo PLUGINDEPS composite opengl LIBRARIES ${OPENGL_glu_LIBRARY} INCDIRS ${OPENGL_INCLUDE_DIR}) | ||
28 | 7 | endif (OPENGL_GLU_FOUND) | ||
29 | 8 | 0 | ||
30 | === removed file '.pc/expo.patch/expo/expo.xml.in' | |||
31 | --- .pc/expo.patch/expo/expo.xml.in 2012-02-13 15:30:29 +0000 | |||
32 | +++ .pc/expo.patch/expo/expo.xml.in 1970-01-01 00:00:00 +0000 | |||
33 | @@ -1,257 +0,0 @@ | |||
34 | 1 | <?xml version="1.0"?> | ||
35 | 2 | <compiz> | ||
36 | 3 | <plugin name="expo" useBcop="true"> | ||
37 | 4 | <_short>Expo</_short> | ||
38 | 5 | <_long>Expo Plugin</_long> | ||
39 | 6 | <category>Desktop</category> | ||
40 | 7 | <deps> | ||
41 | 8 | <requirement> | ||
42 | 9 | <plugin>opengl</plugin> | ||
43 | 10 | </requirement> | ||
44 | 11 | <relation type="after"> | ||
45 | 12 | <plugin>composite</plugin> | ||
46 | 13 | <plugin>opengl</plugin> | ||
47 | 14 | <plugin>decor</plugin> | ||
48 | 15 | <plugin>cube</plugin> | ||
49 | 16 | <plugin>cubeaddon</plugin> | ||
50 | 17 | <plugin>wobbly</plugin> | ||
51 | 18 | <plugin>animation</plugin> | ||
52 | 19 | <plugin>wallpaper</plugin> | ||
53 | 20 | </relation> | ||
54 | 21 | </deps> | ||
55 | 22 | <options> | ||
56 | 23 | <group> | ||
57 | 24 | <_short>Bindings</_short> | ||
58 | 25 | <option name="expo_key" type="key"> | ||
59 | 26 | <_short>Expo key</_short> | ||
60 | 27 | <_long>Engage wall expo mode key binding</_long> | ||
61 | 28 | <default><Super>e</default> | ||
62 | 29 | </option> | ||
63 | 30 | <option name="expo_button" type="button"> | ||
64 | 31 | <_short>Expo button</_short> | ||
65 | 32 | <_long>Engage wall expo mode button binding</_long> | ||
66 | 33 | <default></default> | ||
67 | 34 | </option> | ||
68 | 35 | <option name="expo_edge" type="edge"> | ||
69 | 36 | <_short>Expo edge</_short> | ||
70 | 37 | <_long>Engage wall expo mode edge binding</_long> | ||
71 | 38 | <default> | ||
72 | 39 | <edge name="TopLeft"/> | ||
73 | 40 | </default> | ||
74 | 41 | </option> | ||
75 | 42 | <option name="double_click_time" type="int"> | ||
76 | 43 | <_short>Double click time</_short> | ||
77 | 44 | <_long>Timeframe to execute a double click</_long> | ||
78 | 45 | <default>500</default> | ||
79 | 46 | <min>50</min> | ||
80 | 47 | <max>2000</max> | ||
81 | 48 | </option> | ||
82 | 49 | <option name="dnd_button" type="button"> | ||
83 | 50 | <_short>Drag&drop</_short> | ||
84 | 51 | <_long>Button binding for drag & drop of windows</_long> | ||
85 | 52 | <default>Button1</default> | ||
86 | 53 | <passive_grab>false</passive_grab> | ||
87 | 54 | <internal/> | ||
88 | 55 | </option> | ||
89 | 56 | <option name="exit_button" type="button"> | ||
90 | 57 | <_short>Exit expo</_short> | ||
91 | 58 | <_long>Button binding to exit expo</_long> | ||
92 | 59 | <default>Button3</default> | ||
93 | 60 | <passive_grab>false</passive_grab> | ||
94 | 61 | <internal/> | ||
95 | 62 | </option> | ||
96 | 63 | <option name="next_vp_button" type="button"> | ||
97 | 64 | <_short>Next viewport</_short> | ||
98 | 65 | <_long>Button binding to switch to next viewport in expo</_long> | ||
99 | 66 | <default>Button5</default> | ||
100 | 67 | <passive_grab>false</passive_grab> | ||
101 | 68 | <internal/> | ||
102 | 69 | </option> | ||
103 | 70 | <option name="prev_vp_button" type="button"> | ||
104 | 71 | <_short>Previous viewport</_short> | ||
105 | 72 | <_long>Button binding to switch to next viewport in expo</_long> | ||
106 | 73 | <default>Button4</default> | ||
107 | 74 | <passive_grab>false</passive_grab> | ||
108 | 75 | <internal/> | ||
109 | 76 | </option> | ||
110 | 77 | </group> | ||
111 | 78 | <group> | ||
112 | 79 | <_short>Behaviour</_short> | ||
113 | 80 | <option name="zoom_time" type="float"> | ||
114 | 81 | <_short>Zoom time</_short> | ||
115 | 82 | <_long>Duration of the zoomout animation</_long> | ||
116 | 83 | <default>0.5</default> | ||
117 | 84 | <min>0.1</min> | ||
118 | 85 | <max>5.0</max> | ||
119 | 86 | <precision>0.1</precision> | ||
120 | 87 | </option> | ||
121 | 88 | <option name="expo_immediate_move" type="bool"> | ||
122 | 89 | <_short>Immediate moves</_short> | ||
123 | 90 | <_long>Selects if windows movements in expo mode should be immediate - this among other things disables wobbliness</_long> | ||
124 | 91 | <default>false</default> | ||
125 | 92 | </option> | ||
126 | 93 | <option name="expo_animation" type="int"> | ||
127 | 94 | <_short>Expo Animation</_short> | ||
128 | 95 | <_long>Animation used when switching to expo mode</_long> | ||
129 | 96 | <default>0</default> | ||
130 | 97 | <min>0</min> | ||
131 | 98 | <max>2</max> | ||
132 | 99 | <desc> | ||
133 | 100 | <value>0</value> | ||
134 | 101 | <_name>Zoom</_name> | ||
135 | 102 | </desc> | ||
136 | 103 | <desc> | ||
137 | 104 | <value>1</value> | ||
138 | 105 | <_name>Fade + Zoom</_name> | ||
139 | 106 | </desc> | ||
140 | 107 | <desc> | ||
141 | 108 | <value>2</value> | ||
142 | 109 | <_name>Vortex</_name> | ||
143 | 110 | </desc> | ||
144 | 111 | </option> | ||
145 | 112 | </group> | ||
146 | 113 | <group> | ||
147 | 114 | <_short>Appearance</_short> | ||
148 | 115 | <option name="deform" type="int"> | ||
149 | 116 | <_short>Deformation</_short> | ||
150 | 117 | <_long>Deformation of the expo wall</_long> | ||
151 | 118 | <default>0</default> | ||
152 | 119 | <min>0</min> | ||
153 | 120 | <max>2</max> | ||
154 | 121 | <desc> | ||
155 | 122 | <value>0</value> | ||
156 | 123 | <_name>None</_name> | ||
157 | 124 | </desc> | ||
158 | 125 | <desc> | ||
159 | 126 | <value>1</value> | ||
160 | 127 | <_name>Tilt</_name> | ||
161 | 128 | </desc> | ||
162 | 129 | <desc> | ||
163 | 130 | <value>2</value> | ||
164 | 131 | <_name>Curve</_name> | ||
165 | 132 | </desc> | ||
166 | 133 | </option> | ||
167 | 134 | <option name="distance" type="float"> | ||
168 | 135 | <_short>Distance</_short> | ||
169 | 136 | <_long>Distance of the expo wall</_long> | ||
170 | 137 | <default>0.0</default> | ||
171 | 138 | <min>0.0</min> | ||
172 | 139 | <max>1.0</max> | ||
173 | 140 | <precision>0.01</precision> | ||
174 | 141 | </option> | ||
175 | 142 | <option name="vp_distance" type="float"> | ||
176 | 143 | <_short>Viewport distance</_short> | ||
177 | 144 | <_long>Distance between viewports</_long> | ||
178 | 145 | <default>0.10</default> | ||
179 | 146 | <min>0.0</min> | ||
180 | 147 | <max>1.0</max> | ||
181 | 148 | <precision>0.01</precision> | ||
182 | 149 | </option> | ||
183 | 150 | <option name="aspect_ratio" type="float"> | ||
184 | 151 | <_short>Aspect Ratio</_short> | ||
185 | 152 | <_long>Expo mode aspect ratio</_long> | ||
186 | 153 | <default>1.0</default> | ||
187 | 154 | <min>0.0</min> | ||
188 | 155 | <max>1.0</max> | ||
189 | 156 | <precision>0.1</precision> | ||
190 | 157 | </option> | ||
191 | 158 | <option name="curve" type="float"> | ||
192 | 159 | <_short>Curve strength</_short> | ||
193 | 160 | <_long>Strength of the deformation in curve mode</_long> | ||
194 | 161 | <default>0.50</default> | ||
195 | 162 | <min>0.0</min> | ||
196 | 163 | <max>1.0</max> | ||
197 | 164 | <precision>0.01</precision> | ||
198 | 165 | </option> | ||
199 | 166 | <option name="hide_docks" type="bool"> | ||
200 | 167 | <_short>Hide panels/docks in expo</_short> | ||
201 | 168 | <_long>Hide panels/docks in expo.</_long> | ||
202 | 169 | <default>false</default> | ||
203 | 170 | </option> | ||
204 | 171 | <option name="mipmaps" type="bool"> | ||
205 | 172 | <_short>Mipmaps</_short> | ||
206 | 173 | <_long>Generate mipmaps in expo mode</_long> | ||
207 | 174 | <default>false</default> | ||
208 | 175 | </option> | ||
209 | 176 | <option name="multioutput_mode" type="int"> | ||
210 | 177 | <_short>Multi Output Mode</_short> | ||
211 | 178 | <_long>Selects how the expo wall is displayed if multiple output devices are used.</_long> | ||
212 | 179 | <min>0</min> | ||
213 | 180 | <max>1</max> | ||
214 | 181 | <default>0</default> | ||
215 | 182 | <desc> | ||
216 | 183 | <value>0</value> | ||
217 | 184 | <_name>One big wall</_name> | ||
218 | 185 | </desc> | ||
219 | 186 | <desc> | ||
220 | 187 | <value>1</value> | ||
221 | 188 | <_name>One wall per output</_name> | ||
222 | 189 | </desc> | ||
223 | 190 | </option> | ||
224 | 191 | <subgroup> | ||
225 | 192 | <short>Inactive viewports</short> | ||
226 | 193 | <option name="vp_brightness" type="float"> | ||
227 | 194 | <_short>Brightness</_short> | ||
228 | 195 | <_long>Inactive viewport brightness.</_long> | ||
229 | 196 | <default>75.0</default> | ||
230 | 197 | <min>0.0</min> | ||
231 | 198 | <max>100.0</max> | ||
232 | 199 | <precision>0.1</precision> | ||
233 | 200 | </option> | ||
234 | 201 | <option name="vp_saturation" type="float"> | ||
235 | 202 | <_short>Saturation</_short> | ||
236 | 203 | <_long>Inactive viewport saturation.</_long> | ||
237 | 204 | <default>100.0</default> | ||
238 | 205 | <min>0.0</min> | ||
239 | 206 | <max>100.0</max> | ||
240 | 207 | <precision>0.1</precision> | ||
241 | 208 | </option> | ||
242 | 209 | </subgroup> | ||
243 | 210 | <subgroup> | ||
244 | 211 | <short>Reflection</short> | ||
245 | 212 | <option name="reflection" type="bool"> | ||
246 | 213 | <_short>Reflection</_short> | ||
247 | 214 | <_long>Show a reflection of the viewports on the ground</_long> | ||
248 | 215 | <default>true</default> | ||
249 | 216 | </option> | ||
250 | 217 | <option name="ground_color1" type="color"> | ||
251 | 218 | <_short>Ground color(near)</_short> | ||
252 | 219 | <_long>Color of the ground (near).</_long> | ||
253 | 220 | <default> | ||
254 | 221 | <red>0xb333</red> | ||
255 | 222 | <green>0xb333</green> | ||
256 | 223 | <blue>0xb333</blue> | ||
257 | 224 | <alpha>0xcccc</alpha> | ||
258 | 225 | </default> | ||
259 | 226 | </option> | ||
260 | 227 | <option name="ground_color2" type="color"> | ||
261 | 228 | <_short>Ground color(far)</_short> | ||
262 | 229 | <_long>Color of the ground (far).</_long> | ||
263 | 230 | <default> | ||
264 | 231 | <red>0xb333</red> | ||
265 | 232 | <green>0xb333</green> | ||
266 | 233 | <blue>0xb333</blue> | ||
267 | 234 | <alpha>0x0000</alpha> | ||
268 | 235 | </default> | ||
269 | 236 | </option> | ||
270 | 237 | <option name="ground_size" type="float"> | ||
271 | 238 | <_short>Reflection ground size</_short> | ||
272 | 239 | <_long>Reflection ground size.</_long> | ||
273 | 240 | <default>0.5</default> | ||
274 | 241 | <min>0.0</min> | ||
275 | 242 | <max>1.0</max> | ||
276 | 243 | <precision>0.01</precision> | ||
277 | 244 | </option> | ||
278 | 245 | <option name="scale_factor" type="float"> | ||
279 | 246 | <_short>Reflection Scale</_short> | ||
280 | 247 | <_long>Scale factor of the expo wall reflection</_long> | ||
281 | 248 | <default>0.75</default> | ||
282 | 249 | <min>0.0</min> | ||
283 | 250 | <max>2.0</max> | ||
284 | 251 | <precision>0.01</precision> | ||
285 | 252 | </option> | ||
286 | 253 | </subgroup> | ||
287 | 254 | </group> | ||
288 | 255 | </options> | ||
289 | 256 | </plugin> | ||
290 | 257 | </compiz> | ||
291 | 258 | 0 | ||
292 | === removed directory '.pc/expo.patch/expo/src' | |||
293 | === removed file '.pc/expo.patch/expo/src/expo.cpp' | |||
294 | --- .pc/expo.patch/expo/src/expo.cpp 2012-02-13 15:30:29 +0000 | |||
295 | +++ .pc/expo.patch/expo/src/expo.cpp 1970-01-01 00:00:00 +0000 | |||
296 | @@ -1,1382 +0,0 @@ | |||
297 | 1 | /** | ||
298 | 2 | * | ||
299 | 3 | * Compiz expo plugin | ||
300 | 4 | * | ||
301 | 5 | * expo.c | ||
302 | 6 | * | ||
303 | 7 | * Copyright (c) 2008 Dennis Kasprzyk <racarr@opencompositing.org> | ||
304 | 8 | * Copyright (c) 2006 Robert Carr <racarr@beryl-project.org> | ||
305 | 9 | * | ||
306 | 10 | * Authors: | ||
307 | 11 | * Robert Carr <racarr@beryl-project.org> | ||
308 | 12 | * Dennis Kasprzyk <onestone@opencompositing.org> | ||
309 | 13 | * | ||
310 | 14 | * This program is free software; you can redistribute it and/or | ||
311 | 15 | * modify it under the terms of the GNU General Public License | ||
312 | 16 | * as published by the Free Software Foundation; either version 2 | ||
313 | 17 | * of the License, or (at your option) any later version. | ||
314 | 18 | * | ||
315 | 19 | * This program is distributed in the hope that it will be useful, | ||
316 | 20 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
317 | 21 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
318 | 22 | * GNU General Public License for more details. | ||
319 | 23 | * | ||
320 | 24 | **/ | ||
321 | 25 | |||
322 | 26 | #include "expo.h" | ||
323 | 27 | #include <math.h> | ||
324 | 28 | #include <GL/glu.h> | ||
325 | 29 | |||
326 | 30 | COMPIZ_PLUGIN_20090315 (expo, ExpoPluginVTable); | ||
327 | 31 | |||
328 | 32 | #define sigmoid(x) (1.0f / (1.0f + exp (-5.5f * 2 * ((x) - 0.5)))) | ||
329 | 33 | #define sigmoidProgress(x) ((sigmoid (x) - sigmoid (0)) / \ | ||
330 | 34 | (sigmoid (1) - sigmoid (0))) | ||
331 | 35 | |||
332 | 36 | #define interpolate(a, b, val) (((val) * (a)) + ((1 - (val)) * (b))) | ||
333 | 37 | |||
334 | 38 | bool | ||
335 | 39 | ExpoScreen::dndInit (CompAction *action, | ||
336 | 40 | CompAction::State state, | ||
337 | 41 | CompOption::Vector& options) | ||
338 | 42 | { | ||
339 | 43 | Window xid = CompOption::getIntOptionNamed (options, "root", 0); | ||
340 | 44 | if (xid != screen->root ()) | ||
341 | 45 | return false; | ||
342 | 46 | |||
343 | 47 | if (expoMode) | ||
344 | 48 | { | ||
345 | 49 | dndState = DnDStart; | ||
346 | 50 | action->setState (action->state () | CompAction::StateTermButton); | ||
347 | 51 | cScreen->damageScreen (); | ||
348 | 52 | |||
349 | 53 | return true; | ||
350 | 54 | } | ||
351 | 55 | |||
352 | 56 | return false; | ||
353 | 57 | } | ||
354 | 58 | |||
355 | 59 | bool | ||
356 | 60 | ExpoScreen::dndFini (CompAction *action, | ||
357 | 61 | CompAction::State state, | ||
358 | 62 | CompOption::Vector& options) | ||
359 | 63 | { | ||
360 | 64 | Window xid = CompOption::getIntOptionNamed (options, "root", 0); | ||
361 | 65 | if (xid != screen->root ()) | ||
362 | 66 | return false; | ||
363 | 67 | |||
364 | 68 | if (dndState == DnDDuring || dndState == DnDStart) | ||
365 | 69 | { | ||
366 | 70 | if (dndWindow) | ||
367 | 71 | finishWindowMovement (); | ||
368 | 72 | |||
369 | 73 | dndState = DnDNone; | ||
370 | 74 | dndWindow = NULL; | ||
371 | 75 | |||
372 | 76 | action->setState (action->state () & CompAction::StateInitButton); | ||
373 | 77 | cScreen->damageScreen (); | ||
374 | 78 | |||
375 | 79 | return true; | ||
376 | 80 | } | ||
377 | 81 | |||
378 | 82 | return false; | ||
379 | 83 | } | ||
380 | 84 | |||
381 | 85 | bool | ||
382 | 86 | ExpoScreen::doExpo (CompAction *action, | ||
383 | 87 | CompAction::State state, | ||
384 | 88 | CompOption::Vector& options) | ||
385 | 89 | { | ||
386 | 90 | Window xid = CompOption::getIntOptionNamed (options, "root", 0); | ||
387 | 91 | if (xid != screen->root ()) | ||
388 | 92 | return false; | ||
389 | 93 | |||
390 | 94 | if (screen->otherGrabExist ("expo", NULL)) | ||
391 | 95 | return false; | ||
392 | 96 | |||
393 | 97 | if (!expoMode) | ||
394 | 98 | { | ||
395 | 99 | if (!grabIndex) | ||
396 | 100 | grabIndex = screen->pushGrab (None, "expo"); | ||
397 | 101 | |||
398 | 102 | updateWraps (true); | ||
399 | 103 | |||
400 | 104 | expoMode = true; | ||
401 | 105 | anyClick = false; | ||
402 | 106 | doubleClick = false; | ||
403 | 107 | clickTime = 0; | ||
404 | 108 | |||
405 | 109 | dndState = DnDNone; | ||
406 | 110 | dndWindow = NULL; | ||
407 | 111 | |||
408 | 112 | selectedVp = screen->vp (); | ||
409 | 113 | lastSelectedVp = screen->vp (); | ||
410 | 114 | origVp = screen->vp (); | ||
411 | 115 | |||
412 | 116 | screen->addAction (&optionGetDndButton ()); | ||
413 | 117 | screen->addAction (&optionGetExitButton ()); | ||
414 | 118 | screen->addAction (&optionGetNextVpButton ()); | ||
415 | 119 | screen->addAction (&optionGetPrevVpButton ()); | ||
416 | 120 | |||
417 | 121 | cScreen->damageScreen (); | ||
418 | 122 | } | ||
419 | 123 | else | ||
420 | 124 | { | ||
421 | 125 | termExpo (action, state, options); | ||
422 | 126 | } | ||
423 | 127 | |||
424 | 128 | return true; | ||
425 | 129 | } | ||
426 | 130 | |||
427 | 131 | bool | ||
428 | 132 | ExpoScreen::termExpo (CompAction *action, | ||
429 | 133 | CompAction::State state, | ||
430 | 134 | CompOption::Vector& options) | ||
431 | 135 | { | ||
432 | 136 | Window xid = CompOption::getIntOptionNamed (options, "root", 0); | ||
433 | 137 | if (xid && xid != screen->root ()) | ||
434 | 138 | return false; | ||
435 | 139 | |||
436 | 140 | if (!expoMode) | ||
437 | 141 | return true; | ||
438 | 142 | |||
439 | 143 | expoMode = false; | ||
440 | 144 | |||
441 | 145 | if (dndState != DnDNone) | ||
442 | 146 | dndFini (action, state, options); | ||
443 | 147 | |||
444 | 148 | if (state & CompAction::StateCancel) | ||
445 | 149 | vpUpdateMode = VPUpdatePrevious; | ||
446 | 150 | else | ||
447 | 151 | vpUpdateMode = VPUpdateMouseOver; | ||
448 | 152 | |||
449 | 153 | dndState = DnDNone; | ||
450 | 154 | dndWindow = NULL; | ||
451 | 155 | |||
452 | 156 | screen->removeAction (&optionGetDndButton ()); | ||
453 | 157 | screen->removeAction (&optionGetExitButton ()); | ||
454 | 158 | screen->removeAction (&optionGetNextVpButton ()); | ||
455 | 159 | screen->removeAction (&optionGetPrevVpButton ()); | ||
456 | 160 | |||
457 | 161 | cScreen->damageScreen (); | ||
458 | 162 | screen->focusDefaultWindow (); | ||
459 | 163 | |||
460 | 164 | return true; | ||
461 | 165 | } | ||
462 | 166 | |||
463 | 167 | bool | ||
464 | 168 | ExpoScreen::exitExpo (CompAction *action, | ||
465 | 169 | CompAction::State state, | ||
466 | 170 | CompOption::Vector& options) | ||
467 | 171 | { | ||
468 | 172 | Window xid = CompOption::getIntOptionNamed (options, "root", 0); | ||
469 | 173 | if (xid != screen->root ()) | ||
470 | 174 | return false; | ||
471 | 175 | |||
472 | 176 | if (!expoMode) | ||
473 | 177 | return false; | ||
474 | 178 | |||
475 | 179 | termExpo (action, 0, noOptions); | ||
476 | 180 | anyClick = true; | ||
477 | 181 | cScreen->damageScreen (); | ||
478 | 182 | |||
479 | 183 | return true; | ||
480 | 184 | } | ||
481 | 185 | |||
482 | 186 | bool | ||
483 | 187 | ExpoScreen::nextVp (CompAction *action, | ||
484 | 188 | CompAction::State state, | ||
485 | 189 | CompOption::Vector& options) | ||
486 | 190 | { | ||
487 | 191 | unsigned int newX, newY; | ||
488 | 192 | Window xid = CompOption::getIntOptionNamed (options, "root", 0); | ||
489 | 193 | if (xid != screen->root ()) | ||
490 | 194 | return false; | ||
491 | 195 | |||
492 | 196 | if (!expoMode) | ||
493 | 197 | return false; | ||
494 | 198 | |||
495 | 199 | newX = selectedVp.x () + 1; | ||
496 | 200 | newY = selectedVp.y (); | ||
497 | 201 | |||
498 | 202 | if (newX >= (unsigned int) screen->vpSize ().width ()) | ||
499 | 203 | { | ||
500 | 204 | newX = 0; | ||
501 | 205 | newY = newY + 1; | ||
502 | 206 | if (newY >= (unsigned int) screen->vpSize ().height ()) | ||
503 | 207 | newY = 0; | ||
504 | 208 | } | ||
505 | 209 | |||
506 | 210 | moveFocusViewport (newX - selectedVp.x (), | ||
507 | 211 | newY - selectedVp.y ()); | ||
508 | 212 | cScreen->damageScreen (); | ||
509 | 213 | |||
510 | 214 | return true; | ||
511 | 215 | } | ||
512 | 216 | |||
513 | 217 | bool | ||
514 | 218 | ExpoScreen::prevVp (CompAction *action, | ||
515 | 219 | CompAction::State state, | ||
516 | 220 | CompOption::Vector& options) | ||
517 | 221 | { | ||
518 | 222 | unsigned int newX, newY; | ||
519 | 223 | Window xid = CompOption::getIntOptionNamed (options, "root", 0); | ||
520 | 224 | if (xid != screen->root ()) | ||
521 | 225 | return false; | ||
522 | 226 | |||
523 | 227 | if (!expoMode) | ||
524 | 228 | return false; | ||
525 | 229 | |||
526 | 230 | newX = selectedVp.x () - 1; | ||
527 | 231 | newY = selectedVp.y (); | ||
528 | 232 | |||
529 | 233 | if (newX < 0) | ||
530 | 234 | { | ||
531 | 235 | newX = screen->vpSize ().width () - 1; | ||
532 | 236 | newY = newY - 1; | ||
533 | 237 | if (newY < 0) | ||
534 | 238 | newY = screen->vpSize ().height () - 1; | ||
535 | 239 | } | ||
536 | 240 | |||
537 | 241 | moveFocusViewport (newX - selectedVp.x (), | ||
538 | 242 | newY - selectedVp.y ()); | ||
539 | 243 | cScreen->damageScreen (); | ||
540 | 244 | |||
541 | 245 | return true; | ||
542 | 246 | } | ||
543 | 247 | |||
544 | 248 | void | ||
545 | 249 | ExpoScreen::moveFocusViewport (int dx, | ||
546 | 250 | int dy) | ||
547 | 251 | { | ||
548 | 252 | int newX, newY; | ||
549 | 253 | |||
550 | 254 | lastSelectedVp = selectedVp; | ||
551 | 255 | |||
552 | 256 | newX = selectedVp.x () + dx; | ||
553 | 257 | newY = selectedVp.y () + dy; | ||
554 | 258 | |||
555 | 259 | newX = MAX (0, MIN ((int) screen->vpSize ().width () - 1, newX)); | ||
556 | 260 | newY = MAX (0, MIN ((int) screen->vpSize ().height () - 1, newY)); | ||
557 | 261 | |||
558 | 262 | selectedVp.set (newX, newY); | ||
559 | 263 | cScreen->damageScreen (); | ||
560 | 264 | } | ||
561 | 265 | |||
562 | 266 | void | ||
563 | 267 | ExpoScreen::finishWindowMovement () | ||
564 | 268 | { | ||
565 | 269 | dndWindow->syncPosition (); | ||
566 | 270 | dndWindow->ungrabNotify (); | ||
567 | 271 | |||
568 | 272 | screen->moveViewport (screen->vp ().x () - selectedVp.x (), | ||
569 | 273 | screen->vp ().y () - selectedVp.y (), true); | ||
570 | 274 | |||
571 | 275 | /* update saved window attributes in case we moved the | ||
572 | 276 | window to a new viewport */ | ||
573 | 277 | if (dndWindow->saveMask () & CWX) | ||
574 | 278 | { | ||
575 | 279 | dndWindow->saveWc ().x = dndWindow->saveWc ().x % screen->width (); | ||
576 | 280 | if (dndWindow->saveWc ().x < 0) | ||
577 | 281 | dndWindow->saveWc ().x += screen->width (); | ||
578 | 282 | } | ||
579 | 283 | if (dndWindow->saveMask () & CWY) | ||
580 | 284 | { | ||
581 | 285 | dndWindow->saveWc ().y = dndWindow->saveWc ().y % screen->height (); | ||
582 | 286 | if (dndWindow->saveWc ().y < 0) | ||
583 | 287 | dndWindow->saveWc ().y += screen->height (); | ||
584 | 288 | } | ||
585 | 289 | |||
586 | 290 | /* update window attibutes to make sure a moved maximized window | ||
587 | 291 | is properly snapped to the work area */ | ||
588 | 292 | if (dndWindow->state () & MAXIMIZE_STATE) | ||
589 | 293 | dndWindow->updateAttributes (CompStackingUpdateModeNone); | ||
590 | 294 | |||
591 | 295 | #if 0 /* FIXME: obsolete in the meantime? */ | ||
592 | 296 | { | ||
593 | 297 | int lastOutput; | ||
594 | 298 | int centerX, centerY; | ||
595 | 299 | |||
596 | 300 | /* make sure we snap to the correct output */ | ||
597 | 301 | lastOutput = s->currentOutputDev; | ||
598 | 302 | centerX = (WIN_X (w) + WIN_W (w) / 2) % s->width; | ||
599 | 303 | if (centerX < 0) | ||
600 | 304 | centerX += s->width; | ||
601 | 305 | centerY = (WIN_Y (w) + WIN_H (w) / 2) % s->height; | ||
602 | 306 | if (centerY < 0) | ||
603 | 307 | centerY += s->height; | ||
604 | 308 | |||
605 | 309 | s->currentOutputDev = outputDeviceForPoint (s, centerX, centerY); | ||
606 | 310 | |||
607 | 311 | updateWindowAttributes (w, CompStackingUpdateModeNone); | ||
608 | 312 | |||
609 | 313 | s->currentOutputDev = lastOutput; | ||
610 | 314 | } | ||
611 | 315 | #endif | ||
612 | 316 | } | ||
613 | 317 | |||
614 | 318 | void | ||
615 | 319 | ExpoScreen::handleEvent (XEvent *event) | ||
616 | 320 | { | ||
617 | 321 | switch (event->type) { | ||
618 | 322 | case KeyPress: | ||
619 | 323 | if (expoMode && event->xkey.root == screen->root ()) | ||
620 | 324 | { | ||
621 | 325 | if (event->xkey.keycode == leftKey) | ||
622 | 326 | moveFocusViewport (-1, 0); | ||
623 | 327 | else if (event->xkey.keycode == rightKey) | ||
624 | 328 | moveFocusViewport (1, 0); | ||
625 | 329 | else if (event->xkey.keycode == upKey) | ||
626 | 330 | moveFocusViewport (0, -1); | ||
627 | 331 | else if (event->xkey.keycode == downKey) | ||
628 | 332 | moveFocusViewport (0, 1); | ||
629 | 333 | } | ||
630 | 334 | break; | ||
631 | 335 | |||
632 | 336 | case ButtonPress: | ||
633 | 337 | if (expoMode && event->xbutton.button == Button1 && | ||
634 | 338 | event->xbutton.root == screen->root ()) | ||
635 | 339 | { | ||
636 | 340 | anyClick = true; | ||
637 | 341 | if (clickTime == 0) | ||
638 | 342 | { | ||
639 | 343 | clickTime = event->xbutton.time; | ||
640 | 344 | } | ||
641 | 345 | else if (event->xbutton.time - clickTime <= | ||
642 | 346 | (unsigned int) optionGetDoubleClickTime () && lastSelectedVp == selectedVp) | ||
643 | 347 | { | ||
644 | 348 | doubleClick = true; | ||
645 | 349 | } | ||
646 | 350 | else | ||
647 | 351 | { | ||
648 | 352 | clickTime = event->xbutton.time; | ||
649 | 353 | doubleClick = false; | ||
650 | 354 | } | ||
651 | 355 | cScreen->damageScreen (); | ||
652 | 356 | } | ||
653 | 357 | break; | ||
654 | 358 | |||
655 | 359 | case ButtonRelease: | ||
656 | 360 | if (expoMode && event->xbutton.button == Button1 && | ||
657 | 361 | event->xbutton.root == screen->root ()) | ||
658 | 362 | { | ||
659 | 363 | if (event->xbutton.time - clickTime > | ||
660 | 364 | (unsigned int) optionGetDoubleClickTime ()) | ||
661 | 365 | { | ||
662 | 366 | clickTime = 0; | ||
663 | 367 | doubleClick = false; | ||
664 | 368 | } | ||
665 | 369 | else if (doubleClick) | ||
666 | 370 | { | ||
667 | 371 | CompAction& action = optionGetExpoKey (); | ||
668 | 372 | |||
669 | 373 | clickTime = 0; | ||
670 | 374 | doubleClick = false; | ||
671 | 375 | |||
672 | 376 | termExpo (&action, 0, noOptions); | ||
673 | 377 | anyClick = true; | ||
674 | 378 | } | ||
675 | 379 | } | ||
676 | 380 | break; | ||
677 | 381 | } | ||
678 | 382 | |||
679 | 383 | screen->handleEvent (event); | ||
680 | 384 | } | ||
681 | 385 | |||
682 | 386 | void | ||
683 | 387 | ExpoScreen::preparePaint (int msSinceLastPaint) | ||
684 | 388 | { | ||
685 | 389 | float val = ((float) msSinceLastPaint / 1000.0) / optionGetZoomTime (); | ||
686 | 390 | |||
687 | 391 | if (expoMode) | ||
688 | 392 | expoCam = MIN (1.0, expoCam + val); | ||
689 | 393 | else | ||
690 | 394 | expoCam = MAX (0.0, expoCam - val); | ||
691 | 395 | |||
692 | 396 | if (expoCam) | ||
693 | 397 | { | ||
694 | 398 | unsigned int i, j, vp; | ||
695 | 399 | unsigned int vpCount = screen->vpSize ().width () * | ||
696 | 400 | screen->vpSize ().height (); | ||
697 | 401 | |||
698 | 402 | if (vpActivity.size () < vpCount) | ||
699 | 403 | { | ||
700 | 404 | vpActivity.resize (vpCount); | ||
701 | 405 | foreach (float& activity, vpActivity) | ||
702 | 406 | activity = 1.0f; | ||
703 | 407 | } | ||
704 | 408 | |||
705 | 409 | for (i = 0; i < (unsigned int) screen->vpSize ().width (); i++) | ||
706 | 410 | { | ||
707 | 411 | for (j = 0; j < (unsigned int) screen->vpSize ().height (); j++) | ||
708 | 412 | { | ||
709 | 413 | vp = (j * screen->vpSize ().width ()) + i; | ||
710 | 414 | |||
711 | 415 | if (CompPoint (i, j) == selectedVp) | ||
712 | 416 | vpActivity[vp] = MIN (1.0, vpActivity[vp] + val); | ||
713 | 417 | else | ||
714 | 418 | vpActivity[vp] = MAX (0.0, vpActivity[vp] - val); | ||
715 | 419 | } | ||
716 | 420 | } | ||
717 | 421 | |||
718 | 422 | for (i = 0; i < 360; i++) | ||
719 | 423 | { | ||
720 | 424 | float fi = (float) i; | ||
721 | 425 | |||
722 | 426 | vpNormals[i * 3] = (-sin (fi * (M_PI / 180.0f)) / screen->width ()) * | ||
723 | 427 | expoCam; | ||
724 | 428 | vpNormals[(i * 3) + 1] = 0.0; | ||
725 | 429 | vpNormals[(i * 3) + 2] = (-cos (fi * (M_PI / 180.0f)) * expoCam) - | ||
726 | 430 | (1 - expoCam); | ||
727 | 431 | } | ||
728 | 432 | } | ||
729 | 433 | |||
730 | 434 | cScreen->preparePaint (msSinceLastPaint); | ||
731 | 435 | } | ||
732 | 436 | |||
733 | 437 | void | ||
734 | 438 | ExpoScreen::updateWraps (bool enable) | ||
735 | 439 | { | ||
736 | 440 | screen->handleEventSetEnabled (this, enable); | ||
737 | 441 | cScreen->preparePaintSetEnabled (this, enable); | ||
738 | 442 | cScreen->paintSetEnabled (this, enable); | ||
739 | 443 | cScreen->donePaintSetEnabled (this, enable); | ||
740 | 444 | gScreen->glPaintOutputSetEnabled (this, enable); | ||
741 | 445 | gScreen->glPaintTransformedOutputSetEnabled (this, enable); | ||
742 | 446 | |||
743 | 447 | foreach (CompWindow *w, screen->windows ()) | ||
744 | 448 | { | ||
745 | 449 | ExpoWindow *ew = ExpoWindow::get (w); | ||
746 | 450 | |||
747 | 451 | ew->cWindow->damageRectSetEnabled (ew, enable); | ||
748 | 452 | ew->gWindow->glPaintSetEnabled (ew, enable); | ||
749 | 453 | ew->gWindow->glDrawSetEnabled (ew, enable); | ||
750 | 454 | ew->gWindow->glAddGeometrySetEnabled (ew, enable); | ||
751 | 455 | ew->gWindow->glDrawTextureSetEnabled (ew, enable); | ||
752 | 456 | } | ||
753 | 457 | } | ||
754 | 458 | |||
755 | 459 | void | ||
756 | 460 | ExpoScreen::paint (CompOutput::ptrList& outputs, | ||
757 | 461 | unsigned int mask) | ||
758 | 462 | { | ||
759 | 463 | int width = outputs.front ()->width (); | ||
760 | 464 | int height = outputs.front ()->height (); | ||
761 | 465 | bool sizeDiff = false; | ||
762 | 466 | |||
763 | 467 | /* "One big wall" does not make sense where outputs are different | ||
764 | 468 | * sizes, so force multiple walls in this case | ||
765 | 469 | * | ||
766 | 470 | * TODO: Is it possible to re-create "one big wall" using | ||
767 | 471 | * independent output painting in this case? */ | ||
768 | 472 | |||
769 | 473 | foreach (CompOutput *o, outputs) | ||
770 | 474 | { | ||
771 | 475 | if (o->width () != width || o->height () != height) | ||
772 | 476 | { | ||
773 | 477 | sizeDiff = true; | ||
774 | 478 | break; | ||
775 | 479 | } | ||
776 | 480 | } | ||
777 | 481 | |||
778 | 482 | if (expoCam > 0.0 && outputs.size () > 1 && | ||
779 | 483 | optionGetMultioutputMode () == MultioutputModeOneBigWall && | ||
780 | 484 | !sizeDiff) | ||
781 | 485 | { | ||
782 | 486 | outputs.clear (); | ||
783 | 487 | outputs.push_back (&screen->fullscreenOutput ()); | ||
784 | 488 | } | ||
785 | 489 | |||
786 | 490 | cScreen->paint (outputs, mask); | ||
787 | 491 | } | ||
788 | 492 | |||
789 | 493 | void | ||
790 | 494 | ExpoScreen::donePaint () | ||
791 | 495 | { | ||
792 | 496 | switch (vpUpdateMode) { | ||
793 | 497 | case VPUpdateMouseOver: | ||
794 | 498 | screen->moveViewport (screen->vp ().x () - selectedVp.x (), | ||
795 | 499 | screen->vp ().y () - selectedVp.y (), true); | ||
796 | 500 | screen->focusDefaultWindow (); | ||
797 | 501 | vpUpdateMode = VPUpdateNone; | ||
798 | 502 | break; | ||
799 | 503 | case VPUpdatePrevious: | ||
800 | 504 | screen->moveViewport (screen->vp ().x () - origVp.x (), | ||
801 | 505 | screen->vp ().y () - origVp.y (), true); | ||
802 | 506 | lastSelectedVp = selectedVp; | ||
803 | 507 | selectedVp = origVp; | ||
804 | 508 | screen->focusDefaultWindow (); | ||
805 | 509 | vpUpdateMode = VPUpdateNone; | ||
806 | 510 | break; | ||
807 | 511 | default: | ||
808 | 512 | break; | ||
809 | 513 | } | ||
810 | 514 | |||
811 | 515 | if ((expoCam > 0.0f && expoCam < 1.0f) || dndState != DnDNone) | ||
812 | 516 | cScreen->damageScreen (); | ||
813 | 517 | |||
814 | 518 | if (expoCam == 1.0f) | ||
815 | 519 | { | ||
816 | 520 | foreach (float& vp, vpActivity) | ||
817 | 521 | if (vp != 0.0 && vp != 1.0) | ||
818 | 522 | cScreen->damageScreen (); | ||
819 | 523 | } | ||
820 | 524 | |||
821 | 525 | if (grabIndex && expoCam <= 0.0f && !expoMode) | ||
822 | 526 | { | ||
823 | 527 | screen->removeGrab (grabIndex, NULL); | ||
824 | 528 | grabIndex = 0; | ||
825 | 529 | updateWraps (false); | ||
826 | 530 | } | ||
827 | 531 | |||
828 | 532 | cScreen->donePaint (); | ||
829 | 533 | |||
830 | 534 | switch (dndState) { | ||
831 | 535 | case DnDDuring: | ||
832 | 536 | { | ||
833 | 537 | if (dndWindow) | ||
834 | 538 | dndWindow->move (newCursor.x () - prevCursor.x (), | ||
835 | 539 | newCursor.y () - prevCursor.y (), | ||
836 | 540 | optionGetExpoImmediateMove ()); | ||
837 | 541 | |||
838 | 542 | prevCursor = newCursor; | ||
839 | 543 | cScreen->damageScreen (); | ||
840 | 544 | } | ||
841 | 545 | break; | ||
842 | 546 | |||
843 | 547 | case DnDStart: | ||
844 | 548 | { | ||
845 | 549 | int xOffset, yOffset; | ||
846 | 550 | CompWindowList::reverse_iterator iter; | ||
847 | 551 | |||
848 | 552 | xOffset = screen->vpSize ().width () * screen->width (); | ||
849 | 553 | yOffset = screen->vpSize ().height () * screen->height (); | ||
850 | 554 | |||
851 | 555 | dndState = DnDNone; | ||
852 | 556 | |||
853 | 557 | for (iter = screen->windows ().rbegin (); | ||
854 | 558 | iter != screen->windows ().rend (); ++iter) | ||
855 | 559 | { | ||
856 | 560 | CompWindow *w = *iter; | ||
857 | 561 | CompRect input (w->inputRect ()); | ||
858 | 562 | bool inWindow; | ||
859 | 563 | int nx, ny; | ||
860 | 564 | |||
861 | 565 | if (w->destroyed ()) | ||
862 | 566 | continue; | ||
863 | 567 | |||
864 | 568 | if (!w->shaded () && !w->isViewable ()) | ||
865 | 569 | continue; | ||
866 | 570 | |||
867 | 571 | if (w->onAllViewports ()) | ||
868 | 572 | { | ||
869 | 573 | nx = (newCursor.x () + xOffset) % screen->width (); | ||
870 | 574 | ny = (newCursor.y () + yOffset) % screen->height (); | ||
871 | 575 | } | ||
872 | 576 | else | ||
873 | 577 | { | ||
874 | 578 | nx = newCursor.x () - | ||
875 | 579 | (screen->vp ().x () * screen->width ()); | ||
876 | 580 | ny = newCursor.y () - | ||
877 | 581 | (screen->vp ().y () * screen->height ()); | ||
878 | 582 | } | ||
879 | 583 | |||
880 | 584 | inWindow = (nx >= input.left () && nx <= input.right ()) || | ||
881 | 585 | (nx >= (input.left () + xOffset) && | ||
882 | 586 | nx <= (input.right () + xOffset)); | ||
883 | 587 | |||
884 | 588 | inWindow &= (ny >= input.top () && ny <= input.bottom ()) || | ||
885 | 589 | (ny >= (input.top () + yOffset) && | ||
886 | 590 | ny <= (input.bottom () + yOffset)); | ||
887 | 591 | |||
888 | 592 | if (!inWindow) | ||
889 | 593 | continue; | ||
890 | 594 | |||
891 | 595 | /* make sure we never move windows we're not allowed to move */ | ||
892 | 596 | if (!w->managed ()) | ||
893 | 597 | break; | ||
894 | 598 | else if (!(w->actions () & CompWindowActionMoveMask)) | ||
895 | 599 | break; | ||
896 | 600 | else if (w->type () & (CompWindowTypeDockMask | | ||
897 | 601 | CompWindowTypeDesktopMask)) | ||
898 | 602 | break; | ||
899 | 603 | |||
900 | 604 | dndState = DnDDuring; | ||
901 | 605 | dndWindow = w; | ||
902 | 606 | |||
903 | 607 | w->grabNotify (nx, ny, 0, | ||
904 | 608 | CompWindowGrabMoveMask | | ||
905 | 609 | CompWindowGrabButtonMask); | ||
906 | 610 | |||
907 | 611 | w->raise (); | ||
908 | 612 | w->moveInputFocusTo (); | ||
909 | 613 | break; | ||
910 | 614 | } | ||
911 | 615 | |||
912 | 616 | prevCursor = newCursor; | ||
913 | 617 | } | ||
914 | 618 | break; | ||
915 | 619 | default: | ||
916 | 620 | break; | ||
917 | 621 | } | ||
918 | 622 | } | ||
919 | 623 | |||
920 | 624 | void | ||
921 | 625 | ExpoScreen::invertTransformedVertex (const GLScreenPaintAttrib& attrib, | ||
922 | 626 | const GLMatrix& transform, | ||
923 | 627 | CompOutput *output, | ||
924 | 628 | int vertex[2]) | ||
925 | 629 | { | ||
926 | 630 | GLMatrix sTransform (transform); | ||
927 | 631 | GLdouble p1[3], p2[3], v[3], alpha; | ||
928 | 632 | GLdouble mvm[16], pm[16]; | ||
929 | 633 | GLint viewport[4]; | ||
930 | 634 | int i; | ||
931 | 635 | |||
932 | 636 | gScreen->glApplyTransform (attrib, output, &sTransform); | ||
933 | 637 | sTransform.toScreenSpace (output, -attrib.zTranslate); | ||
934 | 638 | |||
935 | 639 | glGetIntegerv (GL_VIEWPORT, viewport); | ||
936 | 640 | for (i = 0; i < 16; i++) | ||
937 | 641 | { | ||
938 | 642 | mvm[i] = sTransform[i]; | ||
939 | 643 | pm[i] = gScreen->projectionMatrix ()[i]; | ||
940 | 644 | } | ||
941 | 645 | |||
942 | 646 | gluUnProject (vertex[0], screen->height () - vertex[1], 0, mvm, pm, | ||
943 | 647 | viewport, &p1[0], &p1[1], &p1[2]); | ||
944 | 648 | gluUnProject (vertex[0], screen->height () - vertex[1], -1.0, mvm, pm, | ||
945 | 649 | viewport, &p2[0], &p2[1], &p2[2]); | ||
946 | 650 | |||
947 | 651 | for (i = 0; i < 3; i++) | ||
948 | 652 | v[i] = p1[i] - p2[i]; | ||
949 | 653 | |||
950 | 654 | alpha = -p1[2] / v[2]; | ||
951 | 655 | |||
952 | 656 | if (optionGetDeform () == DeformCurve && screen->desktopWindowCount ()) | ||
953 | 657 | { | ||
954 | 658 | const float sws = screen->width () * screen->width (); | ||
955 | 659 | const float rs = (curveDistance * curveDistance) + 0.25; | ||
956 | 660 | const float p = ((2.0 * sws * (p1[2] - curveDistance) * v[2]) + | ||
957 | 661 | (2.0 * p1[0] * v[0]) - | ||
958 | 662 | (v[0] * (float) screen->width ())) / | ||
959 | 663 | ((v[2] * v[2] * sws) + (v[0] * v[0])); | ||
960 | 664 | const float q = (-(sws * rs) + (sws * (p1[2] - curveDistance) * | ||
961 | 665 | (p1[2] - curveDistance)) + | ||
962 | 666 | (0.25 * sws) + (p1[0] * p1[0]) - | ||
963 | 667 | (p1[0] * (float) screen->width ())) / | ||
964 | 668 | ((v[2] * v[2] * sws) + (v[0] * v[0])); | ||
965 | 669 | |||
966 | 670 | const float rq = (0.25 * p * p) - q; | ||
967 | 671 | const float ph = -p * 0.5; | ||
968 | 672 | |||
969 | 673 | if (rq < 0.0) | ||
970 | 674 | { | ||
971 | 675 | vertex[0] = -1000; | ||
972 | 676 | vertex[1] = -1000; | ||
973 | 677 | return; | ||
974 | 678 | } | ||
975 | 679 | else | ||
976 | 680 | { | ||
977 | 681 | alpha = ph + sqrt(rq); | ||
978 | 682 | if (p1[2] + (alpha * v[2]) > 0.0) | ||
979 | 683 | { | ||
980 | 684 | vertex[0] = -1000; | ||
981 | 685 | vertex[1] = -1000; | ||
982 | 686 | return; | ||
983 | 687 | } | ||
984 | 688 | } | ||
985 | 689 | } | ||
986 | 690 | |||
987 | 691 | vertex[0] = ceil (p1[0] + (alpha * v[0])); | ||
988 | 692 | vertex[1] = ceil (p1[1] + (alpha * v[1])); | ||
989 | 693 | } | ||
990 | 694 | |||
991 | 695 | void | ||
992 | 696 | ExpoScreen::paintWall (const GLScreenPaintAttrib& attrib, | ||
993 | 697 | const GLMatrix& transform, | ||
994 | 698 | const CompRegion& region, | ||
995 | 699 | CompOutput *output, | ||
996 | 700 | unsigned int mask, | ||
997 | 701 | bool reflection) | ||
998 | 702 | { | ||
999 | 703 | GLMatrix sTransformW, sTransform (transform); | ||
1000 | 704 | int i, j, vp; | ||
1001 | 705 | GLenum oldFilter = gScreen->textureFilter (); | ||
1002 | 706 | |||
1003 | 707 | float sx = (float) screen->width () / output->width (); | ||
1004 | 708 | float sy = (float) screen->height () / output->height (); | ||
1005 | 709 | float biasZ; | ||
1006 | 710 | float oScale, rotation = 0.0f, progress, vpp; | ||
1007 | 711 | float aspectX = 1.0f, aspectY = 1.0f; | ||
1008 | 712 | GLVector cam; | ||
1009 | 713 | CompPoint vpSize (screen->vpSize ().width (), screen->vpSize ().height ()); | ||
1010 | 714 | |||
1011 | 715 | /* amount of gap between viewports */ | ||
1012 | 716 | const float gapY = optionGetVpDistance () * 0.1f * expoCam; | ||
1013 | 717 | const float gapX = optionGetVpDistance () * 0.1f * screen->height () / | ||
1014 | 718 | screen->width () * expoCam; | ||
1015 | 719 | |||
1016 | 720 | int glPaintTransformedOutputIndex = | ||
1017 | 721 | gScreen->glPaintTransformedOutputGetCurrentIndex (); | ||
1018 | 722 | |||
1019 | 723 | // Make sure that the base glPaintTransformedOutput function is called | ||
1020 | 724 | gScreen->glPaintTransformedOutputSetCurrentIndex (MAXSHORT); | ||
1021 | 725 | |||
1022 | 726 | /* Zoom animation stuff */ | ||
1023 | 727 | /* camera position for the selected viewport */ | ||
1024 | 728 | GLVector vpCamPos (0, 0, 0, 0); | ||
1025 | 729 | |||
1026 | 730 | /* camera position during expo mode */ | ||
1027 | 731 | GLVector expoCamPos (0, 0, 0, 0); | ||
1028 | 732 | |||
1029 | 733 | if (optionGetDeform () == DeformCurve) | ||
1030 | 734 | { | ||
1031 | 735 | vpCamPos[GLVector::x] = -sx * (0.5 - (((float) output->x () + | ||
1032 | 736 | (output->width () / 2.0)) / | ||
1033 | 737 | (float) screen->width ())); | ||
1034 | 738 | } | ||
1035 | 739 | else | ||
1036 | 740 | { | ||
1037 | 741 | vpCamPos[GLVector::x] = (screen->vp ().x () * sx) + 0.5 + | ||
1038 | 742 | (output->x () / output->width ()) - | ||
1039 | 743 | (vpSize.x () * 0.5 * sx) + | ||
1040 | 744 | gapX * screen->vp ().x (); | ||
1041 | 745 | } | ||
1042 | 746 | vpCamPos[GLVector::y] = -((screen->vp ().y () * sy) + 0.5 + | ||
1043 | 747 | (output->y () / output->height ())) + | ||
1044 | 748 | (vpSize.y () * 0.5 * sy) - | ||
1045 | 749 | gapY * screen->vp ().y (); | ||
1046 | 750 | |||
1047 | 751 | biasZ = MAX (vpSize.x () * sx, vpSize.y () * sy); | ||
1048 | 752 | if (optionGetDeform () == DeformTilt || optionGetReflection ()) | ||
1049 | 753 | biasZ *= (0.15 + optionGetDistance ()); | ||
1050 | 754 | else | ||
1051 | 755 | biasZ *= optionGetDistance (); | ||
1052 | 756 | |||
1053 | 757 | progress = sigmoidProgress (expoCam); | ||
1054 | 758 | |||
1055 | 759 | if (optionGetDeform () != DeformCurve) | ||
1056 | 760 | expoCamPos[GLVector::x] = gapX * (vpSize.x () - 1) * 0.5; | ||
1057 | 761 | |||
1058 | 762 | expoCamPos[GLVector::y] = -gapY * (vpSize.y () - 1) * 0.5; | ||
1059 | 763 | expoCamPos[GLVector::z] = -DEFAULT_Z_CAMERA + DEFAULT_Z_CAMERA * | ||
1060 | 764 | (MAX (vpSize.x () + (vpSize.x () - 1) * gapX, | ||
1061 | 765 | vpSize.y () + (vpSize.y () - 1) * gapY) + | ||
1062 | 766 | biasZ); | ||
1063 | 767 | |||
1064 | 768 | /* interpolate between vpCamPos and expoCamPos */ | ||
1065 | 769 | cam[GLVector::x] = vpCamPos[GLVector::x] * (1 - progress) + | ||
1066 | 770 | expoCamPos[GLVector::x] * progress; | ||
1067 | 771 | cam[GLVector::y] = vpCamPos[GLVector::y] * (1 - progress) + | ||
1068 | 772 | expoCamPos[GLVector::y] * progress; | ||
1069 | 773 | cam[GLVector::z] = vpCamPos[GLVector::z] * (1 - progress) + | ||
1070 | 774 | expoCamPos[GLVector::z] * progress; | ||
1071 | 775 | |||
1072 | 776 | if (vpSize.x () > vpSize.y ()) | ||
1073 | 777 | { | ||
1074 | 778 | aspectY = (float) vpSize.x () / (float) vpSize.y (); | ||
1075 | 779 | aspectY -= 1.0; | ||
1076 | 780 | aspectY *= -optionGetAspectRatio () + 1.0; | ||
1077 | 781 | aspectY *= progress; | ||
1078 | 782 | aspectY += 1.0; | ||
1079 | 783 | } | ||
1080 | 784 | else | ||
1081 | 785 | { | ||
1082 | 786 | aspectX = (float) vpSize.y () / (float) vpSize.x (); | ||
1083 | 787 | aspectX -= 1.0; | ||
1084 | 788 | aspectX *= -optionGetAspectRatio () + 1.0; | ||
1085 | 789 | aspectX *= progress; | ||
1086 | 790 | aspectX += 1.0; | ||
1087 | 791 | } | ||
1088 | 792 | |||
1089 | 793 | /* End of Zoom animation stuff */ | ||
1090 | 794 | |||
1091 | 795 | if (optionGetDeform () == DeformTilt) | ||
1092 | 796 | { | ||
1093 | 797 | if (optionGetExpoAnimation () == ExpoAnimationZoom) | ||
1094 | 798 | rotation = 10.0 * sigmoidProgress (expoCam); | ||
1095 | 799 | else | ||
1096 | 800 | rotation = 10.0 * expoCam; | ||
1097 | 801 | } | ||
1098 | 802 | |||
1099 | 803 | if (optionGetMipmaps ()) | ||
1100 | 804 | gScreen->setTextureFilter (GL_LINEAR_MIPMAP_LINEAR); | ||
1101 | 805 | |||
1102 | 806 | /* ALL TRANSFORMATION ARE EXECUTED FROM BOTTOM TO TOP */ | ||
1103 | 807 | |||
1104 | 808 | oScale = 1 / (1 + ((MAX (sx, sy) - 1) * progress)); | ||
1105 | 809 | |||
1106 | 810 | sTransform.scale (oScale, oScale, 1.0); | ||
1107 | 811 | |||
1108 | 812 | /* zoom out */ | ||
1109 | 813 | oScale = DEFAULT_Z_CAMERA / (cam[GLVector::z] + DEFAULT_Z_CAMERA); | ||
1110 | 814 | sTransform.scale (oScale, oScale, oScale); | ||
1111 | 815 | glNormal3f (0.0, 0.0, -oScale); | ||
1112 | 816 | sTransform.translate (-cam[GLVector::x], -cam[GLVector::y], | ||
1113 | 817 | -cam[GLVector::z] - DEFAULT_Z_CAMERA); | ||
1114 | 818 | |||
1115 | 819 | if (reflection) | ||
1116 | 820 | { | ||
1117 | 821 | float scaleFactor = optionGetScaleFactor (); | ||
1118 | 822 | |||
1119 | 823 | sTransform.translate (0.0, | ||
1120 | 824 | (vpSize.y () + ((vpSize.y () - 1) * gapY * 2)) * | ||
1121 | 825 | -sy * aspectY, | ||
1122 | 826 | 0.0); | ||
1123 | 827 | sTransform.scale (1.0, -1.0, 1.0); | ||
1124 | 828 | sTransform.translate (0.0, | ||
1125 | 829 | - (1 - scaleFactor) / 2 * sy * aspectY * | ||
1126 | 830 | (vpSize.y () + ((vpSize.y () - 1) * gapY * 2)), | ||
1127 | 831 | 0.0); | ||
1128 | 832 | sTransform.scale (1.0, scaleFactor, 1.0); | ||
1129 | 833 | glCullFace (GL_FRONT); | ||
1130 | 834 | } | ||
1131 | 835 | |||
1132 | 836 | /* rotate */ | ||
1133 | 837 | sTransform.rotate (rotation, 0.0f, 1.0f, 0.0f); | ||
1134 | 838 | sTransform.scale (aspectX, aspectY, 1.0); | ||
1135 | 839 | |||
1136 | 840 | /* translate expo to center */ | ||
1137 | 841 | sTransform.translate (vpSize.x () * sx * -0.5, | ||
1138 | 842 | vpSize.y () * sy * 0.5, 0.0f); | ||
1139 | 843 | |||
1140 | 844 | if (optionGetDeform () == DeformCurve) | ||
1141 | 845 | sTransform.translate ((vpSize.x () - 1) * sx * 0.5, 0.0, 0.0); | ||
1142 | 846 | |||
1143 | 847 | sTransformW = sTransform; | ||
1144 | 848 | |||
1145 | 849 | /* revert prepareXCoords region shift. Now all screens display the same */ | ||
1146 | 850 | sTransform.translate (0.5f, -0.5f, DEFAULT_Z_CAMERA); | ||
1147 | 851 | |||
1148 | 852 | if (vpSize.x () > 2) | ||
1149 | 853 | /* we can't have 90 degree for the left/right most viewport */ | ||
1150 | 854 | curveAngle = interpolate (359 / ((vpSize.x () - 1) * 2), 1, | ||
1151 | 855 | optionGetCurve ()); | ||
1152 | 856 | else | ||
1153 | 857 | curveAngle = interpolate (180 / vpSize.x (), 1, optionGetCurve ()); | ||
1154 | 858 | |||
1155 | 859 | curveDistance = ((0.5f * sx) + (gapX / 2.0)) / | ||
1156 | 860 | tanf ((M_PI / 180.0f) * curveAngle / 2.0); | ||
1157 | 861 | curveRadius = ((0.5f * sx) + (gapX / 2.0)) / | ||
1158 | 862 | sinf ((M_PI / 180.0f) * curveAngle / 2.0); | ||
1159 | 863 | |||
1160 | 864 | expoActive = true; | ||
1161 | 865 | |||
1162 | 866 | for (j = 0; j < vpSize.y (); j++) | ||
1163 | 867 | { | ||
1164 | 868 | GLMatrix sTransform2 (sTransform), sTransform3; | ||
1165 | 869 | |||
1166 | 870 | for (i = 0; i < vpSize.x (); i++) | ||
1167 | 871 | { | ||
1168 | 872 | if (optionGetExpoAnimation () == ExpoAnimationVortex) | ||
1169 | 873 | sTransform2.rotate (360 * expoCam, | ||
1170 | 874 | 0.0f, 1.0f, 2.0f * expoCam); | ||
1171 | 875 | |||
1172 | 876 | sTransform3 = sTransform2; | ||
1173 | 877 | |||
1174 | 878 | sTransform3.translate (output->x () / output->width (), | ||
1175 | 879 | -output->y () / output->height (), 0.0); | ||
1176 | 880 | |||
1177 | 881 | cScreen->setWindowPaintOffset ((screen->vp ().x () - i) * | ||
1178 | 882 | screen->width (), | ||
1179 | 883 | (screen->vp ().y () - j) * | ||
1180 | 884 | screen->height ()); | ||
1181 | 885 | |||
1182 | 886 | vp = (j * vpSize.x ()) + i; | ||
1183 | 887 | |||
1184 | 888 | vpp = (expoCam * vpActivity[vp]) + (1 - expoCam); | ||
1185 | 889 | vpp = sigmoidProgress (vpp); | ||
1186 | 890 | |||
1187 | 891 | vpBrightness = vpp + ((1.0 - vpp) * | ||
1188 | 892 | optionGetVpBrightness () / 100.0); | ||
1189 | 893 | vpSaturation = vpp + ((1.0 - vpp) * | ||
1190 | 894 | optionGetVpSaturation () / 100.0); | ||
1191 | 895 | |||
1192 | 896 | paintingVp.set (i, j); | ||
1193 | 897 | |||
1194 | 898 | if (optionGetDeform () == DeformCurve) | ||
1195 | 899 | { | ||
1196 | 900 | float rotateX; | ||
1197 | 901 | |||
1198 | 902 | sTransform3.translate (-vpCamPos[GLVector::x], 0.0f, | ||
1199 | 903 | curveDistance - DEFAULT_Z_CAMERA); | ||
1200 | 904 | |||
1201 | 905 | rotateX = -i + interpolate (((float) vpSize.x () / 2.0) - 0.5, | ||
1202 | 906 | screen->vp ().x (), progress); | ||
1203 | 907 | |||
1204 | 908 | sTransform3.rotate (curveAngle * rotateX, 0.0, 1.0, 0.0); | ||
1205 | 909 | |||
1206 | 910 | sTransform3.translate (vpCamPos[GLVector::x], 0.0f, | ||
1207 | 911 | DEFAULT_Z_CAMERA - curveDistance); | ||
1208 | 912 | } | ||
1209 | 913 | |||
1210 | 914 | gScreen->glPaintTransformedOutput (attrib, sTransform3, | ||
1211 | 915 | screen->region (), output, | ||
1212 | 916 | mask); | ||
1213 | 917 | |||
1214 | 918 | if (!reflection) | ||
1215 | 919 | { | ||
1216 | 920 | int cursor[2] = { pointerX, pointerY }; | ||
1217 | 921 | |||
1218 | 922 | invertTransformedVertex (attrib, sTransform3, | ||
1219 | 923 | output, cursor); | ||
1220 | 924 | |||
1221 | 925 | if ((cursor[0] > 0) && (cursor[0] < (int) screen->width ()) && | ||
1222 | 926 | (cursor[1] > 0) && (cursor[1] < (int) screen->height ())) | ||
1223 | 927 | { | ||
1224 | 928 | newCursor.setX (i * screen->width () + cursor[0]); | ||
1225 | 929 | newCursor.setY (j * screen->height () + cursor[1]); | ||
1226 | 930 | |||
1227 | 931 | if (anyClick || dndState != DnDNone) | ||
1228 | 932 | { | ||
1229 | 933 | /* Used to save last viewport interaction was in */ | ||
1230 | 934 | lastSelectedVp = selectedVp; | ||
1231 | 935 | selectedVp.set (i, j); | ||
1232 | 936 | anyClick = false; | ||
1233 | 937 | } | ||
1234 | 938 | } | ||
1235 | 939 | } | ||
1236 | 940 | |||
1237 | 941 | /* not sure this will work with different resolutions */ | ||
1238 | 942 | if (optionGetDeform () != DeformCurve) | ||
1239 | 943 | sTransform2.translate (sx + gapX, 0.0f, 0.0); | ||
1240 | 944 | } | ||
1241 | 945 | |||
1242 | 946 | /* not sure this will work with different resolutions */ | ||
1243 | 947 | sTransform.translate (0.0, -(sy + gapY), 0.0f); | ||
1244 | 948 | } | ||
1245 | 949 | |||
1246 | 950 | glNormal3f (0.0, 0.0, -1.0); | ||
1247 | 951 | |||
1248 | 952 | if (reflection) | ||
1249 | 953 | { | ||
1250 | 954 | glEnable (GL_BLEND); | ||
1251 | 955 | glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); | ||
1252 | 956 | |||
1253 | 957 | glPushMatrix (); | ||
1254 | 958 | |||
1255 | 959 | if (optionGetDeform () != DeformCurve) | ||
1256 | 960 | { | ||
1257 | 961 | glLoadMatrixf (sTransformW.getMatrix ()); | ||
1258 | 962 | |||
1259 | 963 | glBegin (GL_QUADS); | ||
1260 | 964 | glColor4f (0.0, 0.0, 0.0, 1.0); | ||
1261 | 965 | glVertex2f (0.0, 0.0); | ||
1262 | 966 | glColor4f (0.0, 0.0, 0.0, 0.5); | ||
1263 | 967 | glVertex2f (0.0, -vpSize.y () * (sy + gapY)); | ||
1264 | 968 | glVertex2f (vpSize.x () * sx * (1.0 + gapX), | ||
1265 | 969 | -vpSize.y () * sy * (1.0 + gapY)); | ||
1266 | 970 | glColor4f (0.0, 0.0, 0.0, 1.0); | ||
1267 | 971 | glVertex2f (vpSize.x () * sx * (1.0 + gapX), 0.0); | ||
1268 | 972 | glEnd (); | ||
1269 | 973 | } | ||
1270 | 974 | else | ||
1271 | 975 | { | ||
1272 | 976 | glCullFace (GL_BACK); | ||
1273 | 977 | glLoadIdentity (); | ||
1274 | 978 | glTranslatef (0.0, 0.0, -DEFAULT_Z_CAMERA); | ||
1275 | 979 | |||
1276 | 980 | glBegin (GL_QUADS); | ||
1277 | 981 | glColor4f (0.0, 0.0, 0.0, 1.0 * expoCam); | ||
1278 | 982 | glVertex2f (-0.5, -0.5); | ||
1279 | 983 | glVertex2f (0.5, -0.5); | ||
1280 | 984 | glColor4f (0.0, 0.0, 0.0, 0.5 * expoCam); | ||
1281 | 985 | glVertex2f (0.5, 0.0); | ||
1282 | 986 | glVertex2f (-0.5, 0.0); | ||
1283 | 987 | glColor4f (0.0, 0.0, 0.0, 0.5 * expoCam); | ||
1284 | 988 | glVertex2f (-0.5, 0.0); | ||
1285 | 989 | glVertex2f (0.5, 0.0); | ||
1286 | 990 | glColor4f (0.0, 0.0, 0.0, 0.0); | ||
1287 | 991 | glVertex2f (0.5, 0.5); | ||
1288 | 992 | glVertex2f (-0.5, 0.5); | ||
1289 | 993 | glEnd (); | ||
1290 | 994 | } | ||
1291 | 995 | glCullFace (GL_BACK); | ||
1292 | 996 | |||
1293 | 997 | glLoadIdentity (); | ||
1294 | 998 | glTranslatef (0.0, 0.0, -DEFAULT_Z_CAMERA); | ||
1295 | 999 | |||
1296 | 1000 | if (optionGetGroundSize () > 0.0) | ||
1297 | 1001 | { | ||
1298 | 1002 | glBegin (GL_QUADS); | ||
1299 | 1003 | glColor4usv (optionGetGroundColor1 ()); | ||
1300 | 1004 | glVertex2f (-0.5, -0.5); | ||
1301 | 1005 | glVertex2f (0.5, -0.5); | ||
1302 | 1006 | glColor4usv (optionGetGroundColor2 ()); | ||
1303 | 1007 | glVertex2f (0.5, -0.5 + optionGetGroundSize ()); | ||
1304 | 1008 | glVertex2f (-0.5, -0.5 + optionGetGroundSize ()); | ||
1305 | 1009 | glEnd (); | ||
1306 | 1010 | } | ||
1307 | 1011 | |||
1308 | 1012 | glColor4usv (defaultColor); | ||
1309 | 1013 | |||
1310 | 1014 | glBlendFunc (GL_ONE, GL_ONE_MINUS_SRC_ALPHA); | ||
1311 | 1015 | glDisable (GL_BLEND); | ||
1312 | 1016 | glPopMatrix (); | ||
1313 | 1017 | } | ||
1314 | 1018 | |||
1315 | 1019 | expoActive = false; | ||
1316 | 1020 | |||
1317 | 1021 | cScreen->setWindowPaintOffset (0, 0); | ||
1318 | 1022 | |||
1319 | 1023 | gScreen->glPaintTransformedOutputSetCurrentIndex (glPaintTransformedOutputIndex); | ||
1320 | 1024 | gScreen->setTextureFilter (oldFilter); | ||
1321 | 1025 | } | ||
1322 | 1026 | |||
1323 | 1027 | bool | ||
1324 | 1028 | ExpoScreen::glPaintOutput (const GLScreenPaintAttrib& attrib, | ||
1325 | 1029 | const GLMatrix& transform, | ||
1326 | 1030 | const CompRegion& region, | ||
1327 | 1031 | CompOutput *output, | ||
1328 | 1032 | unsigned int mask) | ||
1329 | 1033 | { | ||
1330 | 1034 | if (expoCam > 0.0) | ||
1331 | 1035 | mask |= PAINT_SCREEN_TRANSFORMED_MASK | PAINT_SCREEN_CLEAR_MASK; | ||
1332 | 1036 | |||
1333 | 1037 | return gScreen->glPaintOutput (attrib, transform, region, output, mask); | ||
1334 | 1038 | } | ||
1335 | 1039 | |||
1336 | 1040 | void | ||
1337 | 1041 | ExpoScreen::glPaintTransformedOutput (const GLScreenPaintAttrib& attrib, | ||
1338 | 1042 | const GLMatrix& transform, | ||
1339 | 1043 | const CompRegion& region, | ||
1340 | 1044 | CompOutput *output, | ||
1341 | 1045 | unsigned int mask) | ||
1342 | 1046 | { | ||
1343 | 1047 | expoActive = false; | ||
1344 | 1048 | |||
1345 | 1049 | if (expoCam > 0) | ||
1346 | 1050 | mask |= PAINT_SCREEN_CLEAR_MASK; | ||
1347 | 1051 | |||
1348 | 1052 | if (expoCam <= 0 || (expoCam > 0.0 && expoCam < 1.0 && | ||
1349 | 1053 | optionGetExpoAnimation () != ExpoAnimationZoom)) | ||
1350 | 1054 | { | ||
1351 | 1055 | gScreen->glPaintTransformedOutput (attrib, transform, region, | ||
1352 | 1056 | output, mask); | ||
1353 | 1057 | } | ||
1354 | 1058 | else | ||
1355 | 1059 | { | ||
1356 | 1060 | gScreen->clearOutput (output, GL_COLOR_BUFFER_BIT); | ||
1357 | 1061 | } | ||
1358 | 1062 | |||
1359 | 1063 | mask &= ~PAINT_SCREEN_CLEAR_MASK; | ||
1360 | 1064 | |||
1361 | 1065 | if (expoCam > 0.0) | ||
1362 | 1066 | { | ||
1363 | 1067 | if (optionGetReflection ()) | ||
1364 | 1068 | paintWall (attrib, transform, region, output, mask, true); | ||
1365 | 1069 | |||
1366 | 1070 | paintWall (attrib, transform, region, output, mask, false); | ||
1367 | 1071 | anyClick = false; | ||
1368 | 1072 | } | ||
1369 | 1073 | } | ||
1370 | 1074 | |||
1371 | 1075 | bool | ||
1372 | 1076 | ExpoWindow::glDraw (const GLMatrix& transform, | ||
1373 | 1077 | GLFragment::Attrib& fragment, | ||
1374 | 1078 | const CompRegion& region, | ||
1375 | 1079 | unsigned int mask) | ||
1376 | 1080 | { | ||
1377 | 1081 | if (eScreen->expoCam == 0.0f) | ||
1378 | 1082 | return gWindow->glDraw (transform, fragment, region, mask); | ||
1379 | 1083 | |||
1380 | 1084 | GLFragment::Attrib fA (fragment); | ||
1381 | 1085 | int expoAnimation; | ||
1382 | 1086 | |||
1383 | 1087 | expoAnimation = eScreen->optionGetExpoAnimation (); | ||
1384 | 1088 | |||
1385 | 1089 | if (eScreen->expoActive) | ||
1386 | 1090 | { | ||
1387 | 1091 | if (expoAnimation != ExpoScreen::ExpoAnimationZoom) | ||
1388 | 1092 | fA.setOpacity (fragment.getOpacity () * eScreen->expoCam); | ||
1389 | 1093 | |||
1390 | 1094 | if (window->wmType () & CompWindowTypeDockMask && | ||
1391 | 1095 | eScreen->optionGetHideDocks ()) | ||
1392 | 1096 | { | ||
1393 | 1097 | if (expoAnimation == ExpoScreen::ExpoAnimationZoom && | ||
1394 | 1098 | eScreen->paintingVp == eScreen->selectedVp) | ||
1395 | 1099 | { | ||
1396 | 1100 | fA.setOpacity (fragment.getOpacity () * | ||
1397 | 1101 | (1 - sigmoidProgress (eScreen->expoCam))); | ||
1398 | 1102 | } | ||
1399 | 1103 | else | ||
1400 | 1104 | { | ||
1401 | 1105 | fA.setOpacity (0); | ||
1402 | 1106 | } | ||
1403 | 1107 | } | ||
1404 | 1108 | |||
1405 | 1109 | fA.setBrightness (fragment.getBrightness () * eScreen->vpBrightness); | ||
1406 | 1110 | fA.setSaturation (fragment.getSaturation () * eScreen->vpSaturation); | ||
1407 | 1111 | } | ||
1408 | 1112 | else | ||
1409 | 1113 | { | ||
1410 | 1114 | if (expoAnimation == ExpoScreen::ExpoAnimationZoom) | ||
1411 | 1115 | fA.setBrightness (0); | ||
1412 | 1116 | else | ||
1413 | 1117 | fA.setBrightness (fragment.getBrightness () * | ||
1414 | 1118 | (1 - sigmoidProgress (eScreen->expoCam))); | ||
1415 | 1119 | } | ||
1416 | 1120 | |||
1417 | 1121 | return gWindow->glDraw (transform, fA, region, mask); | ||
1418 | 1122 | } | ||
1419 | 1123 | |||
1420 | 1124 | #define EXPO_GRID_SIZE 100 | ||
1421 | 1125 | |||
1422 | 1126 | void | ||
1423 | 1127 | ExpoWindow::glAddGeometry (const GLTexture::MatrixList& matrices, | ||
1424 | 1128 | const CompRegion& region, | ||
1425 | 1129 | const CompRegion& clip, | ||
1426 | 1130 | unsigned int maxGridWidth, | ||
1427 | 1131 | unsigned int maxGridHeight) | ||
1428 | 1132 | { | ||
1429 | 1133 | if (eScreen->expoCam > 0.0 && | ||
1430 | 1134 | screen->desktopWindowCount () && | ||
1431 | 1135 | eScreen->optionGetDeform () == ExpoScreen::DeformCurve) | ||
1432 | 1136 | { | ||
1433 | 1137 | int i, oldVCount = gWindow->geometry ().vCount; | ||
1434 | 1138 | GLfloat *v; | ||
1435 | 1139 | CompPoint offset; | ||
1436 | 1140 | float lastX, lastZ = 0.0; | ||
1437 | 1141 | const float radSquare = pow (eScreen->curveDistance, 2) + 0.25; | ||
1438 | 1142 | float ang; | ||
1439 | 1143 | |||
1440 | 1144 | gWindow->glAddGeometry (matrices, region, clip, | ||
1441 | 1145 | MIN(maxGridWidth , EXPO_GRID_SIZE), | ||
1442 | 1146 | maxGridHeight); | ||
1443 | 1147 | |||
1444 | 1148 | v = gWindow->geometry ().vertices; | ||
1445 | 1149 | v += gWindow->geometry ().vertexStride - 3; | ||
1446 | 1150 | v += gWindow->geometry ().vertexStride * oldVCount; | ||
1447 | 1151 | |||
1448 | 1152 | if (!window->onAllViewports ()) | ||
1449 | 1153 | { | ||
1450 | 1154 | offset = eScreen->cScreen->windowPaintOffset (); | ||
1451 | 1155 | offset = window->getMovementForOffset (offset); | ||
1452 | 1156 | } | ||
1453 | 1157 | |||
1454 | 1158 | lastX = -1000000000.0; | ||
1455 | 1159 | |||
1456 | 1160 | for (i = oldVCount; i < gWindow->geometry ().vCount; i++) | ||
1457 | 1161 | { | ||
1458 | 1162 | if (v[0] == lastX) | ||
1459 | 1163 | { | ||
1460 | 1164 | v[2] = lastZ; | ||
1461 | 1165 | } | ||
1462 | 1166 | else if (v[0] + offset.x () >= -EXPO_GRID_SIZE && | ||
1463 | 1167 | v[0] + offset.x () < screen->width () + EXPO_GRID_SIZE) | ||
1464 | 1168 | { | ||
1465 | 1169 | ang = (((v[0] + offset.x ()) / (float) screen->width ()) - 0.5); | ||
1466 | 1170 | ang *= ang; | ||
1467 | 1171 | if (ang < radSquare) | ||
1468 | 1172 | { | ||
1469 | 1173 | v[2] = eScreen->curveDistance - sqrt (radSquare - ang); | ||
1470 | 1174 | v[2] *= sigmoidProgress (eScreen->expoCam); | ||
1471 | 1175 | } | ||
1472 | 1176 | } | ||
1473 | 1177 | |||
1474 | 1178 | lastX = v[0]; | ||
1475 | 1179 | lastZ = v[2]; | ||
1476 | 1180 | |||
1477 | 1181 | v += gWindow->geometry ().vertexStride; | ||
1478 | 1182 | } | ||
1479 | 1183 | } | ||
1480 | 1184 | else | ||
1481 | 1185 | { | ||
1482 | 1186 | gWindow->glAddGeometry (matrices, region, clip, maxGridWidth, maxGridHeight); | ||
1483 | 1187 | } | ||
1484 | 1188 | } | ||
1485 | 1189 | |||
1486 | 1190 | void | ||
1487 | 1191 | ExpoWindow::glDrawTexture (GLTexture *texture, | ||
1488 | 1192 | GLFragment::Attrib& attrib, | ||
1489 | 1193 | unsigned int mask) | ||
1490 | 1194 | { | ||
1491 | 1195 | if (eScreen->expoCam > 0.0 && | ||
1492 | 1196 | eScreen->optionGetDeform () == ExpoScreen::DeformCurve && | ||
1493 | 1197 | eScreen->gScreen->lighting () && | ||
1494 | 1198 | screen->desktopWindowCount ()) | ||
1495 | 1199 | { | ||
1496 | 1200 | unsigned int i, idx, vCount; | ||
1497 | 1201 | CompPoint offset; | ||
1498 | 1202 | float x; | ||
1499 | 1203 | GLfloat *v; | ||
1500 | 1204 | |||
1501 | 1205 | vCount = gWindow->geometry ().vCount; | ||
1502 | 1206 | |||
1503 | 1207 | if (eScreen->winNormals.size () < vCount * 3) | ||
1504 | 1208 | eScreen->winNormals.resize (vCount * 3); | ||
1505 | 1209 | |||
1506 | 1210 | if (!window->onAllViewports ()) | ||
1507 | 1211 | { | ||
1508 | 1212 | offset = eScreen->cScreen->windowPaintOffset (); | ||
1509 | 1213 | offset = window->getMovementForOffset (offset); | ||
1510 | 1214 | } | ||
1511 | 1215 | |||
1512 | 1216 | v = gWindow->geometry ().vertices + | ||
1513 | 1217 | (gWindow->geometry ().vertexStride - 3); | ||
1514 | 1218 | |||
1515 | 1219 | for (i = 0; i < vCount; i++) | ||
1516 | 1220 | { | ||
1517 | 1221 | x = (float) (v[0] + offset.x () - screen->width () / 2) * | ||
1518 | 1222 | eScreen->curveAngle / screen->width (); | ||
1519 | 1223 | |||
1520 | 1224 | while (x < 0) | ||
1521 | 1225 | x += 360.0; | ||
1522 | 1226 | |||
1523 | 1227 | idx = floor (x); | ||
1524 | 1228 | |||
1525 | 1229 | eScreen->winNormals[i * 3] = -eScreen->vpNormals[idx * 3]; | ||
1526 | 1230 | eScreen->winNormals[(i * 3) + 1] = | ||
1527 | 1231 | eScreen->vpNormals[(idx * 3) + 1]; | ||
1528 | 1232 | eScreen->winNormals[(i * 3) + 2] = | ||
1529 | 1233 | eScreen->vpNormals[(idx * 3) + 2]; | ||
1530 | 1234 | |||
1531 | 1235 | v += gWindow->geometry ().vertexStride; | ||
1532 | 1236 | } | ||
1533 | 1237 | |||
1534 | 1238 | glEnable (GL_NORMALIZE); | ||
1535 | 1239 | glNormalPointer (GL_FLOAT,0, &eScreen->winNormals.at (0)); | ||
1536 | 1240 | |||
1537 | 1241 | glEnableClientState (GL_NORMAL_ARRAY); | ||
1538 | 1242 | |||
1539 | 1243 | gWindow->glDrawTexture (texture, attrib, mask); | ||
1540 | 1244 | |||
1541 | 1245 | glDisable (GL_NORMALIZE); | ||
1542 | 1246 | glDisableClientState (GL_NORMAL_ARRAY); | ||
1543 | 1247 | glNormal3f (0.0, 0.0, -1.0); | ||
1544 | 1248 | } | ||
1545 | 1249 | else | ||
1546 | 1250 | { | ||
1547 | 1251 | glEnable (GL_NORMALIZE); | ||
1548 | 1252 | gWindow->glDrawTexture (texture, attrib, mask); | ||
1549 | 1253 | glDisable (GL_NORMALIZE); | ||
1550 | 1254 | } | ||
1551 | 1255 | } | ||
1552 | 1256 | |||
1553 | 1257 | bool | ||
1554 | 1258 | ExpoWindow::glPaint (const GLWindowPaintAttrib& attrib, | ||
1555 | 1259 | const GLMatrix& transform, | ||
1556 | 1260 | const CompRegion& region, | ||
1557 | 1261 | unsigned int mask) | ||
1558 | 1262 | { | ||
1559 | 1263 | if (eScreen->expoActive) | ||
1560 | 1264 | { | ||
1561 | 1265 | float opacity = 1.0; | ||
1562 | 1266 | bool hide; | ||
1563 | 1267 | bool zoomAnim; | ||
1564 | 1268 | |||
1565 | 1269 | zoomAnim = eScreen->optionGetExpoAnimation () == | ||
1566 | 1270 | ExpoScreen::ExpoAnimationZoom; | ||
1567 | 1271 | hide = eScreen->optionGetHideDocks () && | ||
1568 | 1272 | (window->wmType () & CompWindowTypeDockMask); | ||
1569 | 1273 | |||
1570 | 1274 | if (eScreen->expoCam > 0.0) | ||
1571 | 1275 | { | ||
1572 | 1276 | if (eScreen->expoCam < 1.0 && !zoomAnim) | ||
1573 | 1277 | mask |= PAINT_WINDOW_TRANSLUCENT_MASK; | ||
1574 | 1278 | else if (hide) | ||
1575 | 1279 | mask |= PAINT_WINDOW_TRANSLUCENT_MASK; | ||
1576 | 1280 | } | ||
1577 | 1281 | |||
1578 | 1282 | if (!zoomAnim) | ||
1579 | 1283 | opacity = attrib.opacity * eScreen->expoCam; | ||
1580 | 1284 | |||
1581 | 1285 | if (hide) | ||
1582 | 1286 | { | ||
1583 | 1287 | if (zoomAnim && eScreen->paintingVp == eScreen->selectedVp) | ||
1584 | 1288 | opacity = attrib.opacity * | ||
1585 | 1289 | (1 - sigmoidProgress (eScreen->expoCam)); | ||
1586 | 1290 | else | ||
1587 | 1291 | opacity = 0; | ||
1588 | 1292 | } | ||
1589 | 1293 | |||
1590 | 1294 | if (opacity <= 0) | ||
1591 | 1295 | mask |= PAINT_WINDOW_NO_CORE_INSTANCE_MASK; | ||
1592 | 1296 | } | ||
1593 | 1297 | |||
1594 | 1298 | return gWindow->glPaint (attrib, transform, region, mask); | ||
1595 | 1299 | } | ||
1596 | 1300 | |||
1597 | 1301 | bool | ||
1598 | 1302 | ExpoWindow::damageRect (bool initial, | ||
1599 | 1303 | const CompRect& rect) | ||
1600 | 1304 | { | ||
1601 | 1305 | if (eScreen->expoCam > 0.0f) | ||
1602 | 1306 | eScreen->cScreen->damageScreen (); | ||
1603 | 1307 | |||
1604 | 1308 | return cWindow->damageRect (initial, rect); | ||
1605 | 1309 | } | ||
1606 | 1310 | |||
1607 | 1311 | #define EXPOINITBIND(opt, func) \ | ||
1608 | 1312 | optionSet##opt##Initiate (boost::bind (&ExpoScreen::func, \ | ||
1609 | 1313 | this, _1, _2, _3)); | ||
1610 | 1314 | #define EXPOTERMBIND(opt, func) \ | ||
1611 | 1315 | optionSet##opt##Terminate (boost::bind (&ExpoScreen::func, \ | ||
1612 | 1316 | this, _1, _2, _3)); | ||
1613 | 1317 | |||
1614 | 1318 | ExpoScreen::ExpoScreen (CompScreen *s) : | ||
1615 | 1319 | PluginClassHandler<ExpoScreen, CompScreen> (s), | ||
1616 | 1320 | ExpoOptions (), | ||
1617 | 1321 | cScreen (CompositeScreen::get (s)), | ||
1618 | 1322 | gScreen (GLScreen::get (s)), | ||
1619 | 1323 | expoCam (0.0f), | ||
1620 | 1324 | expoActive (false), | ||
1621 | 1325 | expoMode (false), | ||
1622 | 1326 | dndState (DnDNone), | ||
1623 | 1327 | dndWindow (NULL), | ||
1624 | 1328 | origVp (s->vp ()), | ||
1625 | 1329 | selectedVp (s->vp ()), | ||
1626 | 1330 | lastSelectedVp (s->vp ()), | ||
1627 | 1331 | vpUpdateMode (VPUpdateNone), | ||
1628 | 1332 | clickTime (0), | ||
1629 | 1333 | doubleClick (false), | ||
1630 | 1334 | vpNormals (360 * 3), | ||
1631 | 1335 | grabIndex (0) | ||
1632 | 1336 | { | ||
1633 | 1337 | leftKey = XKeysymToKeycode (s->dpy (), XStringToKeysym ("Left")); | ||
1634 | 1338 | rightKey = XKeysymToKeycode (s->dpy (), XStringToKeysym ("Right")); | ||
1635 | 1339 | upKey = XKeysymToKeycode (s->dpy (), XStringToKeysym ("Up")); | ||
1636 | 1340 | downKey = XKeysymToKeycode (s->dpy (), XStringToKeysym ("Down")); | ||
1637 | 1341 | |||
1638 | 1342 | EXPOINITBIND (ExpoKey, doExpo); | ||
1639 | 1343 | EXPOTERMBIND (ExpoKey, termExpo); | ||
1640 | 1344 | EXPOINITBIND (ExpoButton, doExpo); | ||
1641 | 1345 | EXPOTERMBIND (ExpoButton, termExpo); | ||
1642 | 1346 | EXPOINITBIND (ExpoEdge, doExpo); | ||
1643 | 1347 | EXPOTERMBIND (ExpoButton, termExpo); | ||
1644 | 1348 | |||
1645 | 1349 | EXPOINITBIND (DndButton, dndInit); | ||
1646 | 1350 | EXPOTERMBIND (DndButton, dndFini); | ||
1647 | 1351 | EXPOINITBIND (ExitButton, exitExpo); | ||
1648 | 1352 | EXPOINITBIND (NextVpButton, nextVp); | ||
1649 | 1353 | EXPOINITBIND (PrevVpButton, prevVp); | ||
1650 | 1354 | |||
1651 | 1355 | ScreenInterface::setHandler (screen, false); | ||
1652 | 1356 | CompositeScreenInterface::setHandler (cScreen, false); | ||
1653 | 1357 | GLScreenInterface::setHandler (gScreen, false); | ||
1654 | 1358 | } | ||
1655 | 1359 | |||
1656 | 1360 | ExpoWindow::ExpoWindow (CompWindow *w) : | ||
1657 | 1361 | PluginClassHandler<ExpoWindow, CompWindow> (w), | ||
1658 | 1362 | window (w), | ||
1659 | 1363 | cWindow (CompositeWindow::get (w)), | ||
1660 | 1364 | gWindow (GLWindow::get (w)), | ||
1661 | 1365 | eScreen (ExpoScreen::get (screen)) | ||
1662 | 1366 | { | ||
1663 | 1367 | CompositeWindowInterface::setHandler (cWindow, false); | ||
1664 | 1368 | GLWindowInterface::setHandler (gWindow, false); | ||
1665 | 1369 | } | ||
1666 | 1370 | |||
1667 | 1371 | bool | ||
1668 | 1372 | ExpoPluginVTable::init () | ||
1669 | 1373 | { | ||
1670 | 1374 | if (!CompPlugin::checkPluginABI ("core", CORE_ABIVERSION) || | ||
1671 | 1375 | !CompPlugin::checkPluginABI ("composite", COMPIZ_COMPOSITE_ABI) || | ||
1672 | 1376 | !CompPlugin::checkPluginABI ("opengl", COMPIZ_OPENGL_ABI)) | ||
1673 | 1377 | return false; | ||
1674 | 1378 | |||
1675 | 1379 | return true; | ||
1676 | 1380 | } | ||
1677 | 1381 | |||
1678 | 1382 | |||
1679 | 1383 | 0 | ||
1680 | === removed file '.pc/expo.patch/expo/src/expo.h' | |||
1681 | --- .pc/expo.patch/expo/src/expo.h 2012-02-13 15:30:29 +0000 | |||
1682 | +++ .pc/expo.patch/expo/src/expo.h 1970-01-01 00:00:00 +0000 | |||
1683 | @@ -1,163 +0,0 @@ | |||
1684 | 1 | /** | ||
1685 | 2 | * | ||
1686 | 3 | * Compiz expo plugin | ||
1687 | 4 | * | ||
1688 | 5 | * expo.c | ||
1689 | 6 | * | ||
1690 | 7 | * Copyright (c) 2008 Dennis Kasprzyk <racarr@opencompositing.org> | ||
1691 | 8 | * Copyright (c) 2006 Robert Carr <racarr@beryl-project.org> | ||
1692 | 9 | * | ||
1693 | 10 | * Authors: | ||
1694 | 11 | * Robert Carr <racarr@beryl-project.org> | ||
1695 | 12 | * Dennis Kasprzyk <onestone@opencompositing.org> | ||
1696 | 13 | * | ||
1697 | 14 | * This program is free software; you can redistribute it and/or | ||
1698 | 15 | * modify it under the terms of the GNU General Public License | ||
1699 | 16 | * as published by the Free Software Foundation; either version 2 | ||
1700 | 17 | * of the License, or (at your option) any later version. | ||
1701 | 18 | * | ||
1702 | 19 | * This program is distributed in the hope that it will be useful, | ||
1703 | 20 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
1704 | 21 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
1705 | 22 | * GNU General Public License for more details. | ||
1706 | 23 | * | ||
1707 | 24 | **/ | ||
1708 | 25 | |||
1709 | 26 | #include <core/core.h> | ||
1710 | 27 | #include <core/pluginclasshandler.h> | ||
1711 | 28 | |||
1712 | 29 | #include <composite/composite.h> | ||
1713 | 30 | #include <opengl/opengl.h> | ||
1714 | 31 | |||
1715 | 32 | #include "expo_options.h" | ||
1716 | 33 | |||
1717 | 34 | class ExpoScreen : | ||
1718 | 35 | public ScreenInterface, | ||
1719 | 36 | public CompositeScreenInterface, | ||
1720 | 37 | public GLScreenInterface, | ||
1721 | 38 | public PluginClassHandler<ExpoScreen, CompScreen>, | ||
1722 | 39 | public ExpoOptions | ||
1723 | 40 | { | ||
1724 | 41 | public: | ||
1725 | 42 | ExpoScreen (CompScreen *); | ||
1726 | 43 | |||
1727 | 44 | void handleEvent (XEvent *); | ||
1728 | 45 | |||
1729 | 46 | void preparePaint (int); | ||
1730 | 47 | void paint (CompOutput::ptrList&, unsigned int); | ||
1731 | 48 | void donePaint (); | ||
1732 | 49 | |||
1733 | 50 | bool glPaintOutput (const GLScreenPaintAttrib&, const GLMatrix&, | ||
1734 | 51 | const CompRegion&, CompOutput *, unsigned int); | ||
1735 | 52 | void glPaintTransformedOutput (const GLScreenPaintAttrib&, | ||
1736 | 53 | const GLMatrix&, const CompRegion&, | ||
1737 | 54 | CompOutput *, unsigned int); | ||
1738 | 55 | |||
1739 | 56 | bool dndInit (CompAction *, CompAction::State, CompOption::Vector&); | ||
1740 | 57 | bool dndFini (CompAction *, CompAction::State, CompOption::Vector&); | ||
1741 | 58 | bool doExpo (CompAction *, CompAction::State, CompOption::Vector&); | ||
1742 | 59 | bool exitExpo (CompAction *, CompAction::State, CompOption::Vector&); | ||
1743 | 60 | bool termExpo (CompAction *, CompAction::State, CompOption::Vector&); | ||
1744 | 61 | bool nextVp (CompAction *, CompAction::State, CompOption::Vector&); | ||
1745 | 62 | bool prevVp (CompAction *, CompAction::State, CompOption::Vector&); | ||
1746 | 63 | |||
1747 | 64 | typedef enum { | ||
1748 | 65 | DnDNone, | ||
1749 | 66 | DnDDuring, | ||
1750 | 67 | DnDStart | ||
1751 | 68 | } DnDState; | ||
1752 | 69 | |||
1753 | 70 | typedef enum { | ||
1754 | 71 | VPUpdateNone, | ||
1755 | 72 | VPUpdateMouseOver, | ||
1756 | 73 | VPUpdatePrevious | ||
1757 | 74 | } VPUpdateMode; | ||
1758 | 75 | |||
1759 | 76 | CompositeScreen *cScreen; | ||
1760 | 77 | GLScreen *gScreen; | ||
1761 | 78 | |||
1762 | 79 | float expoCam; | ||
1763 | 80 | bool expoActive; | ||
1764 | 81 | bool expoMode; | ||
1765 | 82 | |||
1766 | 83 | DnDState dndState; | ||
1767 | 84 | CompWindow *dndWindow; | ||
1768 | 85 | |||
1769 | 86 | CompPoint prevCursor; | ||
1770 | 87 | CompPoint newCursor; | ||
1771 | 88 | |||
1772 | 89 | CompPoint origVp; | ||
1773 | 90 | CompPoint selectedVp; | ||
1774 | 91 | CompPoint lastSelectedVp; | ||
1775 | 92 | CompPoint paintingVp; | ||
1776 | 93 | |||
1777 | 94 | std::vector<float> vpActivity; | ||
1778 | 95 | float vpBrightness; | ||
1779 | 96 | float vpSaturation; | ||
1780 | 97 | |||
1781 | 98 | VPUpdateMode vpUpdateMode; | ||
1782 | 99 | |||
1783 | 100 | bool anyClick; | ||
1784 | 101 | unsigned int clickTime; | ||
1785 | 102 | bool doubleClick; | ||
1786 | 103 | |||
1787 | 104 | CompRegion tmpRegion; | ||
1788 | 105 | |||
1789 | 106 | float curveAngle; | ||
1790 | 107 | float curveDistance; | ||
1791 | 108 | float curveRadius; | ||
1792 | 109 | |||
1793 | 110 | std::vector<GLfloat> vpNormals; | ||
1794 | 111 | std::vector<GLfloat> winNormals; | ||
1795 | 112 | |||
1796 | 113 | CompScreen::GrabHandle grabIndex; | ||
1797 | 114 | |||
1798 | 115 | private: | ||
1799 | 116 | void moveFocusViewport (int, int); | ||
1800 | 117 | void finishWindowMovement (); | ||
1801 | 118 | void updateWraps (bool); | ||
1802 | 119 | |||
1803 | 120 | void invertTransformedVertex (const GLScreenPaintAttrib&, | ||
1804 | 121 | const GLMatrix&, CompOutput *, int[2]); | ||
1805 | 122 | void paintWall (const GLScreenPaintAttrib&, const GLMatrix&, | ||
1806 | 123 | const CompRegion&, CompOutput *, unsigned int, bool); | ||
1807 | 124 | |||
1808 | 125 | KeyCode leftKey; | ||
1809 | 126 | KeyCode rightKey; | ||
1810 | 127 | KeyCode upKey; | ||
1811 | 128 | KeyCode downKey; | ||
1812 | 129 | }; | ||
1813 | 130 | |||
1814 | 131 | class ExpoWindow : | ||
1815 | 132 | public CompositeWindowInterface, | ||
1816 | 133 | public GLWindowInterface, | ||
1817 | 134 | public PluginClassHandler<ExpoWindow, CompWindow> | ||
1818 | 135 | { | ||
1819 | 136 | public: | ||
1820 | 137 | ExpoWindow (CompWindow *); | ||
1821 | 138 | |||
1822 | 139 | bool damageRect (bool, const CompRect&); | ||
1823 | 140 | |||
1824 | 141 | bool glDraw (const GLMatrix&, GLFragment::Attrib&, | ||
1825 | 142 | const CompRegion&, unsigned int); | ||
1826 | 143 | bool glPaint (const GLWindowPaintAttrib&, const GLMatrix&, | ||
1827 | 144 | const CompRegion&, unsigned int); | ||
1828 | 145 | void glAddGeometry (const GLTexture::MatrixList&, | ||
1829 | 146 | const CompRegion&, const CompRegion&, | ||
1830 | 147 | unsigned int, unsigned int); | ||
1831 | 148 | void glDrawTexture (GLTexture *, GLFragment::Attrib& attrib, | ||
1832 | 149 | unsigned int); | ||
1833 | 150 | |||
1834 | 151 | CompWindow *window; | ||
1835 | 152 | CompositeWindow *cWindow; | ||
1836 | 153 | GLWindow *gWindow; | ||
1837 | 154 | ExpoScreen *eScreen; | ||
1838 | 155 | }; | ||
1839 | 156 | |||
1840 | 157 | class ExpoPluginVTable : | ||
1841 | 158 | public CompPlugin::VTableForScreenAndWindow<ExpoScreen, ExpoWindow> | ||
1842 | 159 | { | ||
1843 | 160 | public: | ||
1844 | 161 | bool init (); | ||
1845 | 162 | }; | ||
1846 | 163 | |||
1847 | 164 | 0 | ||
1848 | === removed file '.pc/expo.patch/expo/src/glow.cpp' | |||
1849 | === removed file '.pc/expo.patch/expo/src/glow.h' | |||
1850 | === removed file '.pc/expo.patch/expo/src/group_glow.h' | |||
1851 | === removed file '.pc/expo.patch/glow.cpp' | |||
1852 | === removed file '.pc/expo.patch/glow.h' | |||
1853 | === removed file '.pc/expo.patch/group_glow.h' | |||
1854 | === removed directory '.pc/expo_api_931927.patch' | |||
1855 | === removed directory '.pc/expo_api_931927.patch/expo' | |||
1856 | === removed directory '.pc/expo_api_931927.patch/expo/src' | |||
1857 | === removed file '.pc/expo_api_931927.patch/expo/src/expo.cpp' | |||
1858 | --- .pc/expo_api_931927.patch/expo/src/expo.cpp 2012-02-16 15:14:05 +0000 | |||
1859 | +++ .pc/expo_api_931927.patch/expo/src/expo.cpp 1970-01-01 00:00:00 +0000 | |||
1860 | @@ -1,1692 +0,0 @@ | |||
1861 | 1 | /** | ||
1862 | 2 | * | ||
1863 | 3 | * Compiz expo plugin | ||
1864 | 4 | * | ||
1865 | 5 | * expo.c | ||
1866 | 6 | * | ||
1867 | 7 | * Copyright (c) 2008 Dennis Kasprzyk <racarr@opencompositing.org> | ||
1868 | 8 | * Copyright (c) 2006 Robert Carr <racarr@beryl-project.org> | ||
1869 | 9 | * | ||
1870 | 10 | * Authors: | ||
1871 | 11 | * Robert Carr <racarr@beryl-project.org> | ||
1872 | 12 | * Dennis Kasprzyk <onestone@opencompositing.org> | ||
1873 | 13 | * | ||
1874 | 14 | * This program is free software; you can redistribute it and/or | ||
1875 | 15 | * modify it under the terms of the GNU General Public License | ||
1876 | 16 | * as published by the Free Software Foundation; either version 2 | ||
1877 | 17 | * of the License, or (at your option) any later version. | ||
1878 | 18 | * | ||
1879 | 19 | * This program is distributed in the hope that it will be useful, | ||
1880 | 20 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
1881 | 21 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
1882 | 22 | * GNU General Public License for more details. | ||
1883 | 23 | * | ||
1884 | 24 | **/ | ||
1885 | 25 | |||
1886 | 26 | #include "expo.h" | ||
1887 | 27 | #include <math.h> | ||
1888 | 28 | #include <GL/glu.h> | ||
1889 | 29 | #include <X11/cursorfont.h> | ||
1890 | 30 | |||
1891 | 31 | COMPIZ_PLUGIN_20090315 (expo, ExpoPluginVTable); | ||
1892 | 32 | |||
1893 | 33 | #define sigmoid(x) (1.0f / (1.0f + exp (-5.5f * 2 * ((x) - 0.5)))) | ||
1894 | 34 | #define sigmoidProgress(x) ((sigmoid (x) - sigmoid (0)) / \ | ||
1895 | 35 | (sigmoid (1) - sigmoid (0))) | ||
1896 | 36 | |||
1897 | 37 | #define interpolate(a, b, val) (((val) * (a)) + ((1 - (val)) * (b))) | ||
1898 | 38 | |||
1899 | 39 | bool | ||
1900 | 40 | ExpoScreen::dndInit (CompAction *action, | ||
1901 | 41 | CompAction::State state, | ||
1902 | 42 | CompOption::Vector& options) | ||
1903 | 43 | { | ||
1904 | 44 | Window xid = CompOption::getIntOptionNamed (options, "root", 0); | ||
1905 | 45 | if (xid != screen->root ()) | ||
1906 | 46 | return false; | ||
1907 | 47 | |||
1908 | 48 | if (expoMode) | ||
1909 | 49 | { | ||
1910 | 50 | dndState = DnDStart; | ||
1911 | 51 | action->setState (action->state () | CompAction::StateTermButton); | ||
1912 | 52 | cScreen->damageScreen (); | ||
1913 | 53 | |||
1914 | 54 | return true; | ||
1915 | 55 | } | ||
1916 | 56 | |||
1917 | 57 | return false; | ||
1918 | 58 | } | ||
1919 | 59 | |||
1920 | 60 | bool | ||
1921 | 61 | ExpoScreen::dndFini (CompAction *action, | ||
1922 | 62 | CompAction::State state, | ||
1923 | 63 | CompOption::Vector& options) | ||
1924 | 64 | { | ||
1925 | 65 | Window xid = CompOption::getIntOptionNamed (options, "root", 0); | ||
1926 | 66 | if (xid != screen->root ()) | ||
1927 | 67 | return false; | ||
1928 | 68 | |||
1929 | 69 | if (dndState == DnDDuring || dndState == DnDStart) | ||
1930 | 70 | { | ||
1931 | 71 | if (dndWindows.size ()) | ||
1932 | 72 | finishWindowMovement (); | ||
1933 | 73 | |||
1934 | 74 | dndState = DnDNone; | ||
1935 | 75 | |||
1936 | 76 | action->setState (action->state () & CompAction::StateInitButton); | ||
1937 | 77 | cScreen->damageScreen (); | ||
1938 | 78 | |||
1939 | 79 | return true; | ||
1940 | 80 | } | ||
1941 | 81 | |||
1942 | 82 | return false; | ||
1943 | 83 | } | ||
1944 | 84 | |||
1945 | 85 | bool | ||
1946 | 86 | ExpoScreen::doExpo (CompAction *action, | ||
1947 | 87 | CompAction::State state, | ||
1948 | 88 | CompOption::Vector& options) | ||
1949 | 89 | { | ||
1950 | 90 | Window xid = CompOption::getIntOptionNamed (options, "root", 0); | ||
1951 | 91 | if (xid != screen->root ()) | ||
1952 | 92 | return false; | ||
1953 | 93 | |||
1954 | 94 | if (screen->otherGrabExist ("expo", NULL)) | ||
1955 | 95 | return false; | ||
1956 | 96 | |||
1957 | 97 | if (!expoMode) | ||
1958 | 98 | { | ||
1959 | 99 | if (!grabIndex) | ||
1960 | 100 | grabIndex = screen->pushGrab (None, "expo"); | ||
1961 | 101 | |||
1962 | 102 | updateWraps (true); | ||
1963 | 103 | |||
1964 | 104 | expoMode = true; | ||
1965 | 105 | anyClick = false; | ||
1966 | 106 | doubleClick = false; | ||
1967 | 107 | clickTime = 0; | ||
1968 | 108 | |||
1969 | 109 | dndState = DnDNone; | ||
1970 | 110 | |||
1971 | 111 | selectedVp = screen->vp (); | ||
1972 | 112 | origVp = screen->vp (); | ||
1973 | 113 | |||
1974 | 114 | screen->addAction (&optionGetDndButton ()); | ||
1975 | 115 | screen->addAction (&optionGetExitButton ()); | ||
1976 | 116 | screen->addAction (&optionGetNextVpButton ()); | ||
1977 | 117 | screen->addAction (&optionGetPrevVpButton ()); | ||
1978 | 118 | |||
1979 | 119 | cScreen->damageScreen (); | ||
1980 | 120 | } | ||
1981 | 121 | else | ||
1982 | 122 | { | ||
1983 | 123 | termExpo (action, state, options); | ||
1984 | 124 | } | ||
1985 | 125 | |||
1986 | 126 | return true; | ||
1987 | 127 | } | ||
1988 | 128 | |||
1989 | 129 | bool | ||
1990 | 130 | ExpoScreen::termExpo (CompAction *action, | ||
1991 | 131 | CompAction::State state, | ||
1992 | 132 | CompOption::Vector& options) | ||
1993 | 133 | { | ||
1994 | 134 | Window xid = CompOption::getIntOptionNamed (options, "root", 0); | ||
1995 | 135 | if (xid && xid != screen->root ()) | ||
1996 | 136 | return false; | ||
1997 | 137 | |||
1998 | 138 | if (!expoMode) | ||
1999 | 139 | return true; | ||
2000 | 140 | |||
2001 | 141 | expoMode = false; | ||
2002 | 142 | |||
2003 | 143 | if (dndState != DnDNone) | ||
2004 | 144 | dndFini (action, state, options); | ||
2005 | 145 | |||
2006 | 146 | if (state & CompAction::StateCancel) | ||
2007 | 147 | vpUpdateMode = VPUpdatePrevious; | ||
2008 | 148 | else | ||
2009 | 149 | vpUpdateMode = VPUpdateMouseOver; | ||
2010 | 150 | |||
2011 | 151 | screen->removeAction (&optionGetDndButton ()); | ||
2012 | 152 | screen->removeAction (&optionGetExitButton ()); | ||
2013 | 153 | screen->removeAction (&optionGetNextVpButton ()); | ||
2014 | 154 | screen->removeAction (&optionGetPrevVpButton ()); | ||
2015 | 155 | |||
2016 | 156 | cScreen->damageScreen (); | ||
2017 | 157 | screen->focusDefaultWindow (); | ||
2018 | 158 | |||
2019 | 159 | return true; | ||
2020 | 160 | } | ||
2021 | 161 | |||
2022 | 162 | bool | ||
2023 | 163 | ExpoScreen::exitExpo (CompAction *action, | ||
2024 | 164 | CompAction::State state, | ||
2025 | 165 | CompOption::Vector& options) | ||
2026 | 166 | { | ||
2027 | 167 | Window xid = CompOption::getIntOptionNamed (options, "root", 0); | ||
2028 | 168 | if (xid != screen->root ()) | ||
2029 | 169 | return false; | ||
2030 | 170 | |||
2031 | 171 | if (!expoMode) | ||
2032 | 172 | return false; | ||
2033 | 173 | |||
2034 | 174 | termExpo (action, 0, noOptions); | ||
2035 | 175 | anyClick = true; | ||
2036 | 176 | cScreen->damageScreen (); | ||
2037 | 177 | |||
2038 | 178 | return true; | ||
2039 | 179 | } | ||
2040 | 180 | |||
2041 | 181 | bool | ||
2042 | 182 | ExpoScreen::nextVp (CompAction *action, | ||
2043 | 183 | CompAction::State state, | ||
2044 | 184 | CompOption::Vector& options) | ||
2045 | 185 | { | ||
2046 | 186 | unsigned int newX, newY; | ||
2047 | 187 | Window xid = CompOption::getIntOptionNamed (options, "root", 0); | ||
2048 | 188 | if (xid != screen->root ()) | ||
2049 | 189 | return false; | ||
2050 | 190 | |||
2051 | 191 | if (!expoMode) | ||
2052 | 192 | return false; | ||
2053 | 193 | |||
2054 | 194 | newX = selectedVp.x () + 1; | ||
2055 | 195 | newY = selectedVp.y (); | ||
2056 | 196 | |||
2057 | 197 | if (newX >= (unsigned int) screen->vpSize ().width ()) | ||
2058 | 198 | { | ||
2059 | 199 | newX = 0; | ||
2060 | 200 | newY = newY + 1; | ||
2061 | 201 | if (newY >= (unsigned int) screen->vpSize ().height ()) | ||
2062 | 202 | newY = 0; | ||
2063 | 203 | } | ||
2064 | 204 | |||
2065 | 205 | moveFocusViewport (newX - selectedVp.x (), | ||
2066 | 206 | newY - selectedVp.y ()); | ||
2067 | 207 | cScreen->damageScreen (); | ||
2068 | 208 | |||
2069 | 209 | return true; | ||
2070 | 210 | } | ||
2071 | 211 | |||
2072 | 212 | bool | ||
2073 | 213 | ExpoScreen::prevVp (CompAction *action, | ||
2074 | 214 | CompAction::State state, | ||
2075 | 215 | CompOption::Vector& options) | ||
2076 | 216 | { | ||
2077 | 217 | unsigned int newX, newY; | ||
2078 | 218 | Window xid = CompOption::getIntOptionNamed (options, "root", 0); | ||
2079 | 219 | if (xid != screen->root ()) | ||
2080 | 220 | return false; | ||
2081 | 221 | |||
2082 | 222 | if (!expoMode) | ||
2083 | 223 | return false; | ||
2084 | 224 | |||
2085 | 225 | newX = selectedVp.x () - 1; | ||
2086 | 226 | newY = selectedVp.y (); | ||
2087 | 227 | |||
2088 | 228 | if (newX < 0) | ||
2089 | 229 | { | ||
2090 | 230 | newX = screen->vpSize ().width () - 1; | ||
2091 | 231 | newY = newY - 1; | ||
2092 | 232 | if (newY < 0) | ||
2093 | 233 | newY = screen->vpSize ().height () - 1; | ||
2094 | 234 | } | ||
2095 | 235 | |||
2096 | 236 | moveFocusViewport (newX - selectedVp.x (), | ||
2097 | 237 | newY - selectedVp.y ()); | ||
2098 | 238 | cScreen->damageScreen (); | ||
2099 | 239 | |||
2100 | 240 | return true; | ||
2101 | 241 | } | ||
2102 | 242 | |||
2103 | 243 | void | ||
2104 | 244 | ExpoScreen::moveFocusViewport (int dx, | ||
2105 | 245 | int dy) | ||
2106 | 246 | { | ||
2107 | 247 | int newX, newY; | ||
2108 | 248 | |||
2109 | 249 | newX = selectedVp.x () + dx; | ||
2110 | 250 | newY = selectedVp.y () + dy; | ||
2111 | 251 | |||
2112 | 252 | newX = MAX (0, MIN ((int) screen->vpSize ().width () - 1, newX)); | ||
2113 | 253 | newY = MAX (0, MIN ((int) screen->vpSize ().height () - 1, newY)); | ||
2114 | 254 | |||
2115 | 255 | selectedVp.set (newX, newY); | ||
2116 | 256 | cScreen->damageScreen (); | ||
2117 | 257 | } | ||
2118 | 258 | |||
2119 | 259 | void | ||
2120 | 260 | ExpoScreen::finishWindowMovement () | ||
2121 | 261 | { | ||
2122 | 262 | foreach (CompWindow *dndWindow, dndWindows) | ||
2123 | 263 | { | ||
2124 | 264 | if (dndWindow->grabbed ()) | ||
2125 | 265 | { | ||
2126 | 266 | dndWindow->syncPosition (); | ||
2127 | 267 | dndWindow->ungrabNotify (); | ||
2128 | 268 | |||
2129 | 269 | screen->updateGrab (grabIndex, None); | ||
2130 | 270 | |||
2131 | 271 | screen->moveViewport (screen->vp ().x () - selectedVp.x (), | ||
2132 | 272 | screen->vp ().y () - selectedVp.y (), true); | ||
2133 | 273 | |||
2134 | 274 | /* update saved window attributes in case we moved the | ||
2135 | 275 | window to a new viewport */ | ||
2136 | 276 | if (dndWindow->saveMask () & CWX) | ||
2137 | 277 | { | ||
2138 | 278 | dndWindow->saveWc ().x = dndWindow->saveWc ().x % screen->width (); | ||
2139 | 279 | if (dndWindow->saveWc ().x < 0) | ||
2140 | 280 | dndWindow->saveWc ().x += screen->width (); | ||
2141 | 281 | } | ||
2142 | 282 | if (dndWindow->saveMask () & CWY) | ||
2143 | 283 | { | ||
2144 | 284 | dndWindow->saveWc ().y = dndWindow->saveWc ().y % screen->height (); | ||
2145 | 285 | if (dndWindow->saveWc ().y < 0) | ||
2146 | 286 | dndWindow->saveWc ().y += screen->height (); | ||
2147 | 287 | } | ||
2148 | 288 | |||
2149 | 289 | /* update window attibutes to make sure a moved maximized window | ||
2150 | 290 | is properly snapped to the work area */ | ||
2151 | 291 | if (dndWindow->state () & MAXIMIZE_STATE) | ||
2152 | 292 | dndWindow->updateAttributes (CompStackingUpdateModeNone); | ||
2153 | 293 | } | ||
2154 | 294 | } | ||
2155 | 295 | } | ||
2156 | 296 | |||
2157 | 297 | void | ||
2158 | 298 | ExpoScreen::handleEvent (XEvent *event) | ||
2159 | 299 | { | ||
2160 | 300 | switch (event->type) { | ||
2161 | 301 | case KeyPress: | ||
2162 | 302 | if (expoMode && event->xkey.root == screen->root ()) | ||
2163 | 303 | { | ||
2164 | 304 | if (event->xkey.keycode == leftKey) | ||
2165 | 305 | moveFocusViewport (-1, 0); | ||
2166 | 306 | else if (event->xkey.keycode == rightKey) | ||
2167 | 307 | moveFocusViewport (1, 0); | ||
2168 | 308 | else if (event->xkey.keycode == upKey) | ||
2169 | 309 | moveFocusViewport (0, -1); | ||
2170 | 310 | else if (event->xkey.keycode == downKey) | ||
2171 | 311 | moveFocusViewport (0, 1); | ||
2172 | 312 | } | ||
2173 | 313 | break; | ||
2174 | 314 | |||
2175 | 315 | case ButtonPress: | ||
2176 | 316 | if (expoMode && event->xbutton.button == Button1 && | ||
2177 | 317 | event->xbutton.root == screen->root ()) | ||
2178 | 318 | { | ||
2179 | 319 | anyClick = true; | ||
2180 | 320 | if (clickTime == 0) | ||
2181 | 321 | { | ||
2182 | 322 | clickTime = event->xbutton.time; | ||
2183 | 323 | } | ||
2184 | 324 | else if (event->xbutton.time - clickTime <= | ||
2185 | 325 | (unsigned int) optionGetDoubleClickTime ()) | ||
2186 | 326 | { | ||
2187 | 327 | doubleClick = true; | ||
2188 | 328 | } | ||
2189 | 329 | else | ||
2190 | 330 | { | ||
2191 | 331 | clickTime = event->xbutton.time; | ||
2192 | 332 | doubleClick = false; | ||
2193 | 333 | } | ||
2194 | 334 | cScreen->damageScreen (); | ||
2195 | 335 | } | ||
2196 | 336 | break; | ||
2197 | 337 | |||
2198 | 338 | case ButtonRelease: | ||
2199 | 339 | if (expoMode && event->xbutton.button == Button1 && | ||
2200 | 340 | event->xbutton.root == screen->root ()) | ||
2201 | 341 | { | ||
2202 | 342 | if (event->xbutton.time - clickTime > | ||
2203 | 343 | (unsigned int) optionGetDoubleClickTime ()) | ||
2204 | 344 | { | ||
2205 | 345 | clickTime = 0; | ||
2206 | 346 | doubleClick = false; | ||
2207 | 347 | } | ||
2208 | 348 | else if (doubleClick) | ||
2209 | 349 | { | ||
2210 | 350 | CompAction& action = optionGetExpoKey (); | ||
2211 | 351 | |||
2212 | 352 | clickTime = 0; | ||
2213 | 353 | doubleClick = false; | ||
2214 | 354 | |||
2215 | 355 | termExpo (&action, 0, noOptions); | ||
2216 | 356 | anyClick = true; | ||
2217 | 357 | } | ||
2218 | 358 | } | ||
2219 | 359 | break; | ||
2220 | 360 | } | ||
2221 | 361 | |||
2222 | 362 | screen->handleEvent (event); | ||
2223 | 363 | } | ||
2224 | 364 | |||
2225 | 365 | bool | ||
2226 | 366 | ExpoScreen::windowsOnVp (CompPoint &p) | ||
2227 | 367 | { | ||
2228 | 368 | foreach (CompWindow *w, screen->clientList (true)) | ||
2229 | 369 | { | ||
2230 | 370 | CompPoint viewport; | ||
2231 | 371 | |||
2232 | 372 | screen->viewportForGeometry (w->geometry (), viewport); | ||
2233 | 373 | |||
2234 | 374 | if (viewport == p&& | ||
2235 | 375 | w->type () != CompWindowTypeDesktopMask && | ||
2236 | 376 | w->type () != CompWindowTypeDockMask) | ||
2237 | 377 | { | ||
2238 | 378 | return true; | ||
2239 | 379 | } | ||
2240 | 380 | } | ||
2241 | 381 | |||
2242 | 382 | return false; | ||
2243 | 383 | } | ||
2244 | 384 | |||
2245 | 385 | void | ||
2246 | 386 | ExpoScreen::preparePaint (int msSinceLastPaint) | ||
2247 | 387 | { | ||
2248 | 388 | float val = ((float) msSinceLastPaint / 1000.0) / optionGetZoomTime (); | ||
2249 | 389 | |||
2250 | 390 | if (expoMode) | ||
2251 | 391 | expoCam = MIN (1.0, expoCam + val); | ||
2252 | 392 | else | ||
2253 | 393 | expoCam = MAX (0.0, expoCam - val); | ||
2254 | 394 | |||
2255 | 395 | if (dndState == DnDDuring) | ||
2256 | 396 | { | ||
2257 | 397 | foreach (CompWindow *w, dndWindows) | ||
2258 | 398 | ExpoWindow::get (w)->dndOpacity = MIN (1.0, ExpoWindow::get (w)->dndOpacity + val); | ||
2259 | 399 | } | ||
2260 | 400 | else if (dndState == DnDNone) | ||
2261 | 401 | { | ||
2262 | 402 | CompWindowList::iterator it = dndWindows.begin (); | ||
2263 | 403 | |||
2264 | 404 | while (it != dndWindows.end ()) | ||
2265 | 405 | { | ||
2266 | 406 | ExpoWindow::get ((*it))->dndOpacity = MAX (0.0, ExpoWindow::get ((*it))->dndOpacity - val); | ||
2267 | 407 | |||
2268 | 408 | if (ExpoWindow::get ((*it))->dndOpacity <= 0.0f) | ||
2269 | 409 | { | ||
2270 | 410 | dndWindows.erase (it); | ||
2271 | 411 | it = dndWindows.begin (); | ||
2272 | 412 | } | ||
2273 | 413 | else | ||
2274 | 414 | it++; | ||
2275 | 415 | } | ||
2276 | 416 | } | ||
2277 | 417 | |||
2278 | 418 | if (expoCam) | ||
2279 | 419 | { | ||
2280 | 420 | unsigned int i, j, vp; | ||
2281 | 421 | unsigned int vpCount = screen->vpSize ().width () * | ||
2282 | 422 | screen->vpSize ().height (); | ||
2283 | 423 | |||
2284 | 424 | if (vpActivity.size () < vpCount) | ||
2285 | 425 | { | ||
2286 | 426 | vpActivity.resize (vpCount); | ||
2287 | 427 | foreach (float& activity, vpActivity) | ||
2288 | 428 | activity = 1.0f; | ||
2289 | 429 | } | ||
2290 | 430 | |||
2291 | 431 | for (i = 0; i < (unsigned int) screen->vpSize ().width (); i++) | ||
2292 | 432 | { | ||
2293 | 433 | for (j = 0; j < (unsigned int) screen->vpSize ().height (); j++) | ||
2294 | 434 | { | ||
2295 | 435 | vp = (j * screen->vpSize ().width ()) + i; | ||
2296 | 436 | CompPoint vpPos = CompPoint (i, j); | ||
2297 | 437 | |||
2298 | 438 | if (windowsOnVp (vpPos)) | ||
2299 | 439 | vpActivity[vp] = MIN (1.0, vpActivity[vp] + val); | ||
2300 | 440 | else | ||
2301 | 441 | vpActivity[vp] = MAX (0.0, vpActivity[vp] - val); | ||
2302 | 442 | } | ||
2303 | 443 | } | ||
2304 | 444 | |||
2305 | 445 | for (i = 0; i < 360; i++) | ||
2306 | 446 | { | ||
2307 | 447 | float fi = (float) i; | ||
2308 | 448 | |||
2309 | 449 | vpNormals[i * 3] = (-sin (fi * (M_PI / 180.0f)) / screen->width ()) * | ||
2310 | 450 | expoCam; | ||
2311 | 451 | vpNormals[(i * 3) + 1] = 0.0; | ||
2312 | 452 | vpNormals[(i * 3) + 2] = (-cos (fi * (M_PI / 180.0f)) * expoCam) - | ||
2313 | 453 | (1 - expoCam); | ||
2314 | 454 | } | ||
2315 | 455 | } | ||
2316 | 456 | |||
2317 | 457 | cScreen->preparePaint (msSinceLastPaint); | ||
2318 | 458 | } | ||
2319 | 459 | |||
2320 | 460 | void | ||
2321 | 461 | ExpoScreen::updateWraps (bool enable) | ||
2322 | 462 | { | ||
2323 | 463 | screen->handleEventSetEnabled (this, enable); | ||
2324 | 464 | cScreen->preparePaintSetEnabled (this, enable); | ||
2325 | 465 | cScreen->paintSetEnabled (this, enable); | ||
2326 | 466 | cScreen->donePaintSetEnabled (this, enable); | ||
2327 | 467 | gScreen->glPaintOutputSetEnabled (this, enable); | ||
2328 | 468 | gScreen->glPaintTransformedOutputSetEnabled (this, enable); | ||
2329 | 469 | |||
2330 | 470 | foreach (CompWindow *w, screen->windows ()) | ||
2331 | 471 | { | ||
2332 | 472 | ExpoWindow *ew = ExpoWindow::get (w); | ||
2333 | 473 | |||
2334 | 474 | ew->cWindow->damageRectSetEnabled (ew, enable); | ||
2335 | 475 | ew->gWindow->glPaintSetEnabled (ew, enable); | ||
2336 | 476 | ew->gWindow->glDrawSetEnabled (ew, enable); | ||
2337 | 477 | ew->gWindow->glAddGeometrySetEnabled (ew, enable); | ||
2338 | 478 | ew->gWindow->glDrawTextureSetEnabled (ew, enable); | ||
2339 | 479 | } | ||
2340 | 480 | } | ||
2341 | 481 | |||
2342 | 482 | void | ||
2343 | 483 | ExpoScreen::paint (CompOutput::ptrList& outputs, | ||
2344 | 484 | unsigned int mask) | ||
2345 | 485 | { | ||
2346 | 486 | int width = outputs.front ()->width (); | ||
2347 | 487 | int height = outputs.front ()->height (); | ||
2348 | 488 | bool sizeDiff = false; | ||
2349 | 489 | |||
2350 | 490 | /* "One big wall" does not make sense where outputs are different | ||
2351 | 491 | * sizes, so force multiple walls in this case | ||
2352 | 492 | * | ||
2353 | 493 | * TODO: Is it possible to re-create "one big wall" using | ||
2354 | 494 | * independent output painting in this case? */ | ||
2355 | 495 | |||
2356 | 496 | foreach (CompOutput *o, outputs) | ||
2357 | 497 | { | ||
2358 | 498 | if (o->width () != width || o->height () != height) | ||
2359 | 499 | { | ||
2360 | 500 | sizeDiff = true; | ||
2361 | 501 | break; | ||
2362 | 502 | } | ||
2363 | 503 | } | ||
2364 | 504 | |||
2365 | 505 | if (expoCam > 0.0 && outputs.size () > 1 && | ||
2366 | 506 | optionGetMultioutputMode () == MultioutputModeOneBigWall && | ||
2367 | 507 | !sizeDiff) | ||
2368 | 508 | { | ||
2369 | 509 | outputs.clear (); | ||
2370 | 510 | outputs.push_back (&screen->fullscreenOutput ()); | ||
2371 | 511 | } | ||
2372 | 512 | |||
2373 | 513 | cScreen->paint (outputs, mask); | ||
2374 | 514 | } | ||
2375 | 515 | |||
2376 | 516 | void | ||
2377 | 517 | ExpoScreen::donePaint () | ||
2378 | 518 | { | ||
2379 | 519 | switch (vpUpdateMode) { | ||
2380 | 520 | case VPUpdateMouseOver: | ||
2381 | 521 | screen->moveViewport (screen->vp ().x () - selectedVp.x (), | ||
2382 | 522 | screen->vp ().y () - selectedVp.y (), true); | ||
2383 | 523 | screen->focusDefaultWindow (); | ||
2384 | 524 | vpUpdateMode = VPUpdateNone; | ||
2385 | 525 | break; | ||
2386 | 526 | case VPUpdatePrevious: | ||
2387 | 527 | screen->moveViewport (screen->vp ().x () - origVp.x (), | ||
2388 | 528 | screen->vp ().y () - origVp.y (), true); | ||
2389 | 529 | selectedVp = origVp; | ||
2390 | 530 | screen->focusDefaultWindow (); | ||
2391 | 531 | vpUpdateMode = VPUpdateNone; | ||
2392 | 532 | break; | ||
2393 | 533 | default: | ||
2394 | 534 | break; | ||
2395 | 535 | } | ||
2396 | 536 | |||
2397 | 537 | if ((expoCam > 0.0f && expoCam < 1.0f) || dndState != DnDNone) | ||
2398 | 538 | cScreen->damageScreen (); | ||
2399 | 539 | |||
2400 | 540 | if (expoCam == 1.0f) | ||
2401 | 541 | { | ||
2402 | 542 | foreach (float& vp, vpActivity) | ||
2403 | 543 | if (vp != 0.0 && vp != 1.0) | ||
2404 | 544 | cScreen->damageScreen (); | ||
2405 | 545 | |||
2406 | 546 | foreach (CompWindow *w, dndWindows) | ||
2407 | 547 | if (ExpoWindow::get (w)->dndOpacity != 0.0f && | ||
2408 | 548 | ExpoWindow::get (w)->dndOpacity != 1.0f) | ||
2409 | 549 | cScreen->damageScreen (); | ||
2410 | 550 | } | ||
2411 | 551 | |||
2412 | 552 | if (grabIndex && expoCam <= 0.0f && !expoMode) | ||
2413 | 553 | { | ||
2414 | 554 | screen->removeGrab (grabIndex, NULL); | ||
2415 | 555 | grabIndex = 0; | ||
2416 | 556 | updateWraps (false); | ||
2417 | 557 | } | ||
2418 | 558 | |||
2419 | 559 | cScreen->donePaint (); | ||
2420 | 560 | |||
2421 | 561 | switch (dndState) { | ||
2422 | 562 | case DnDDuring: | ||
2423 | 563 | { | ||
2424 | 564 | if (dndWindows.size ()) | ||
2425 | 565 | { | ||
2426 | 566 | foreach (CompWindow *dndWindow, dndWindows) | ||
2427 | 567 | { | ||
2428 | 568 | if (dndWindow->grabbed ()) | ||
2429 | 569 | { | ||
2430 | 570 | dndWindow->move (newCursor.x () - prevCursor.x (), | ||
2431 | 571 | newCursor.y () - prevCursor.y (), | ||
2432 | 572 | optionGetExpoImmediateMove ()); | ||
2433 | 573 | } | ||
2434 | 574 | } | ||
2435 | 575 | } | ||
2436 | 576 | |||
2437 | 577 | prevCursor = newCursor; | ||
2438 | 578 | cScreen->damageScreen (); | ||
2439 | 579 | } | ||
2440 | 580 | break; | ||
2441 | 581 | |||
2442 | 582 | case DnDStart: | ||
2443 | 583 | { | ||
2444 | 584 | int xOffset, yOffset; | ||
2445 | 585 | CompWindowList::reverse_iterator iter; | ||
2446 | 586 | |||
2447 | 587 | xOffset = screen->vpSize ().width () * screen->width (); | ||
2448 | 588 | yOffset = screen->vpSize ().height () * screen->height (); | ||
2449 | 589 | |||
2450 | 590 | dndState = DnDNone; | ||
2451 | 591 | |||
2452 | 592 | for (iter = screen->windows ().rbegin (); | ||
2453 | 593 | iter != screen->windows ().rend (); ++iter) | ||
2454 | 594 | { | ||
2455 | 595 | CompWindow *w = *iter; | ||
2456 | 596 | CompRect input (w->inputRect ()); | ||
2457 | 597 | bool inWindow; | ||
2458 | 598 | int nx, ny; | ||
2459 | 599 | |||
2460 | 600 | if (w->destroyed ()) | ||
2461 | 601 | continue; | ||
2462 | 602 | |||
2463 | 603 | if (!w->shaded () && !w->isViewable ()) | ||
2464 | 604 | continue; | ||
2465 | 605 | |||
2466 | 606 | if (w->onAllViewports ()) | ||
2467 | 607 | { | ||
2468 | 608 | nx = (newCursor.x () + xOffset) % screen->width (); | ||
2469 | 609 | ny = (newCursor.y () + yOffset) % screen->height (); | ||
2470 | 610 | } | ||
2471 | 611 | else | ||
2472 | 612 | { | ||
2473 | 613 | nx = newCursor.x () - | ||
2474 | 614 | (screen->vp ().x () * screen->width ()); | ||
2475 | 615 | ny = newCursor.y () - | ||
2476 | 616 | (screen->vp ().y () * screen->height ()); | ||
2477 | 617 | } | ||
2478 | 618 | |||
2479 | 619 | inWindow = (nx >= input.left () && nx <= input.right ()) || | ||
2480 | 620 | (nx >= (input.left () + xOffset) && | ||
2481 | 621 | nx <= (input.right () + xOffset)); | ||
2482 | 622 | |||
2483 | 623 | inWindow &= (ny >= input.top () && ny <= input.bottom ()) || | ||
2484 | 624 | (ny >= (input.top () + yOffset) && | ||
2485 | 625 | ny <= (input.bottom () + yOffset)); | ||
2486 | 626 | |||
2487 | 627 | if (!inWindow) | ||
2488 | 628 | continue; | ||
2489 | 629 | |||
2490 | 630 | /* make sure we never move windows we're not allowed to move */ | ||
2491 | 631 | if (!w->managed ()) | ||
2492 | 632 | break; | ||
2493 | 633 | else if (!(w->actions () & CompWindowActionMoveMask)) | ||
2494 | 634 | break; | ||
2495 | 635 | else if (w->type () & (CompWindowTypeDockMask | | ||
2496 | 636 | CompWindowTypeDesktopMask)) | ||
2497 | 637 | break; | ||
2498 | 638 | |||
2499 | 639 | dndState = DnDDuring; | ||
2500 | 640 | dndWindows.push_back (w); | ||
2501 | 641 | |||
2502 | 642 | w->grabNotify (nx, ny, 0, | ||
2503 | 643 | CompWindowGrabMoveMask | | ||
2504 | 644 | CompWindowGrabButtonMask); | ||
2505 | 645 | |||
2506 | 646 | screen->updateGrab (grabIndex, mMoveCursor); | ||
2507 | 647 | |||
2508 | 648 | w->raise (); | ||
2509 | 649 | w->moveInputFocusTo (); | ||
2510 | 650 | break; | ||
2511 | 651 | } | ||
2512 | 652 | |||
2513 | 653 | prevCursor = newCursor; | ||
2514 | 654 | } | ||
2515 | 655 | break; | ||
2516 | 656 | default: | ||
2517 | 657 | break; | ||
2518 | 658 | } | ||
2519 | 659 | } | ||
2520 | 660 | |||
2521 | 661 | void | ||
2522 | 662 | ExpoScreen::invertTransformedVertex (const GLScreenPaintAttrib& attrib, | ||
2523 | 663 | const GLMatrix& transform, | ||
2524 | 664 | CompOutput *output, | ||
2525 | 665 | int vertex[2]) | ||
2526 | 666 | { | ||
2527 | 667 | GLMatrix sTransform (transform); | ||
2528 | 668 | GLdouble p1[3], p2[3], v[3], alpha; | ||
2529 | 669 | GLdouble mvm[16], pm[16]; | ||
2530 | 670 | GLint viewport[4]; | ||
2531 | 671 | int i; | ||
2532 | 672 | |||
2533 | 673 | gScreen->glApplyTransform (attrib, output, &sTransform); | ||
2534 | 674 | sTransform.toScreenSpace (output, -attrib.zTranslate); | ||
2535 | 675 | |||
2536 | 676 | glGetIntegerv (GL_VIEWPORT, viewport); | ||
2537 | 677 | for (i = 0; i < 16; i++) | ||
2538 | 678 | { | ||
2539 | 679 | mvm[i] = sTransform[i]; | ||
2540 | 680 | pm[i] = gScreen->projectionMatrix ()[i]; | ||
2541 | 681 | } | ||
2542 | 682 | |||
2543 | 683 | gluUnProject (vertex[0], screen->height () - vertex[1], 0, mvm, pm, | ||
2544 | 684 | viewport, &p1[0], &p1[1], &p1[2]); | ||
2545 | 685 | gluUnProject (vertex[0], screen->height () - vertex[1], -1.0, mvm, pm, | ||
2546 | 686 | viewport, &p2[0], &p2[1], &p2[2]); | ||
2547 | 687 | |||
2548 | 688 | for (i = 0; i < 3; i++) | ||
2549 | 689 | v[i] = p1[i] - p2[i]; | ||
2550 | 690 | |||
2551 | 691 | alpha = -p1[2] / v[2]; | ||
2552 | 692 | |||
2553 | 693 | if (optionGetDeform () == DeformCurve && screen->desktopWindowCount ()) | ||
2554 | 694 | { | ||
2555 | 695 | const float sws = screen->width () * screen->width (); | ||
2556 | 696 | const float rs = (curveDistance * curveDistance) + 0.25; | ||
2557 | 697 | const float p = ((2.0 * sws * (p1[2] - curveDistance) * v[2]) + | ||
2558 | 698 | (2.0 * p1[0] * v[0]) - | ||
2559 | 699 | (v[0] * (float) screen->width ())) / | ||
2560 | 700 | ((v[2] * v[2] * sws) + (v[0] * v[0])); | ||
2561 | 701 | const float q = (-(sws * rs) + (sws * (p1[2] - curveDistance) * | ||
2562 | 702 | (p1[2] - curveDistance)) + | ||
2563 | 703 | (0.25 * sws) + (p1[0] * p1[0]) - | ||
2564 | 704 | (p1[0] * (float) screen->width ())) / | ||
2565 | 705 | ((v[2] * v[2] * sws) + (v[0] * v[0])); | ||
2566 | 706 | |||
2567 | 707 | const float rq = (0.25 * p * p) - q; | ||
2568 | 708 | const float ph = -p * 0.5; | ||
2569 | 709 | |||
2570 | 710 | if (rq < 0.0) | ||
2571 | 711 | { | ||
2572 | 712 | vertex[0] = -1000; | ||
2573 | 713 | vertex[1] = -1000; | ||
2574 | 714 | return; | ||
2575 | 715 | } | ||
2576 | 716 | else | ||
2577 | 717 | { | ||
2578 | 718 | alpha = ph + sqrt(rq); | ||
2579 | 719 | if (p1[2] + (alpha * v[2]) > 0.0) | ||
2580 | 720 | { | ||
2581 | 721 | vertex[0] = -1000; | ||
2582 | 722 | vertex[1] = -1000; | ||
2583 | 723 | return; | ||
2584 | 724 | } | ||
2585 | 725 | } | ||
2586 | 726 | } | ||
2587 | 727 | |||
2588 | 728 | vertex[0] = ceil (p1[0] + (alpha * v[0])); | ||
2589 | 729 | vertex[1] = ceil (p1[1] + (alpha * v[1])); | ||
2590 | 730 | } | ||
2591 | 731 | |||
2592 | 732 | void | ||
2593 | 733 | ExpoScreen::paintViewport (const GLScreenPaintAttrib& attrib, | ||
2594 | 734 | const GLMatrix& transform, | ||
2595 | 735 | const CompRegion& region, | ||
2596 | 736 | CompOutput *output, | ||
2597 | 737 | unsigned int mask, | ||
2598 | 738 | CompPoint vpPos, | ||
2599 | 739 | GLVector &vpCamPos, | ||
2600 | 740 | bool reflection) | ||
2601 | 741 | { | ||
2602 | 742 | GLMatrix sTransform (transform); | ||
2603 | 743 | GLMatrix sTransform2, sTransform3; | ||
2604 | 744 | float sx = (float) screen->width () / output->width (); | ||
2605 | 745 | float sy = (float) screen->height () / output->height (); | ||
2606 | 746 | float vpp; | ||
2607 | 747 | float progress = sigmoidProgress (expoCam); | ||
2608 | 748 | unsigned int vp; | ||
2609 | 749 | CompPoint vpSize (screen->vpSize ().width (), screen->vpSize ().height ()); | ||
2610 | 750 | |||
2611 | 751 | const float gapY = optionGetVpDistance () * 0.1f * expoCam; | ||
2612 | 752 | const float gapX = optionGetVpDistance () * 0.1f * screen->height () / | ||
2613 | 753 | screen->width () * expoCam; | ||
2614 | 754 | |||
2615 | 755 | /* not sure this will work with different resolutions */ | ||
2616 | 756 | sTransform.translate (0.0, MAX (0, vpPos.y ()) * -(sy + gapY), 0.0f); | ||
2617 | 757 | |||
2618 | 758 | sTransform2 = sTransform; | ||
2619 | 759 | |||
2620 | 760 | /* not sure this will work with different resolutions */ | ||
2621 | 761 | if (optionGetDeform () != DeformCurve) | ||
2622 | 762 | sTransform2.translate (MAX (0, vpPos.x ()) * (sx + gapX), 0.0f, 0.0); | ||
2623 | 763 | |||
2624 | 764 | |||
2625 | 765 | if (optionGetExpoAnimation () == ExpoAnimationVortex) | ||
2626 | 766 | sTransform2.rotate (360 * expoCam, | ||
2627 | 767 | 0.0f, 1.0f, 2.0f * expoCam); | ||
2628 | 768 | |||
2629 | 769 | sTransform3 = sTransform2; | ||
2630 | 770 | |||
2631 | 771 | sTransform3.translate (output->x () / output->width (), | ||
2632 | 772 | -output->y () / output->height (), 0.0); | ||
2633 | 773 | |||
2634 | 774 | cScreen->setWindowPaintOffset ((screen->vp ().x () - vpPos.x ()) * | ||
2635 | 775 | screen->width (), | ||
2636 | 776 | (screen->vp ().y () - vpPos.y ()) * | ||
2637 | 777 | screen->height ()); | ||
2638 | 778 | |||
2639 | 779 | vp = (vpPos.y () * vpSize.x ()) + vpPos.x (); | ||
2640 | 780 | |||
2641 | 781 | vpp = (expoCam * vpActivity[vp]) + (1 - expoCam); | ||
2642 | 782 | vpp = sigmoidProgress (vpp); | ||
2643 | 783 | |||
2644 | 784 | vpBrightness = vpp + ((1.0 - vpp) * | ||
2645 | 785 | optionGetVpBrightness () / 100.0); | ||
2646 | 786 | vpSaturation = vpp + ((1.0 - vpp) * | ||
2647 | 787 | optionGetVpSaturation () / 100.0); | ||
2648 | 788 | |||
2649 | 789 | paintingVp = vpPos; | ||
2650 | 790 | |||
2651 | 791 | if (optionGetDeform () == DeformCurve) | ||
2652 | 792 | { | ||
2653 | 793 | float rotateX; | ||
2654 | 794 | |||
2655 | 795 | sTransform3.translate (-vpCamPos[GLVector::x], 0.0f, | ||
2656 | 796 | curveDistance - DEFAULT_Z_CAMERA); | ||
2657 | 797 | |||
2658 | 798 | rotateX = -vpPos.x () + interpolate (((float) vpSize.x () / 2.0) - 0.5, | ||
2659 | 799 | screen->vp ().x (), progress); | ||
2660 | 800 | |||
2661 | 801 | sTransform3.rotate (curveAngle * rotateX, 0.0, 1.0, 0.0); | ||
2662 | 802 | |||
2663 | 803 | sTransform3.translate (vpCamPos[GLVector::x], 0.0f, | ||
2664 | 804 | DEFAULT_Z_CAMERA - curveDistance); | ||
2665 | 805 | } | ||
2666 | 806 | |||
2667 | 807 | if (paintingDndWindow) | ||
2668 | 808 | cScreen->getWindowPaintListSetEnabled (this, true); | ||
2669 | 809 | gScreen->glPaintTransformedOutput (attrib, sTransform3, | ||
2670 | 810 | screen->region (), output, | ||
2671 | 811 | mask); | ||
2672 | 812 | |||
2673 | 813 | if (paintingDndWindow) | ||
2674 | 814 | cScreen->getWindowPaintListSetEnabled (this, false); | ||
2675 | 815 | |||
2676 | 816 | if (!reflection && !paintingDndWindow) | ||
2677 | 817 | { | ||
2678 | 818 | int cursor[2] = { pointerX, pointerY }; | ||
2679 | 819 | |||
2680 | 820 | invertTransformedVertex (attrib, sTransform3, | ||
2681 | 821 | output, cursor); | ||
2682 | 822 | |||
2683 | 823 | if ((cursor[0] > 0) && (cursor[0] < (int) screen->width ()) && | ||
2684 | 824 | (cursor[1] > 0) && (cursor[1] < (int) screen->height ())) | ||
2685 | 825 | { | ||
2686 | 826 | newCursor.setX (vpPos.x () * screen->width () + cursor[0]); | ||
2687 | 827 | newCursor.setY (vpPos.y () * screen->height () + cursor[1]); | ||
2688 | 828 | |||
2689 | 829 | if (anyClick || dndState != DnDNone) | ||
2690 | 830 | { | ||
2691 | 831 | /* Used to save last viewport interaction was in */ | ||
2692 | 832 | selectedVp = vpPos; | ||
2693 | 833 | anyClick = false; | ||
2694 | 834 | } | ||
2695 | 835 | } | ||
2696 | 836 | } | ||
2697 | 837 | |||
2698 | 838 | /* Calculate the current viewport size */ | ||
2699 | 839 | int tl[2] = { 0, 0 }; | ||
2700 | 840 | int br[2] = { screen->width (), screen->height () }; | ||
2701 | 841 | |||
2702 | 842 | invertTransformedVertex (attrib, sTransform3, output, tl); | ||
2703 | 843 | invertTransformedVertex (attrib, sTransform3, output, br); | ||
2704 | 844 | |||
2705 | 845 | viewport_size = CompSize (br[0] - tl[0], br[1] - tl[1]); | ||
2706 | 846 | |||
2707 | 847 | cScreen->setWindowPaintOffset (0, 0); | ||
2708 | 848 | } | ||
2709 | 849 | |||
2710 | 850 | void | ||
2711 | 851 | ExpoScreen::paintWall (const GLScreenPaintAttrib& attrib, | ||
2712 | 852 | const GLMatrix& transform, | ||
2713 | 853 | const CompRegion& region, | ||
2714 | 854 | CompOutput *output, | ||
2715 | 855 | unsigned int mask, | ||
2716 | 856 | bool reflection) | ||
2717 | 857 | { | ||
2718 | 858 | GLMatrix sTransformW, sTransform (transform); | ||
2719 | 859 | GLenum oldFilter = gScreen->textureFilter (); | ||
2720 | 860 | float sx = (float) screen->width () / output->width (); | ||
2721 | 861 | float sy = (float) screen->height () / output->height (); | ||
2722 | 862 | float biasZ; | ||
2723 | 863 | float oScale, rotation = 0.0f, progress; | ||
2724 | 864 | float aspectX = 1.0f, aspectY = 1.0f; | ||
2725 | 865 | GLVector cam; | ||
2726 | 866 | CompPoint vpSize (screen->vpSize ().width (), screen->vpSize ().height ()); | ||
2727 | 867 | |||
2728 | 868 | /* amount of gap between viewports */ | ||
2729 | 869 | const float gapY = optionGetVpDistance () * 0.1f * expoCam; | ||
2730 | 870 | const float gapX = optionGetVpDistance () * 0.1f * screen->height () / | ||
2731 | 871 | screen->width () * expoCam; | ||
2732 | 872 | |||
2733 | 873 | int glPaintTransformedOutputIndex = | ||
2734 | 874 | gScreen->glPaintTransformedOutputGetCurrentIndex (); | ||
2735 | 875 | |||
2736 | 876 | // Make sure that the base glPaintTransformedOutput function is called | ||
2737 | 877 | gScreen->glPaintTransformedOutputSetCurrentIndex (MAXSHORT); | ||
2738 | 878 | |||
2739 | 879 | /* Zoom animation stuff */ | ||
2740 | 880 | /* camera position for the selected viewport */ | ||
2741 | 881 | GLVector vpCamPos (0, 0, 0, 0); | ||
2742 | 882 | |||
2743 | 883 | /* camera position during expo mode */ | ||
2744 | 884 | GLVector expoCamPos (0, 0, 0, 0); | ||
2745 | 885 | |||
2746 | 886 | if (optionGetDeform () == DeformCurve) | ||
2747 | 887 | { | ||
2748 | 888 | vpCamPos[GLVector::x] = -sx * (0.5 - (((float) output->x () + | ||
2749 | 889 | (output->width () / 2.0)) / | ||
2750 | 890 | (float) screen->width ())); | ||
2751 | 891 | } | ||
2752 | 892 | else | ||
2753 | 893 | { | ||
2754 | 894 | vpCamPos[GLVector::x] = (screen->vp ().x () * sx) + 0.5 + | ||
2755 | 895 | (output->x () / output->width ()) - | ||
2756 | 896 | (vpSize.x () * 0.5 * sx) + | ||
2757 | 897 | gapX * screen->vp ().x (); | ||
2758 | 898 | } | ||
2759 | 899 | vpCamPos[GLVector::y] = -((screen->vp ().y () * sy) + 0.5 + | ||
2760 | 900 | (output->y () / output->height ())) + | ||
2761 | 901 | (vpSize.y () * 0.5 * sy) - | ||
2762 | 902 | gapY * screen->vp ().y (); | ||
2763 | 903 | |||
2764 | 904 | biasZ = MAX (vpSize.x () * sx, vpSize.y () * sy); | ||
2765 | 905 | if (optionGetDeform () == DeformTilt || optionGetReflection ()) | ||
2766 | 906 | biasZ *= (0.15 + optionGetDistance ()); | ||
2767 | 907 | else | ||
2768 | 908 | biasZ *= optionGetDistance (); | ||
2769 | 909 | |||
2770 | 910 | progress = sigmoidProgress (expoCam); | ||
2771 | 911 | |||
2772 | 912 | if (optionGetDeform () != DeformCurve) | ||
2773 | 913 | expoCamPos[GLVector::x] = gapX * (vpSize.x () - 1) * 0.5; | ||
2774 | 914 | |||
2775 | 915 | expoCamPos[GLVector::y] = -gapY * (vpSize.y () - 1) * 0.5; | ||
2776 | 916 | expoCamPos[GLVector::z] = -DEFAULT_Z_CAMERA + DEFAULT_Z_CAMERA * | ||
2777 | 917 | (MAX (vpSize.x () + (vpSize.x () - 1) * gapX, | ||
2778 | 918 | vpSize.y () + (vpSize.y () - 1) * gapY) + | ||
2779 | 919 | biasZ); | ||
2780 | 920 | |||
2781 | 921 | /* interpolate between vpCamPos and expoCamPos */ | ||
2782 | 922 | cam[GLVector::x] = vpCamPos[GLVector::x] * (1 - progress) + | ||
2783 | 923 | expoCamPos[GLVector::x] * progress; | ||
2784 | 924 | cam[GLVector::y] = vpCamPos[GLVector::y] * (1 - progress) + | ||
2785 | 925 | expoCamPos[GLVector::y] * progress; | ||
2786 | 926 | cam[GLVector::z] = vpCamPos[GLVector::z] * (1 - progress) + | ||
2787 | 927 | expoCamPos[GLVector::z] * progress; | ||
2788 | 928 | |||
2789 | 929 | if (vpSize.x () > vpSize.y ()) | ||
2790 | 930 | { | ||
2791 | 931 | aspectY = (float) vpSize.x () / (float) vpSize.y (); | ||
2792 | 932 | aspectY -= 1.0; | ||
2793 | 933 | aspectY *= -optionGetAspectRatio () + 1.0; | ||
2794 | 934 | aspectY *= progress; | ||
2795 | 935 | aspectY += 1.0; | ||
2796 | 936 | } | ||
2797 | 937 | else | ||
2798 | 938 | { | ||
2799 | 939 | aspectX = (float) vpSize.y () / (float) vpSize.x (); | ||
2800 | 940 | aspectX -= 1.0; | ||
2801 | 941 | aspectX *= -optionGetAspectRatio () + 1.0; | ||
2802 | 942 | aspectX *= progress; | ||
2803 | 943 | aspectX += 1.0; | ||
2804 | 944 | } | ||
2805 | 945 | |||
2806 | 946 | /* End of Zoom animation stuff */ | ||
2807 | 947 | |||
2808 | 948 | if (optionGetDeform () == DeformTilt) | ||
2809 | 949 | { | ||
2810 | 950 | if (optionGetExpoAnimation () == ExpoAnimationZoom) | ||
2811 | 951 | rotation = 10.0 * sigmoidProgress (expoCam); | ||
2812 | 952 | else | ||
2813 | 953 | rotation = 10.0 * expoCam; | ||
2814 | 954 | } | ||
2815 | 955 | |||
2816 | 956 | if (optionGetMipmaps ()) | ||
2817 | 957 | gScreen->setTextureFilter (GL_LINEAR_MIPMAP_LINEAR); | ||
2818 | 958 | |||
2819 | 959 | /* ALL TRANSFORMATION ARE EXECUTED FROM BOTTOM TO TOP */ | ||
2820 | 960 | |||
2821 | 961 | oScale = 1 / (1 + ((MAX (sx, sy) - 1) * progress)); | ||
2822 | 962 | |||
2823 | 963 | sTransform.scale (oScale, oScale, 1.0); | ||
2824 | 964 | |||
2825 | 965 | /* zoom out */ | ||
2826 | 966 | oScale = DEFAULT_Z_CAMERA / (cam[GLVector::z] + DEFAULT_Z_CAMERA); | ||
2827 | 967 | sTransform.scale (oScale, oScale, oScale); | ||
2828 | 968 | glNormal3f (0.0, 0.0, -oScale); | ||
2829 | 969 | sTransform.translate (-cam[GLVector::x], -cam[GLVector::y], | ||
2830 | 970 | -cam[GLVector::z] - DEFAULT_Z_CAMERA); | ||
2831 | 971 | |||
2832 | 972 | if (reflection) | ||
2833 | 973 | { | ||
2834 | 974 | float scaleFactor = optionGetScaleFactor (); | ||
2835 | 975 | |||
2836 | 976 | sTransform.translate (0.0, | ||
2837 | 977 | (vpSize.y () + ((vpSize.y () - 1) * gapY * 2)) * | ||
2838 | 978 | -sy * aspectY, | ||
2839 | 979 | 0.0); | ||
2840 | 980 | sTransform.scale (1.0, -1.0, 1.0); | ||
2841 | 981 | sTransform.translate (0.0, | ||
2842 | 982 | - (1 - scaleFactor) / 2 * sy * aspectY * | ||
2843 | 983 | (vpSize.y () + ((vpSize.y () - 1) * gapY * 2)), | ||
2844 | 984 | 0.0); | ||
2845 | 985 | sTransform.scale (1.0, scaleFactor, 1.0); | ||
2846 | 986 | glCullFace (GL_FRONT); | ||
2847 | 987 | } | ||
2848 | 988 | |||
2849 | 989 | /* rotate */ | ||
2850 | 990 | sTransform.rotate (rotation, 0.0f, 1.0f, 0.0f); | ||
2851 | 991 | sTransform.scale (aspectX, aspectY, 1.0); | ||
2852 | 992 | |||
2853 | 993 | float xoffset = 0.0; | ||
2854 | 994 | float yoffset = 0.0; | ||
2855 | 995 | float xadjs = 1.0f; | ||
2856 | 996 | float yadjs = 1.0f; | ||
2857 | 997 | |||
2858 | 998 | if (output->left () == 0) | ||
2859 | 999 | { | ||
2860 | 1000 | xoffset = ((vpSize.x () * sx) / ((float) output->width ()) * (optionGetXOffset ()) * sigmoidProgress (expoCam)); | ||
2861 | 1001 | xadjs = 1.0f - ((float) (optionGetXOffset ()) / (float) (output->width ())) * sigmoidProgress (expoCam); | ||
2862 | 1002 | } | ||
2863 | 1003 | |||
2864 | 1004 | if (output->top () == 0) | ||
2865 | 1005 | { | ||
2866 | 1006 | yoffset = ((vpSize.y () * sy) / ((float) output->height ()) * (optionGetYOffset ()) * sigmoidProgress (expoCam)); | ||
2867 | 1007 | |||
2868 | 1008 | yadjs = 1.0f - ((float) (optionGetYOffset ()) / (float) output->height ()) * sigmoidProgress (expoCam); | ||
2869 | 1009 | } | ||
2870 | 1010 | |||
2871 | 1011 | /* translate expo to center */ | ||
2872 | 1012 | sTransform.translate (vpSize.x () * sx * -0.5 + xoffset, | ||
2873 | 1013 | vpSize.y () * sy * 0.5 - yoffset, 0.0f); | ||
2874 | 1014 | sTransform.scale (xadjs, yadjs, 1.0f); | ||
2875 | 1015 | |||
2876 | 1016 | if (optionGetDeform () == DeformCurve) | ||
2877 | 1017 | sTransform.translate ((vpSize.x () - 1) * sx * 0.5, 0.0, 0.0); | ||
2878 | 1018 | |||
2879 | 1019 | sTransformW = sTransform; | ||
2880 | 1020 | |||
2881 | 1021 | /* revert prepareXCoords region shift. Now all screens display the same */ | ||
2882 | 1022 | sTransform.translate (0.5f, -0.5f, DEFAULT_Z_CAMERA); | ||
2883 | 1023 | |||
2884 | 1024 | if (vpSize.x () > 2) | ||
2885 | 1025 | /* we can't have 90 degree for the left/right most viewport */ | ||
2886 | 1026 | curveAngle = interpolate (359 / ((vpSize.x () - 1) * 2), 1, | ||
2887 | 1027 | optionGetCurve ()); | ||
2888 | 1028 | else | ||
2889 | 1029 | curveAngle = interpolate (180 / vpSize.x (), 1, optionGetCurve ()); | ||
2890 | 1030 | |||
2891 | 1031 | curveDistance = ((0.5f * sx) + (gapX / 2.0)) / | ||
2892 | 1032 | tanf ((M_PI / 180.0f) * curveAngle / 2.0); | ||
2893 | 1033 | curveRadius = ((0.5f * sx) + (gapX / 2.0)) / | ||
2894 | 1034 | sinf ((M_PI / 180.0f) * curveAngle / 2.0); | ||
2895 | 1035 | |||
2896 | 1036 | expoActive = true; | ||
2897 | 1037 | |||
2898 | 1038 | for (int j = 0; j < screen->vpSize ().height (); j++) | ||
2899 | 1039 | for (int i = 0; i < screen->vpSize().width (); i++) | ||
2900 | 1040 | paintViewport (attrib, sTransform, region, output, mask, CompPoint (i, j), vpCamPos, reflection); | ||
2901 | 1041 | |||
2902 | 1042 | paintingDndWindow = true; | ||
2903 | 1043 | |||
2904 | 1044 | foreach (CompWindow *dndWindow, dndWindows) | ||
2905 | 1045 | { | ||
2906 | 1046 | CompPoint vp; | ||
2907 | 1047 | |||
2908 | 1048 | screen->viewportForGeometry (dndWindow->geometry (), vp); | ||
2909 | 1049 | |||
2910 | 1050 | while (vp.x () < 0) | ||
2911 | 1051 | vp.setX (screen->vpSize ().width () + vp.x ()); | ||
2912 | 1052 | |||
2913 | 1053 | while (vp.y () < 0) | ||
2914 | 1054 | vp.setY (screen->vpSize ().height () + vp.y ()); | ||
2915 | 1055 | |||
2916 | 1056 | paintViewport (attrib, sTransform, infiniteRegion, output, mask, vp, vpCamPos, reflection); | ||
2917 | 1057 | } | ||
2918 | 1058 | |||
2919 | 1059 | paintingDndWindow = false; | ||
2920 | 1060 | |||
2921 | 1061 | glNormal3f (0.0, 0.0, -1.0); | ||
2922 | 1062 | |||
2923 | 1063 | if (reflection) | ||
2924 | 1064 | { | ||
2925 | 1065 | glEnable (GL_BLEND); | ||
2926 | 1066 | glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); | ||
2927 | 1067 | |||
2928 | 1068 | glPushMatrix (); | ||
2929 | 1069 | |||
2930 | 1070 | if (optionGetDeform () != DeformCurve) | ||
2931 | 1071 | { | ||
2932 | 1072 | glLoadMatrixf (sTransformW.getMatrix ()); | ||
2933 | 1073 | |||
2934 | 1074 | glBegin (GL_QUADS); | ||
2935 | 1075 | glColor4f (0.0, 0.0, 0.0, 1.0); | ||
2936 | 1076 | glVertex2f (0.0, 0.0); | ||
2937 | 1077 | glColor4f (0.0, 0.0, 0.0, 0.5); | ||
2938 | 1078 | glVertex2f (0.0, -vpSize.y () * (sy + gapY)); | ||
2939 | 1079 | glVertex2f (vpSize.x () * sx * (1.0 + gapX), | ||
2940 | 1080 | -vpSize.y () * sy * (1.0 + gapY)); | ||
2941 | 1081 | glColor4f (0.0, 0.0, 0.0, 1.0); | ||
2942 | 1082 | glVertex2f (vpSize.x () * sx * (1.0 + gapX), 0.0); | ||
2943 | 1083 | glEnd (); | ||
2944 | 1084 | } | ||
2945 | 1085 | else | ||
2946 | 1086 | { | ||
2947 | 1087 | glCullFace (GL_BACK); | ||
2948 | 1088 | glLoadIdentity (); | ||
2949 | 1089 | glTranslatef (0.0, 0.0, -DEFAULT_Z_CAMERA); | ||
2950 | 1090 | |||
2951 | 1091 | glBegin (GL_QUADS); | ||
2952 | 1092 | glColor4f (0.0, 0.0, 0.0, 1.0 * expoCam); | ||
2953 | 1093 | glVertex2f (-0.5, -0.5); | ||
2954 | 1094 | glVertex2f (0.5, -0.5); | ||
2955 | 1095 | glColor4f (0.0, 0.0, 0.0, 0.5 * expoCam); | ||
2956 | 1096 | glVertex2f (0.5, 0.0); | ||
2957 | 1097 | glVertex2f (-0.5, 0.0); | ||
2958 | 1098 | glColor4f (0.0, 0.0, 0.0, 0.5 * expoCam); | ||
2959 | 1099 | glVertex2f (-0.5, 0.0); | ||
2960 | 1100 | glVertex2f (0.5, 0.0); | ||
2961 | 1101 | glColor4f (0.0, 0.0, 0.0, 0.0); | ||
2962 | 1102 | glVertex2f (0.5, 0.5); | ||
2963 | 1103 | glVertex2f (-0.5, 0.5); | ||
2964 | 1104 | glEnd (); | ||
2965 | 1105 | } | ||
2966 | 1106 | glCullFace (GL_BACK); | ||
2967 | 1107 | |||
2968 | 1108 | glLoadIdentity (); | ||
2969 | 1109 | glTranslatef (0.0, 0.0, -DEFAULT_Z_CAMERA); | ||
2970 | 1110 | |||
2971 | 1111 | if (optionGetGroundSize () > 0.0) | ||
2972 | 1112 | { | ||
2973 | 1113 | glBegin (GL_QUADS); | ||
2974 | 1114 | glColor4usv (optionGetGroundColor1 ()); | ||
2975 | 1115 | glVertex2f (-0.5, -0.5); | ||
2976 | 1116 | glVertex2f (0.5, -0.5); | ||
2977 | 1117 | glColor4usv (optionGetGroundColor2 ()); | ||
2978 | 1118 | glVertex2f (0.5, -0.5 + optionGetGroundSize ()); | ||
2979 | 1119 | glVertex2f (-0.5, -0.5 + optionGetGroundSize ()); | ||
2980 | 1120 | glEnd (); | ||
2981 | 1121 | } | ||
2982 | 1122 | |||
2983 | 1123 | glColor4usv (defaultColor); | ||
2984 | 1124 | |||
2985 | 1125 | glBlendFunc (GL_ONE, GL_ONE_MINUS_SRC_ALPHA); | ||
2986 | 1126 | glDisable (GL_BLEND); | ||
2987 | 1127 | glPopMatrix (); | ||
2988 | 1128 | } | ||
2989 | 1129 | |||
2990 | 1130 | expoActive = false; | ||
2991 | 1131 | |||
2992 | 1132 | gScreen->glPaintTransformedOutputSetCurrentIndex (glPaintTransformedOutputIndex); | ||
2993 | 1133 | gScreen->setTextureFilter (oldFilter); | ||
2994 | 1134 | } | ||
2995 | 1135 | |||
2996 | 1136 | const CompWindowList & | ||
2997 | 1137 | ExpoScreen::getWindowPaintList () | ||
2998 | 1138 | { | ||
2999 | 1139 | return dndWindows; | ||
3000 | 1140 | } | ||
3001 | 1141 | |||
3002 | 1142 | bool | ||
3003 | 1143 | ExpoScreen::glPaintOutput (const GLScreenPaintAttrib& attrib, | ||
3004 | 1144 | const GLMatrix& transform, | ||
3005 | 1145 | const CompRegion& region, | ||
3006 | 1146 | CompOutput *output, | ||
3007 | 1147 | unsigned int mask) | ||
3008 | 1148 | { | ||
3009 | 1149 | if (expoCam > 0.0) | ||
3010 | 1150 | mask |= PAINT_SCREEN_TRANSFORMED_MASK | PAINT_SCREEN_CLEAR_MASK; | ||
3011 | 1151 | |||
3012 | 1152 | return gScreen->glPaintOutput (attrib, transform, region, output, mask); | ||
3013 | 1153 | } | ||
3014 | 1154 | |||
3015 | 1155 | void | ||
3016 | 1156 | ExpoScreen::glPaintTransformedOutput (const GLScreenPaintAttrib& attrib, | ||
3017 | 1157 | const GLMatrix& transform, | ||
3018 | 1158 | const CompRegion& region, | ||
3019 | 1159 | CompOutput *output, | ||
3020 | 1160 | unsigned int mask) | ||
3021 | 1161 | { | ||
3022 | 1162 | expoActive = false; | ||
3023 | 1163 | |||
3024 | 1164 | if (expoCam > 0) | ||
3025 | 1165 | mask |= PAINT_SCREEN_CLEAR_MASK; | ||
3026 | 1166 | |||
3027 | 1167 | if (expoCam <= 0 || (expoCam > 0.0 && expoCam < 1.0 && | ||
3028 | 1168 | optionGetExpoAnimation () != ExpoAnimationZoom)) | ||
3029 | 1169 | { | ||
3030 | 1170 | gScreen->glPaintTransformedOutput (attrib, transform, region, | ||
3031 | 1171 | output, mask); | ||
3032 | 1172 | } | ||
3033 | 1173 | else | ||
3034 | 1174 | { | ||
3035 | 1175 | gScreen->clearOutput (output, GL_COLOR_BUFFER_BIT); | ||
3036 | 1176 | } | ||
3037 | 1177 | |||
3038 | 1178 | mask &= ~PAINT_SCREEN_CLEAR_MASK; | ||
3039 | 1179 | |||
3040 | 1180 | if (expoCam > 0.0) | ||
3041 | 1181 | { | ||
3042 | 1182 | if (optionGetReflection ()) | ||
3043 | 1183 | paintWall (attrib, transform, region, output, mask, true); | ||
3044 | 1184 | |||
3045 | 1185 | paintWall (attrib, transform, region, output, mask, false); | ||
3046 | 1186 | anyClick = false; | ||
3047 | 1187 | } | ||
3048 | 1188 | } | ||
3049 | 1189 | |||
3050 | 1190 | bool | ||
3051 | 1191 | ExpoWindow::glDraw (const GLMatrix& transform, | ||
3052 | 1192 | GLFragment::Attrib& fragment, | ||
3053 | 1193 | const CompRegion& region, | ||
3054 | 1194 | unsigned int mask) | ||
3055 | 1195 | { | ||
3056 | 1196 | GLMatrix wTransform (transform); | ||
3057 | 1197 | CompPoint vp; | ||
3058 | 1198 | |||
3059 | 1199 | screen->viewportForGeometry (window->geometry (), vp); | ||
3060 | 1200 | |||
3061 | 1201 | if (eScreen->expoCam == 0.0f) | ||
3062 | 1202 | return gWindow->glDraw (transform, fragment, region, mask); | ||
3063 | 1203 | |||
3064 | 1204 | GLFragment::Attrib fA (fragment); | ||
3065 | 1205 | int expoAnimation; | ||
3066 | 1206 | |||
3067 | 1207 | expoAnimation = eScreen->optionGetExpoAnimation (); | ||
3068 | 1208 | |||
3069 | 1209 | if (eScreen->expoActive) | ||
3070 | 1210 | { | ||
3071 | 1211 | if (expoAnimation != ExpoScreen::ExpoAnimationZoom) | ||
3072 | 1212 | fA.setOpacity (fragment.getOpacity () * eScreen->expoCam); | ||
3073 | 1213 | |||
3074 | 1214 | if (window->wmType () & CompWindowTypeDockMask && | ||
3075 | 1215 | eScreen->optionGetHideDocks ()) | ||
3076 | 1216 | { | ||
3077 | 1217 | if (expoAnimation == ExpoScreen::ExpoAnimationZoom && | ||
3078 | 1218 | eScreen->paintingVp == eScreen->selectedVp) | ||
3079 | 1219 | { | ||
3080 | 1220 | fA.setOpacity (fragment.getOpacity () * | ||
3081 | 1221 | (1 - sigmoidProgress (eScreen->expoCam))); | ||
3082 | 1222 | } | ||
3083 | 1223 | else | ||
3084 | 1224 | { | ||
3085 | 1225 | fA.setOpacity (0); | ||
3086 | 1226 | } | ||
3087 | 1227 | } | ||
3088 | 1228 | |||
3089 | 1229 | if (vp == eScreen->paintingVp || window->onAllViewports ()) | ||
3090 | 1230 | { | ||
3091 | 1231 | fA.setBrightness (fragment.getBrightness () * eScreen->vpBrightness); | ||
3092 | 1232 | fA.setSaturation (fragment.getSaturation () * eScreen->vpSaturation); | ||
3093 | 1233 | } | ||
3094 | 1234 | } | ||
3095 | 1235 | else | ||
3096 | 1236 | { | ||
3097 | 1237 | if (expoAnimation == ExpoScreen::ExpoAnimationZoom) | ||
3098 | 1238 | fA.setBrightness (0); | ||
3099 | 1239 | else | ||
3100 | 1240 | fA.setBrightness (fragment.getBrightness () * | ||
3101 | 1241 | (1 - sigmoidProgress (eScreen->expoCam))); | ||
3102 | 1242 | } | ||
3103 | 1243 | |||
3104 | 1244 | bool status = gWindow->glDraw (wTransform, fA, region, mask); | ||
3105 | 1245 | |||
3106 | 1246 | if (window->type () & CompWindowTypeDesktopMask) | ||
3107 | 1247 | { | ||
3108 | 1248 | /* We want to set the geometry of the polka dots to the window | ||
3109 | 1249 | * region */ | ||
3110 | 1250 | CompRegion reg = CompRegion (0, 0, window->width (), window->height ()); | ||
3111 | 1251 | |||
3112 | 1252 | foreach(GLTexture * tex, eScreen->polkadots_texture) | ||
3113 | 1253 | { | ||
3114 | 1254 | GLTexture::MatrixList matl; | ||
3115 | 1255 | GLTexture::Matrix mat = tex->matrix(); | ||
3116 | 1256 | CompRegion paintRegion(region); | ||
3117 | 1257 | |||
3118 | 1258 | /* We can reset the window geometry since it will be | ||
3119 | 1259 | * re-added later */ | ||
3120 | 1260 | gWindow->geometry().reset(); | ||
3121 | 1261 | |||
3122 | 1262 | float xScale = screen->width () / (float) eScreen->viewport_size.width (); | ||
3123 | 1263 | float yScale = screen->height () / (float) eScreen->viewport_size.height (); | ||
3124 | 1264 | |||
3125 | 1265 | mat.xx *= xScale; | ||
3126 | 1266 | mat.yy *= yScale; | ||
3127 | 1267 | |||
3128 | 1268 | /* Not sure what this does, but it is necessary | ||
3129 | 1269 | * (adjusts for scale?) */ | ||
3130 | 1270 | mat.x0 -= mat.xx * reg.boundingRect().x1(); | ||
3131 | 1271 | mat.y0 -= mat.yy * reg.boundingRect().y1(); | ||
3132 | 1272 | |||
3133 | 1273 | matl.push_back(mat); | ||
3134 | 1274 | |||
3135 | 1275 | if (mask & PAINT_WINDOW_TRANSFORMED_MASK) | ||
3136 | 1276 | paintRegion = infiniteRegion; | ||
3137 | 1277 | |||
3138 | 1278 | /* Now allow plugins to mess with the geometry of our | ||
3139 | 1279 | * dim (so we get a nice render for things like | ||
3140 | 1280 | * wobbly etc etc */ | ||
3141 | 1281 | gWindow->glAddGeometry(matl, reg, paintRegion); | ||
3142 | 1282 | |||
3143 | 1283 | /* Did it succeed? */ | ||
3144 | 1284 | if (gWindow->geometry().vertices) | ||
3145 | 1285 | { | ||
3146 | 1286 | unsigned int glDrawTextureIndex = gWindow->glDrawTextureGetCurrentIndex(); | ||
3147 | 1287 | fA.setOpacity (fragment.getOpacity () * (((1.0 - eScreen->vpBrightness) + (1.0 - eScreen->vpSaturation) / 2.0))); | ||
3148 | 1288 | /* Texture rendering set-up */ | ||
3149 | 1289 | eScreen->gScreen->setTexEnvMode(GL_MODULATE); | ||
3150 | 1290 | glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA); | ||
3151 | 1291 | /* Draw the dim texture with all of it's modified | ||
3152 | 1292 | * geometry glory */ | ||
3153 | 1293 | gWindow->glDrawTextureSetCurrentIndex(MAXSHORT); | ||
3154 | 1294 | gWindow->glDrawTexture(tex, fA, mask | PAINT_WINDOW_BLEND_MASK | ||
3155 | 1295 | | PAINT_WINDOW_TRANSLUCENT_MASK | | ||
3156 | 1296 | PAINT_WINDOW_TRANSFORMED_MASK); | ||
3157 | 1297 | gWindow->glDrawTextureSetCurrentIndex(glDrawTextureIndex); | ||
3158 | 1298 | /* Texture rendering tear-down */ | ||
3159 | 1299 | glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA); | ||
3160 | 1300 | eScreen->gScreen->setTexEnvMode(GL_REPLACE); | ||
3161 | 1301 | } | ||
3162 | 1302 | } | ||
3163 | 1303 | |||
3164 | 1304 | /* Paint the outline */ | ||
3165 | 1305 | if (mGlowQuads && eScreen->paintingVp == eScreen->selectedVp) | ||
3166 | 1306 | { | ||
3167 | 1307 | if (region.numRects ()) | ||
3168 | 1308 | { | ||
3169 | 1309 | /* reset geometry and paint */ | ||
3170 | 1310 | gWindow->geometry ().reset (); | ||
3171 | 1311 | |||
3172 | 1312 | paintGlow (fragment, infiniteRegion, mask); | ||
3173 | 1313 | } | ||
3174 | 1314 | } | ||
3175 | 1315 | |||
3176 | 1316 | } | ||
3177 | 1317 | |||
3178 | 1318 | return status; | ||
3179 | 1319 | |||
3180 | 1320 | } | ||
3181 | 1321 | |||
3182 | 1322 | #define EXPO_GRID_SIZE 100 | ||
3183 | 1323 | |||
3184 | 1324 | void | ||
3185 | 1325 | ExpoWindow::glAddGeometry (const GLTexture::MatrixList& matrices, | ||
3186 | 1326 | const CompRegion& region, | ||
3187 | 1327 | const CompRegion& clip, | ||
3188 | 1328 | unsigned int maxGridWidth, | ||
3189 | 1329 | unsigned int maxGridHeight) | ||
3190 | 1330 | { | ||
3191 | 1331 | if (eScreen->expoCam > 0.0 && | ||
3192 | 1332 | screen->desktopWindowCount () && | ||
3193 | 1333 | eScreen->optionGetDeform () == ExpoScreen::DeformCurve) | ||
3194 | 1334 | { | ||
3195 | 1335 | int i, oldVCount = gWindow->geometry ().vCount; | ||
3196 | 1336 | GLfloat *v; | ||
3197 | 1337 | CompPoint offset; | ||
3198 | 1338 | float lastX, lastZ = 0.0; | ||
3199 | 1339 | const float radSquare = pow (eScreen->curveDistance, 2) + 0.25; | ||
3200 | 1340 | float ang; | ||
3201 | 1341 | |||
3202 | 1342 | gWindow->glAddGeometry (matrices, region, clip, | ||
3203 | 1343 | MIN(maxGridWidth , EXPO_GRID_SIZE), | ||
3204 | 1344 | maxGridHeight); | ||
3205 | 1345 | |||
3206 | 1346 | v = gWindow->geometry ().vertices; | ||
3207 | 1347 | v += gWindow->geometry ().vertexStride - 3; | ||
3208 | 1348 | v += gWindow->geometry ().vertexStride * oldVCount; | ||
3209 | 1349 | |||
3210 | 1350 | if (!window->onAllViewports ()) | ||
3211 | 1351 | { | ||
3212 | 1352 | offset = eScreen->cScreen->windowPaintOffset (); | ||
3213 | 1353 | offset = window->getMovementForOffset (offset); | ||
3214 | 1354 | } | ||
3215 | 1355 | |||
3216 | 1356 | lastX = -1000000000.0; | ||
3217 | 1357 | |||
3218 | 1358 | for (i = oldVCount; i < gWindow->geometry ().vCount; i++) | ||
3219 | 1359 | { | ||
3220 | 1360 | if (v[0] == lastX) | ||
3221 | 1361 | { | ||
3222 | 1362 | v[2] = lastZ; | ||
3223 | 1363 | } | ||
3224 | 1364 | else if (v[0] + offset.x () >= -EXPO_GRID_SIZE && | ||
3225 | 1365 | v[0] + offset.x () < screen->width () + EXPO_GRID_SIZE) | ||
3226 | 1366 | { | ||
3227 | 1367 | ang = (((v[0] + offset.x ()) / (float) screen->width ()) - 0.5); | ||
3228 | 1368 | ang *= ang; | ||
3229 | 1369 | if (ang < radSquare) | ||
3230 | 1370 | { | ||
3231 | 1371 | v[2] = eScreen->curveDistance - sqrt (radSquare - ang); | ||
3232 | 1372 | v[2] *= sigmoidProgress (eScreen->expoCam); | ||
3233 | 1373 | } | ||
3234 | 1374 | } | ||
3235 | 1375 | |||
3236 | 1376 | lastX = v[0]; | ||
3237 | 1377 | lastZ = v[2]; | ||
3238 | 1378 | |||
3239 | 1379 | v += gWindow->geometry ().vertexStride; | ||
3240 | 1380 | } | ||
3241 | 1381 | } | ||
3242 | 1382 | else | ||
3243 | 1383 | { | ||
3244 | 1384 | gWindow->glAddGeometry (matrices, region, clip, maxGridWidth, maxGridHeight); | ||
3245 | 1385 | } | ||
3246 | 1386 | } | ||
3247 | 1387 | |||
3248 | 1388 | void | ||
3249 | 1389 | ExpoWindow::glDrawTexture (GLTexture *texture, | ||
3250 | 1390 | GLFragment::Attrib& attrib, | ||
3251 | 1391 | unsigned int mask) | ||
3252 | 1392 | { | ||
3253 | 1393 | if (eScreen->expoCam > 0.0 && | ||
3254 | 1394 | eScreen->optionGetDeform () == ExpoScreen::DeformCurve && | ||
3255 | 1395 | eScreen->gScreen->lighting () && | ||
3256 | 1396 | screen->desktopWindowCount ()) | ||
3257 | 1397 | { | ||
3258 | 1398 | unsigned int i, idx, vCount; | ||
3259 | 1399 | CompPoint offset; | ||
3260 | 1400 | float x; | ||
3261 | 1401 | GLfloat *v; | ||
3262 | 1402 | |||
3263 | 1403 | vCount = gWindow->geometry ().vCount; | ||
3264 | 1404 | |||
3265 | 1405 | if (eScreen->winNormals.size () < vCount * 3) | ||
3266 | 1406 | eScreen->winNormals.resize (vCount * 3); | ||
3267 | 1407 | |||
3268 | 1408 | if (!window->onAllViewports ()) | ||
3269 | 1409 | { | ||
3270 | 1410 | offset = eScreen->cScreen->windowPaintOffset (); | ||
3271 | 1411 | offset = window->getMovementForOffset (offset); | ||
3272 | 1412 | } | ||
3273 | 1413 | |||
3274 | 1414 | v = gWindow->geometry ().vertices + | ||
3275 | 1415 | (gWindow->geometry ().vertexStride - 3); | ||
3276 | 1416 | |||
3277 | 1417 | for (i = 0; i < vCount; i++) | ||
3278 | 1418 | { | ||
3279 | 1419 | x = (float) (v[0] + offset.x () - screen->width () / 2) * | ||
3280 | 1420 | eScreen->curveAngle / screen->width (); | ||
3281 | 1421 | |||
3282 | 1422 | while (x < 0) | ||
3283 | 1423 | x += 360.0; | ||
3284 | 1424 | |||
3285 | 1425 | idx = floor (x); | ||
3286 | 1426 | |||
3287 | 1427 | eScreen->winNormals[i * 3] = -eScreen->vpNormals[idx * 3]; | ||
3288 | 1428 | eScreen->winNormals[(i * 3) + 1] = | ||
3289 | 1429 | eScreen->vpNormals[(idx * 3) + 1]; | ||
3290 | 1430 | eScreen->winNormals[(i * 3) + 2] = | ||
3291 | 1431 | eScreen->vpNormals[(idx * 3) + 2]; | ||
3292 | 1432 | |||
3293 | 1433 | v += gWindow->geometry ().vertexStride; | ||
3294 | 1434 | } | ||
3295 | 1435 | |||
3296 | 1436 | glEnable (GL_NORMALIZE); | ||
3297 | 1437 | glNormalPointer (GL_FLOAT,0, &eScreen->winNormals.at (0)); | ||
3298 | 1438 | |||
3299 | 1439 | glEnableClientState (GL_NORMAL_ARRAY); | ||
3300 | 1440 | |||
3301 | 1441 | gWindow->glDrawTexture (texture, attrib, mask); | ||
3302 | 1442 | |||
3303 | 1443 | glDisable (GL_NORMALIZE); | ||
3304 | 1444 | glDisableClientState (GL_NORMAL_ARRAY); | ||
3305 | 1445 | glNormal3f (0.0, 0.0, -1.0); | ||
3306 | 1446 | } | ||
3307 | 1447 | else | ||
3308 | 1448 | { | ||
3309 | 1449 | glEnable (GL_NORMALIZE); | ||
3310 | 1450 | gWindow->glDrawTexture (texture, attrib, mask); | ||
3311 | 1451 | glDisable (GL_NORMALIZE); | ||
3312 | 1452 | } | ||
3313 | 1453 | } | ||
3314 | 1454 | |||
3315 | 1455 | bool | ||
3316 | 1456 | ExpoWindow::glPaint (const GLWindowPaintAttrib& attrib, | ||
3317 | 1457 | const GLMatrix& transform, | ||
3318 | 1458 | const CompRegion& region, | ||
3319 | 1459 | unsigned int mask) | ||
3320 | 1460 | { | ||
3321 | 1461 | GLMatrix wTransform (transform); | ||
3322 | 1462 | GLWindowPaintAttrib wAttrib (attrib); | ||
3323 | 1463 | CompRegion clip (region); | ||
3324 | 1464 | |||
3325 | 1465 | if (eScreen->expoActive) | ||
3326 | 1466 | { | ||
3327 | 1467 | float opacity = 1.0; | ||
3328 | 1468 | bool hide; | ||
3329 | 1469 | bool zoomAnim; | ||
3330 | 1470 | CompPoint vp; | ||
3331 | 1471 | screen->viewportForGeometry (window->geometry (), vp); | ||
3332 | 1472 | |||
3333 | 1473 | zoomAnim = eScreen->optionGetExpoAnimation () == | ||
3334 | 1474 | ExpoScreen::ExpoAnimationZoom; | ||
3335 | 1475 | hide = eScreen->optionGetHideDocks () && | ||
3336 | 1476 | (window->wmType () & CompWindowTypeDockMask); | ||
3337 | 1477 | |||
3338 | 1478 | if (eScreen->expoCam > 0.0) | ||
3339 | 1479 | { | ||
3340 | 1480 | if (eScreen->expoCam < 1.0 && !zoomAnim) | ||
3341 | 1481 | mask |= PAINT_WINDOW_TRANSLUCENT_MASK; | ||
3342 | 1482 | else if (hide) | ||
3343 | 1483 | mask |= PAINT_WINDOW_TRANSLUCENT_MASK; | ||
3344 | 1484 | } | ||
3345 | 1485 | |||
3346 | 1486 | if (!zoomAnim) | ||
3347 | 1487 | opacity = attrib.opacity * eScreen->expoCam; | ||
3348 | 1488 | |||
3349 | 1489 | if (hide) | ||
3350 | 1490 | { | ||
3351 | 1491 | if (zoomAnim && eScreen->paintingVp == eScreen->selectedVp) | ||
3352 | 1492 | opacity = attrib.opacity * | ||
3353 | 1493 | (1 - sigmoidProgress (eScreen->expoCam)); | ||
3354 | 1494 | else | ||
3355 | 1495 | opacity = 0; | ||
3356 | 1496 | } | ||
3357 | 1497 | |||
3358 | 1498 | if (opacity <= 0) | ||
3359 | 1499 | mask |= PAINT_WINDOW_NO_CORE_INSTANCE_MASK; | ||
3360 | 1500 | else | ||
3361 | 1501 | wAttrib.opacity = wAttrib.opacity * opacity; | ||
3362 | 1502 | |||
3363 | 1503 | /* Stretch maximized windows a little so that you don't | ||
3364 | 1504 | * have an awkward gap */ | ||
3365 | 1505 | |||
3366 | 1506 | if (window->state () & MAXIMIZE_STATE && | ||
3367 | 1507 | !window->border ().top) | ||
3368 | 1508 | { | ||
3369 | 1509 | CompOutput *o = &screen->outputDevs ()[screen->outputDeviceForGeometry(window->geometry())]; | ||
3370 | 1510 | float yS = 1.0 + ((o->height () / (float) window->height ()) - 1.0f) * sigmoidProgress (eScreen->expoCam); | ||
3371 | 1511 | wTransform.translate (window->x () + window->width () / 2, | ||
3372 | 1512 | window->y () + window->height (), | ||
3373 | 1513 | 0.0f); | ||
3374 | 1514 | wTransform.scale (1.0f, yS, 1.0f); | ||
3375 | 1515 | wTransform.translate (-(window->x () + window->width () / 2), | ||
3376 | 1516 | -(window->y () + window->height ()), | ||
3377 | 1517 | 0.0f); | ||
3378 | 1518 | |||
3379 | 1519 | if (eScreen->paintingVp != vp) | ||
3380 | 1520 | mask |= PAINT_WINDOW_NO_CORE_INSTANCE_MASK; | ||
3381 | 1521 | |||
3382 | 1522 | mask |= PAINT_WINDOW_TRANSFORMED_MASK; | ||
3383 | 1523 | } | ||
3384 | 1524 | |||
3385 | 1525 | if (std::find (eScreen->dndWindows.begin(), eScreen->dndWindows.end (), window) != eScreen->dndWindows.end ()) | ||
3386 | 1526 | { | ||
3387 | 1527 | if (!eScreen->paintingDndWindow) | ||
3388 | 1528 | { | ||
3389 | 1529 | mask |= PAINT_WINDOW_NO_CORE_INSTANCE_MASK; | ||
3390 | 1530 | } | ||
3391 | 1531 | else | ||
3392 | 1532 | { | ||
3393 | 1533 | mask |= PAINT_WINDOW_TRANSFORMED_MASK; | ||
3394 | 1534 | clip = infiniteRegion; | ||
3395 | 1535 | } | ||
3396 | 1536 | } | ||
3397 | 1537 | } | ||
3398 | 1538 | |||
3399 | 1539 | bool status = gWindow->glPaint (wAttrib, wTransform, clip, mask); | ||
3400 | 1540 | |||
3401 | 1541 | return status; | ||
3402 | 1542 | } | ||
3403 | 1543 | |||
3404 | 1544 | bool | ||
3405 | 1545 | ExpoWindow::damageRect (bool initial, | ||
3406 | 1546 | const CompRect& rect) | ||
3407 | 1547 | { | ||
3408 | 1548 | if (eScreen->expoCam > 0.0f) | ||
3409 | 1549 | eScreen->cScreen->damageScreen (); | ||
3410 | 1550 | |||
3411 | 1551 | return cWindow->damageRect (initial, rect); | ||
3412 | 1552 | } | ||
3413 | 1553 | |||
3414 | 1554 | #define EXPOINITBIND(opt, func) \ | ||
3415 | 1555 | optionSet##opt##Initiate (boost::bind (&ExpoScreen::func, \ | ||
3416 | 1556 | this, _1, _2, _3)); | ||
3417 | 1557 | #define EXPOTERMBIND(opt, func) \ | ||
3418 | 1558 | optionSet##opt##Terminate (boost::bind (&ExpoScreen::func, \ | ||
3419 | 1559 | this, _1, _2, _3)); | ||
3420 | 1560 | |||
3421 | 1561 | ExpoScreen::ExpoScreen (CompScreen *s) : | ||
3422 | 1562 | PluginClassHandler<ExpoScreen, CompScreen> (s), | ||
3423 | 1563 | ExpoOptions (), | ||
3424 | 1564 | cScreen (CompositeScreen::get (s)), | ||
3425 | 1565 | gScreen (GLScreen::get (s)), | ||
3426 | 1566 | expoCam (0.0f), | ||
3427 | 1567 | expoActive (false), | ||
3428 | 1568 | expoMode (false), | ||
3429 | 1569 | dndState (DnDNone), | ||
3430 | 1570 | dndWindows (0), | ||
3431 | 1571 | origVp (s->vp ()), | ||
3432 | 1572 | selectedVp (s->vp ()), | ||
3433 | 1573 | vpUpdateMode (VPUpdateNone), | ||
3434 | 1574 | clickTime (0), | ||
3435 | 1575 | doubleClick (false), | ||
3436 | 1576 | vpNormals (360 * 3), | ||
3437 | 1577 | grabIndex (0), | ||
3438 | 1578 | paintingDndWindow (false), | ||
3439 | 1579 | mGlowTextureProperties (&glowTextureProperties) | ||
3440 | 1580 | { | ||
3441 | 1581 | CompString fname; | ||
3442 | 1582 | CompString pname = "expo"; | ||
3443 | 1583 | CompSize size; | ||
3444 | 1584 | |||
3445 | 1585 | |||
3446 | 1586 | leftKey = XKeysymToKeycode (s->dpy (), XStringToKeysym ("Left")); | ||
3447 | 1587 | rightKey = XKeysymToKeycode (s->dpy (), XStringToKeysym ("Right")); | ||
3448 | 1588 | upKey = XKeysymToKeycode (s->dpy (), XStringToKeysym ("Up")); | ||
3449 | 1589 | downKey = XKeysymToKeycode (s->dpy (), XStringToKeysym ("Down")); | ||
3450 | 1590 | |||
3451 | 1591 | mMoveCursor = XCreateFontCursor (screen->dpy (), XC_fleur); | ||
3452 | 1592 | |||
3453 | 1593 | EXPOINITBIND (ExpoKey, doExpo); | ||
3454 | 1594 | EXPOTERMBIND (ExpoKey, termExpo); | ||
3455 | 1595 | EXPOINITBIND (ExpoButton, doExpo); | ||
3456 | 1596 | EXPOTERMBIND (ExpoButton, termExpo); | ||
3457 | 1597 | EXPOINITBIND (ExpoEdge, doExpo); | ||
3458 | 1598 | EXPOTERMBIND (ExpoButton, termExpo); | ||
3459 | 1599 | |||
3460 | 1600 | EXPOINITBIND (DndButton, dndInit); | ||
3461 | 1601 | EXPOTERMBIND (DndButton, dndFini); | ||
3462 | 1602 | EXPOINITBIND (ExitButton, exitExpo); | ||
3463 | 1603 | EXPOINITBIND (NextVpButton, nextVp); | ||
3464 | 1604 | EXPOINITBIND (PrevVpButton, prevVp); | ||
3465 | 1605 | |||
3466 | 1606 | ScreenInterface::setHandler (screen, false); | ||
3467 | 1607 | CompositeScreenInterface::setHandler (cScreen, false); | ||
3468 | 1608 | GLScreenInterface::setHandler (gScreen, false); | ||
3469 | 1609 | |||
3470 | 1610 | outline_texture = GLTexture::imageDataToTexture (mGlowTextureProperties->textureData, | ||
3471 | 1611 | CompSize (mGlowTextureProperties->textureSize, | ||
3472 | 1612 | mGlowTextureProperties->textureSize), | ||
3473 | 1613 | GL_RGBA, GL_UNSIGNED_BYTE); | ||
3474 | 1614 | fname = "texture_tile.png"; | ||
3475 | 1615 | polkadots_texture = GLTexture::readImageToTexture (fname, pname, polkadots_texture_size); | ||
3476 | 1616 | |||
3477 | 1617 | if (polkadots_texture.empty ()) | ||
3478 | 1618 | compLogMessage ("expo", CompLogLevelWarn, "failed to bind image to texture"); | ||
3479 | 1619 | else | ||
3480 | 1620 | { | ||
3481 | 1621 | foreach (GLTexture *tex, polkadots_texture) | ||
3482 | 1622 | { | ||
3483 | 1623 | tex->enable (GLTexture::Good); | ||
3484 | 1624 | glTexParameteri (tex->target (), GL_TEXTURE_WRAP_S, GL_REPEAT); | ||
3485 | 1625 | glTexParameteri (tex->target (), GL_TEXTURE_WRAP_T, GL_REPEAT); | ||
3486 | 1626 | tex->disable (); | ||
3487 | 1627 | } | ||
3488 | 1628 | } | ||
3489 | 1629 | } | ||
3490 | 1630 | |||
3491 | 1631 | ExpoScreen::~ExpoScreen () | ||
3492 | 1632 | { | ||
3493 | 1633 | if (mMoveCursor) | ||
3494 | 1634 | XFreeCursor (screen->dpy (), mMoveCursor); | ||
3495 | 1635 | } | ||
3496 | 1636 | |||
3497 | 1637 | void | ||
3498 | 1638 | ExpoWindow::resizeNotify(int dx, int dy, int dw, int dh) | ||
3499 | 1639 | { | ||
3500 | 1640 | window->resizeNotify (dx, dy, dw, dh); | ||
3501 | 1641 | |||
3502 | 1642 | /* mGlowQuads contains positional info, so we need to recalc that */ | ||
3503 | 1643 | if (mGlowQuads) | ||
3504 | 1644 | { | ||
3505 | 1645 | /* FIXME: we need to find a more multitexture friendly way | ||
3506 | 1646 | * of doing this */ | ||
3507 | 1647 | GLTexture::Matrix tMat = eScreen->outline_texture.at (0)->matrix (); | ||
3508 | 1648 | computeGlowQuads (&tMat); | ||
3509 | 1649 | } | ||
3510 | 1650 | } | ||
3511 | 1651 | |||
3512 | 1652 | ExpoWindow::ExpoWindow (CompWindow *w) : | ||
3513 | 1653 | PluginClassHandler<ExpoWindow, CompWindow> (w), | ||
3514 | 1654 | window (w), | ||
3515 | 1655 | cWindow (CompositeWindow::get (w)), | ||
3516 | 1656 | gWindow (GLWindow::get (w)), | ||
3517 | 1657 | eScreen (ExpoScreen::get (screen)), | ||
3518 | 1658 | dndOpacity (0.0f), | ||
3519 | 1659 | mGlowQuads (NULL) | ||
3520 | 1660 | { | ||
3521 | 1661 | CompositeWindowInterface::setHandler (cWindow, false); | ||
3522 | 1662 | GLWindowInterface::setHandler (gWindow, false); | ||
3523 | 1663 | WindowInterface::setHandler (window, true); | ||
3524 | 1664 | |||
3525 | 1665 | if (window->type () & CompWindowTypeDesktopMask) | ||
3526 | 1666 | { | ||
3527 | 1667 | foreach (GLTexture *tex, eScreen->outline_texture) | ||
3528 | 1668 | { | ||
3529 | 1669 | GLTexture::Matrix mat = tex->matrix (); | ||
3530 | 1670 | computeGlowQuads (&mat); | ||
3531 | 1671 | } | ||
3532 | 1672 | } | ||
3533 | 1673 | } | ||
3534 | 1674 | |||
3535 | 1675 | ExpoWindow::~ExpoWindow () | ||
3536 | 1676 | { | ||
3537 | 1677 | eScreen->dndWindows.remove (window); | ||
3538 | 1678 | computeGlowQuads (NULL); | ||
3539 | 1679 | } | ||
3540 | 1680 | |||
3541 | 1681 | bool | ||
3542 | 1682 | ExpoPluginVTable::init () | ||
3543 | 1683 | { | ||
3544 | 1684 | if (!CompPlugin::checkPluginABI ("core", CORE_ABIVERSION) || | ||
3545 | 1685 | !CompPlugin::checkPluginABI ("composite", COMPIZ_COMPOSITE_ABI) || | ||
3546 | 1686 | !CompPlugin::checkPluginABI ("opengl", COMPIZ_OPENGL_ABI)) | ||
3547 | 1687 | return false; | ||
3548 | 1688 | |||
3549 | 1689 | return true; | ||
3550 | 1690 | } | ||
3551 | 1691 | |||
3552 | 1692 | |||
3553 | 1693 | 0 | ||
3554 | === removed directory '.pc/fix_930192.patch' | |||
3555 | === removed directory '.pc/fix_930192.patch/animation' | |||
3556 | === removed directory '.pc/fix_930192.patch/animation/src' | |||
3557 | === removed file '.pc/fix_930192.patch/animation/src/animation.cpp' | |||
3558 | --- .pc/fix_930192.patch/animation/src/animation.cpp 2012-03-21 11:46:41 +0000 | |||
3559 | +++ .pc/fix_930192.patch/animation/src/animation.cpp 1970-01-01 00:00:00 +0000 | |||
3560 | @@ -1,2962 +0,0 @@ | |||
3561 | 1 | /** | ||
3562 | 2 | * Animation plugin for compiz/beryl | ||
3563 | 3 | * | ||
3564 | 4 | * animation.c | ||
3565 | 5 | * | ||
3566 | 6 | * Copyright : (C) 2006 Erkin Bahceci | ||
3567 | 7 | * E-mail : erkinbah@gmail.com | ||
3568 | 8 | * | ||
3569 | 9 | * Based on Wobbly and Minimize plugins by | ||
3570 | 10 | * : David Reveman | ||
3571 | 11 | * E-mail : davidr@novell.com> | ||
3572 | 12 | * | ||
3573 | 13 | * Airplane added by : Carlo Palma | ||
3574 | 14 | * E-mail : carlopalma@salug.it | ||
3575 | 15 | * Based on code originally written by Mark J. Kilgard | ||
3576 | 16 | * | ||
3577 | 17 | * Beam-Up added by : Florencio Guimaraes | ||
3578 | 18 | * E-mail : florencio@nexcorp.com.br | ||
3579 | 19 | * | ||
3580 | 20 | * Fold and Skewer added by : Tomasz Kolodziejski | ||
3581 | 21 | * E-mail : tkolodziejski@gmail.com | ||
3582 | 22 | * | ||
3583 | 23 | * Hexagon tessellator added by : Mike Slegeir | ||
3584 | 24 | * E-mail : mikeslegeir@mail.utexas.edu> | ||
3585 | 25 | * | ||
3586 | 26 | * Particle system added by : (C) 2006 Dennis Kasprzyk | ||
3587 | 27 | * E-mail : onestone@beryl-project.org | ||
3588 | 28 | * | ||
3589 | 29 | * This program is free software; you can redistribute it and/or | ||
3590 | 30 | * modify it under the terms of the GNU General Public License | ||
3591 | 31 | * as published by the Free Software Foundation; either version 2 | ||
3592 | 32 | * of the License, or (at your option) any later version. | ||
3593 | 33 | * | ||
3594 | 34 | * This program is distributed in the hope that it will be useful, | ||
3595 | 35 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
3596 | 36 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
3597 | 37 | * GNU General Public License for more details. | ||
3598 | 38 | * | ||
3599 | 39 | * You should have received a copy of the GNU General Public License | ||
3600 | 40 | * along with this program; if not, write to the Free Software | ||
3601 | 41 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | ||
3602 | 42 | **/ | ||
3603 | 43 | |||
3604 | 44 | /* | ||
3605 | 45 | * TODO: | ||
3606 | 46 | * | ||
3607 | 47 | * - Custom bounding box update function for Airplane | ||
3608 | 48 | * | ||
3609 | 49 | * - Auto direction option: Close in opposite direction of opening | ||
3610 | 50 | * - Proper side surface normals for lighting | ||
3611 | 51 | * - decoration shadows | ||
3612 | 52 | * - shadow quad generation | ||
3613 | 53 | * - shadow texture coords (from clip tex. matrices) | ||
3614 | 54 | * - draw shadows | ||
3615 | 55 | * - fade in shadows | ||
3616 | 56 | * | ||
3617 | 57 | * - Voronoi tessellation | ||
3618 | 58 | * - Brick tessellation | ||
3619 | 59 | * - Triangle tessellation | ||
3620 | 60 | * - Hexagonal tessellation | ||
3621 | 61 | * | ||
3622 | 62 | * Effects: | ||
3623 | 63 | * - Circular action for tornado type fx | ||
3624 | 64 | * - Tornado 3D (especially for minimize) | ||
3625 | 65 | * - Helix 3D (hor. strips descend while they rotate and fade in) | ||
3626 | 66 | * - Glass breaking 3D | ||
3627 | 67 | * - Gaussian distr. points (for gradually increasing polygon size | ||
3628 | 68 | * starting from center or near mouse pointer) | ||
3629 | 69 | * - Drawing cracks | ||
3630 | 70 | * - Gradual cracking | ||
3631 | 71 | * | ||
3632 | 72 | * - fix slowness during transparent cube with <100 opacity | ||
3633 | 73 | * - fix occasional wrong side color in some windows | ||
3634 | 74 | * - fix on top windows and panels | ||
3635 | 75 | * (These two only matter for viewing during Rotate Cube. | ||
3636 | 76 | * All windows should be painted with depth test on | ||
3637 | 77 | * like 3d-plugin does) | ||
3638 | 78 | * - play better with rotate (fix cube face drawn on top of polygons | ||
3639 | 79 | * after 45 deg. rotation) | ||
3640 | 80 | * | ||
3641 | 81 | */ | ||
3642 | 82 | |||
3643 | 83 | #include <GL/glu.h> | ||
3644 | 84 | #include <core/atoms.h> | ||
3645 | 85 | #include <sys/time.h> | ||
3646 | 86 | #include <assert.h> | ||
3647 | 87 | #include "private.h" | ||
3648 | 88 | |||
3649 | 89 | using namespace compiz::core; | ||
3650 | 90 | |||
3651 | 91 | class AnimPluginVTable : | ||
3652 | 92 | public CompPlugin::VTableForScreenAndWindow<AnimScreen, AnimWindow> | ||
3653 | 93 | { | ||
3654 | 94 | public: | ||
3655 | 95 | bool init (); | ||
3656 | 96 | void fini (); | ||
3657 | 97 | }; | ||
3658 | 98 | |||
3659 | 99 | COMPIZ_PLUGIN_20090315 (animation, AnimPluginVTable); | ||
3660 | 100 | |||
3661 | 101 | #define FAKE_ICON_SIZE 4 | ||
3662 | 102 | |||
3663 | 103 | const char *eventNames[AnimEventNum] = | ||
3664 | 104 | {"Open", "Close", "Minimize", "Shade", "Focus"}; | ||
3665 | 105 | |||
3666 | 106 | int chosenEffectOptionIds[AnimEventNum] = | ||
3667 | 107 | { | ||
3668 | 108 | AnimationOptions::OpenEffects, | ||
3669 | 109 | AnimationOptions::CloseEffects, | ||
3670 | 110 | AnimationOptions::MinimizeEffects, | ||
3671 | 111 | AnimationOptions::ShadeEffects, | ||
3672 | 112 | AnimationOptions::FocusEffects | ||
3673 | 113 | }; | ||
3674 | 114 | |||
3675 | 115 | int randomEffectOptionIds[AnimEventNum] = | ||
3676 | 116 | { | ||
3677 | 117 | AnimationOptions::OpenRandomEffects, | ||
3678 | 118 | AnimationOptions::CloseRandomEffects, | ||
3679 | 119 | AnimationOptions::MinimizeRandomEffects, | ||
3680 | 120 | AnimationOptions::ShadeRandomEffects, | ||
3681 | 121 | -1 | ||
3682 | 122 | }; | ||
3683 | 123 | |||
3684 | 124 | int customOptionOptionIds[AnimEventNum] = | ||
3685 | 125 | { | ||
3686 | 126 | AnimationOptions::OpenOptions, | ||
3687 | 127 | AnimationOptions::CloseOptions, | ||
3688 | 128 | AnimationOptions::MinimizeOptions, | ||
3689 | 129 | AnimationOptions::ShadeOptions, | ||
3690 | 130 | AnimationOptions::FocusOptions | ||
3691 | 131 | }; | ||
3692 | 132 | |||
3693 | 133 | int matchOptionIds[AnimEventNum] = | ||
3694 | 134 | { | ||
3695 | 135 | AnimationOptions::OpenMatches, | ||
3696 | 136 | AnimationOptions::CloseMatches, | ||
3697 | 137 | AnimationOptions::MinimizeMatches, | ||
3698 | 138 | AnimationOptions::ShadeMatches, | ||
3699 | 139 | AnimationOptions::FocusMatches | ||
3700 | 140 | }; | ||
3701 | 141 | |||
3702 | 142 | int durationOptionIds[AnimEventNum] = | ||
3703 | 143 | { | ||
3704 | 144 | AnimationOptions::OpenDurations, | ||
3705 | 145 | AnimationOptions::CloseDurations, | ||
3706 | 146 | AnimationOptions::MinimizeDurations, | ||
3707 | 147 | AnimationOptions::ShadeDurations, | ||
3708 | 148 | AnimationOptions::FocusDurations | ||
3709 | 149 | }; | ||
3710 | 150 | |||
3711 | 151 | // Bind each effect in the list of chosen effects for every event, to the | ||
3712 | 152 | // corresponding animation effect (i.e. effect with that name) if it is | ||
3713 | 153 | // provided by a plugin, otherwise set it to None. | ||
3714 | 154 | void | ||
3715 | 155 | PrivateAnimScreen::updateEventEffects (AnimEvent e, | ||
3716 | 156 | bool forRandom, | ||
3717 | 157 | bool callPost) | ||
3718 | 158 | { | ||
3719 | 159 | CompOption::Value::Vector *listVal; | ||
3720 | 160 | EffectSet *effectSet; | ||
3721 | 161 | if (forRandom) | ||
3722 | 162 | { | ||
3723 | 163 | listVal = &getOptions ()[(unsigned)randomEffectOptionIds[e]].value (). | ||
3724 | 164 | list (); | ||
3725 | 165 | effectSet = &mRandomEffects[e]; | ||
3726 | 166 | } | ||
3727 | 167 | else | ||
3728 | 168 | { | ||
3729 | 169 | listVal = &getOptions ()[(unsigned)chosenEffectOptionIds[e]].value (). | ||
3730 | 170 | list (); | ||
3731 | 171 | effectSet = &mEventEffects[e]; | ||
3732 | 172 | } | ||
3733 | 173 | unsigned int n = listVal->size (); | ||
3734 | 174 | |||
3735 | 175 | effectSet->effects.clear (); | ||
3736 | 176 | effectSet->effects.reserve (n); | ||
3737 | 177 | |||
3738 | 178 | AnimEffectVector &eventEffectsAllowed = mEventEffectsAllowed[e]; | ||
3739 | 179 | |||
3740 | 180 | for (unsigned int r = 0; r < n; r++) // for each row | ||
3741 | 181 | { | ||
3742 | 182 | const CompString &animName = (*listVal)[r].s (); | ||
3743 | 183 | |||
3744 | 184 | // Find the animation effect with matching name | ||
3745 | 185 | AnimEffectVector::iterator it = | ||
3746 | 186 | find_if (eventEffectsAllowed.begin (), | ||
3747 | 187 | eventEffectsAllowed.end (), | ||
3748 | 188 | boost::bind (&AnimEffectInfo::matchesEffectName, | ||
3749 | 189 | _1, animName)); | ||
3750 | 190 | |||
3751 | 191 | effectSet->effects.push_back (it == eventEffectsAllowed.end () ? | ||
3752 | 192 | AnimEffectNone : *it); | ||
3753 | 193 | } | ||
3754 | 194 | |||
3755 | 195 | if (callPost) | ||
3756 | 196 | { | ||
3757 | 197 | foreach (ExtensionPluginInfo *extPlugin, mExtensionPlugins) | ||
3758 | 198 | extPlugin->postUpdateEventEffects (e, forRandom); | ||
3759 | 199 | } | ||
3760 | 200 | } | ||
3761 | 201 | |||
3762 | 202 | void | ||
3763 | 203 | PrivateAnimScreen::updateAllEventEffects () | ||
3764 | 204 | { | ||
3765 | 205 | // for each anim event | ||
3766 | 206 | for (int e = 0; e < AnimEventNum; e++) | ||
3767 | 207 | updateEventEffects ((AnimEvent)e, false); | ||
3768 | 208 | |||
3769 | 209 | // for each anim event except focus | ||
3770 | 210 | for (int e = 0; e < AnimEventNum - 1; e++) | ||
3771 | 211 | updateEventEffects ((AnimEvent)e, true); | ||
3772 | 212 | } | ||
3773 | 213 | |||
3774 | 214 | bool | ||
3775 | 215 | PrivateAnimScreen::isAnimEffectInList (AnimEffect theEffect, | ||
3776 | 216 | EffectSet &effectList) | ||
3777 | 217 | { | ||
3778 | 218 | for (unsigned int i = 0; i < effectList.effects.size (); i++) | ||
3779 | 219 | if (effectList.effects[i] == theEffect) | ||
3780 | 220 | return true; | ||
3781 | 221 | return false; | ||
3782 | 222 | } | ||
3783 | 223 | |||
3784 | 224 | bool | ||
3785 | 225 | PrivateAnimScreen::isAnimEffectPossibleForEvent (AnimEffect theEffect, | ||
3786 | 226 | AnimEvent event) | ||
3787 | 227 | { | ||
3788 | 228 | // Check all rows to see if the effect is chosen there | ||
3789 | 229 | unsigned int nRows = mEventEffects[event].effects.size (); | ||
3790 | 230 | for (unsigned int i = 0; i < nRows; i++) | ||
3791 | 231 | { | ||
3792 | 232 | AnimEffect chosenEffect = mEventEffects[event].effects[i]; | ||
3793 | 233 | // if chosen directly | ||
3794 | 234 | if (chosenEffect == theEffect) | ||
3795 | 235 | return true; | ||
3796 | 236 | // if chosen in random pool | ||
3797 | 237 | if (mRandomEffects[event].effects.size () && | ||
3798 | 238 | chosenEffect == AnimEffectRandom && | ||
3799 | 239 | isAnimEffectInList (theEffect, mRandomEffects[event])) | ||
3800 | 240 | return true; | ||
3801 | 241 | } | ||
3802 | 242 | return false; | ||
3803 | 243 | } | ||
3804 | 244 | |||
3805 | 245 | bool | ||
3806 | 246 | PrivateAnimScreen::isAnimEffectPossible (AnimEffect theEffect) | ||
3807 | 247 | { | ||
3808 | 248 | for (int e = 0; e < AnimEventNum; e++) | ||
3809 | 249 | if (isAnimEffectPossibleForEvent (theEffect, (AnimEvent)e)) | ||
3810 | 250 | return true; | ||
3811 | 251 | return false; | ||
3812 | 252 | } | ||
3813 | 253 | |||
3814 | 254 | bool | ||
3815 | 255 | PrivateAnimScreen::isRestackAnimPossible () | ||
3816 | 256 | { | ||
3817 | 257 | // Check all rows to see if the chosen effect is a restack animation | ||
3818 | 258 | unsigned int nRows = mEventEffects[AnimEventFocus].effects.size (); | ||
3819 | 259 | |||
3820 | 260 | for (unsigned int i = 0; i < nRows; i++) | ||
3821 | 261 | { | ||
3822 | 262 | AnimEffect chosenEffect = mEventEffects[(unsigned)AnimEventFocus]. | ||
3823 | 263 | effects[i]; | ||
3824 | 264 | if (chosenEffect->isRestackAnim) | ||
3825 | 265 | return true; | ||
3826 | 266 | } | ||
3827 | 267 | return false; | ||
3828 | 268 | } | ||
3829 | 269 | |||
3830 | 270 | bool | ||
3831 | 271 | AnimScreen::isRestackAnimPossible () | ||
3832 | 272 | { | ||
3833 | 273 | return priv->isRestackAnimPossible (); | ||
3834 | 274 | } | ||
3835 | 275 | |||
3836 | 276 | // Extension functions | ||
3837 | 277 | |||
3838 | 278 | void | ||
3839 | 279 | AnimScreen::addExtension (ExtensionPluginInfo *extensionPluginInfo) | ||
3840 | 280 | { | ||
3841 | 281 | priv->addExtension (extensionPluginInfo, true); | ||
3842 | 282 | } | ||
3843 | 283 | |||
3844 | 284 | void | ||
3845 | 285 | PrivateAnimScreen::addExtension (ExtensionPluginInfo *extensionPluginInfo, | ||
3846 | 286 | bool shouldInitPersistentData) | ||
3847 | 287 | { | ||
3848 | 288 | mExtensionPlugins.push_back (extensionPluginInfo); | ||
3849 | 289 | |||
3850 | 290 | unsigned int nPluginEffects = extensionPluginInfo->nEffects; | ||
3851 | 291 | |||
3852 | 292 | bool eventEffectsNeedUpdate[AnimEventNum] = | ||
3853 | 293 | {false, false, false, false, false}; | ||
3854 | 294 | |||
3855 | 295 | // Put this plugin's effects into mEventEffects and | ||
3856 | 296 | // mEventEffectsAllowed | ||
3857 | 297 | for (unsigned int j = 0; j < nPluginEffects; j++) | ||
3858 | 298 | { | ||
3859 | 299 | const AnimEffect effect = extensionPluginInfo->effects[j]; | ||
3860 | 300 | |||
3861 | 301 | // Update allowed effects for each event | ||
3862 | 302 | for (int e = 0; e < AnimEventNum; e++) | ||
3863 | 303 | { | ||
3864 | 304 | if (effect->usedForEvents[e]) | ||
3865 | 305 | { | ||
3866 | 306 | mEventEffectsAllowed[e].push_back (effect); | ||
3867 | 307 | eventEffectsNeedUpdate[e] = true; | ||
3868 | 308 | } | ||
3869 | 309 | } | ||
3870 | 310 | } | ||
3871 | 311 | |||
3872 | 312 | for (int e = 0; e < AnimEventNum; e++) | ||
3873 | 313 | if (eventEffectsNeedUpdate[e]) | ||
3874 | 314 | { | ||
3875 | 315 | updateEventEffects ((AnimEvent)e, false, false); | ||
3876 | 316 | if (e != AnimEventFocus) | ||
3877 | 317 | updateEventEffects ((AnimEvent)e, true, false); | ||
3878 | 318 | } | ||
3879 | 319 | |||
3880 | 320 | if (shouldInitPersistentData) | ||
3881 | 321 | { | ||
3882 | 322 | const CompWindowList &pl = pushLockedPaintList (); | ||
3883 | 323 | // Initialize persistent window data for the extension plugin | ||
3884 | 324 | foreach (CompWindow *w, pl) | ||
3885 | 325 | { | ||
3886 | 326 | AnimWindow *aw = AnimWindow::get (w); | ||
3887 | 327 | extensionPluginInfo->initPersistentData (aw); | ||
3888 | 328 | } | ||
3889 | 329 | |||
3890 | 330 | popLockedPaintList (); | ||
3891 | 331 | } | ||
3892 | 332 | } | ||
3893 | 333 | |||
3894 | 334 | void | ||
3895 | 335 | AnimScreen::removeExtension (ExtensionPluginInfo *extensionPluginInfo) | ||
3896 | 336 | { | ||
3897 | 337 | priv->removeExtension (extensionPluginInfo); | ||
3898 | 338 | } | ||
3899 | 339 | |||
3900 | 340 | void | ||
3901 | 341 | PrivateAnimScreen::removeExtension (ExtensionPluginInfo *extensionPluginInfo) | ||
3902 | 342 | { | ||
3903 | 343 | // Stop all ongoing animations | ||
3904 | 344 | const CompWindowList &pl = pushLockedPaintList (); | ||
3905 | 345 | |||
3906 | 346 | foreach (CompWindow *w, pl) | ||
3907 | 347 | { | ||
3908 | 348 | PrivateAnimWindow *aw = AnimWindow::get (w)->priv; | ||
3909 | 349 | if (aw->curAnimation ()) | ||
3910 | 350 | aw->postAnimationCleanUp (); | ||
3911 | 351 | } | ||
3912 | 352 | |||
3913 | 353 | popLockedPaintList (); | ||
3914 | 354 | |||
3915 | 355 | // Find the matching plugin and delete it | ||
3916 | 356 | |||
3917 | 357 | ExtensionPluginVector::iterator it = find (mExtensionPlugins.begin (), | ||
3918 | 358 | mExtensionPlugins.end (), | ||
3919 | 359 | extensionPluginInfo); | ||
3920 | 360 | |||
3921 | 361 | if (it == mExtensionPlugins.end ()) | ||
3922 | 362 | return; // couldn't find that extension plugin | ||
3923 | 363 | |||
3924 | 364 | mExtensionPlugins.erase (it); | ||
3925 | 365 | |||
3926 | 366 | if (extensionPluginInfo->nEffects == 0) | ||
3927 | 367 | return; // no animation effects -> we're done here | ||
3928 | 368 | |||
3929 | 369 | |||
3930 | 370 | // Also delete the "allowed effect" entries for that plugin | ||
3931 | 371 | |||
3932 | 372 | for (int e = 0; e < AnimEventNum; e++) | ||
3933 | 373 | { | ||
3934 | 374 | AnimEffectVector &eventEffectsAllowed = mEventEffectsAllowed[e]; | ||
3935 | 375 | |||
3936 | 376 | // Find the first animation effect with matching name | ||
3937 | 377 | AnimEffectVector::iterator itBeginEffect = | ||
3938 | 378 | find_if (eventEffectsAllowed.begin (), | ||
3939 | 379 | eventEffectsAllowed.end (), | ||
3940 | 380 | boost::bind (&AnimEffectInfo::matchesPluginName, | ||
3941 | 381 | _1, extensionPluginInfo->name)); | ||
3942 | 382 | |||
3943 | 383 | if (itBeginEffect == eventEffectsAllowed.end ()) | ||
3944 | 384 | continue; // plugin didn't provide any effects for this event | ||
3945 | 385 | |||
3946 | 386 | // Find the first animation effect with non-matching name, | ||
3947 | 387 | // starting with itBeginEffect | ||
3948 | 388 | AnimEffectVector::iterator itEndEffect = | ||
3949 | 389 | find_if (itBeginEffect, | ||
3950 | 390 | eventEffectsAllowed.end (), | ||
3951 | 391 | boost::bind (&AnimEffectInfo::matchesPluginName, | ||
3952 | 392 | _1, extensionPluginInfo->name) == false); | ||
3953 | 393 | |||
3954 | 394 | eventEffectsAllowed.erase (itBeginEffect, itEndEffect); | ||
3955 | 395 | |||
3956 | 396 | // Update event effects to complete removal | ||
3957 | 397 | updateEventEffects ((AnimEvent)e, false); | ||
3958 | 398 | if (e != AnimEventFocus) | ||
3959 | 399 | updateEventEffects ((AnimEvent)e, true); | ||
3960 | 400 | } | ||
3961 | 401 | |||
3962 | 402 | const CompWindowList &cpl = pushLockedPaintList (); | ||
3963 | 403 | |||
3964 | 404 | // Destroy persistent window data for the extension plugin | ||
3965 | 405 | foreach (CompWindow *w, cpl) | ||
3966 | 406 | { | ||
3967 | 407 | AnimWindow *aw = AnimWindow::get (w); | ||
3968 | 408 | extensionPluginInfo->destroyPersistentData (aw); | ||
3969 | 409 | } | ||
3970 | 410 | |||
3971 | 411 | popLockedPaintList (); | ||
3972 | 412 | } | ||
3973 | 413 | |||
3974 | 414 | ExtensionPluginInfo::ExtensionPluginInfo (const CompString &name, | ||
3975 | 415 | unsigned int nEffects, | ||
3976 | 416 | AnimEffect *effects, | ||
3977 | 417 | CompOption::Vector *effectOptions, | ||
3978 | 418 | unsigned int firstEffectOptionIndex) : | ||
3979 | 419 | name (name), | ||
3980 | 420 | nEffects (nEffects), | ||
3981 | 421 | effects (effects), | ||
3982 | 422 | effectOptions (effectOptions), | ||
3983 | 423 | firstEffectOptionIndex (firstEffectOptionIndex) | ||
3984 | 424 | { | ||
3985 | 425 | } | ||
3986 | 426 | |||
3987 | 427 | // End of extension functions | ||
3988 | 428 | |||
3989 | 429 | Animation::Animation (CompWindow *w, | ||
3990 | 430 | WindowEvent curWindowEvent, | ||
3991 | 431 | float duration, | ||
3992 | 432 | const AnimEffect info, | ||
3993 | 433 | const CompRect &icon) : | ||
3994 | 434 | mWindow (w), | ||
3995 | 435 | mAWindow (AnimWindow::get (w)), | ||
3996 | 436 | mTotalTime (duration), | ||
3997 | 437 | mRemainingTime (duration), | ||
3998 | 438 | mTimeElapsedWithinTimeStep (0), | ||
3999 | 439 | mOverrideProgressDir (0), | ||
4000 | 440 | mCurPaintAttrib (GLWindow::defaultPaintAttrib), | ||
4001 | 441 | mStoredOpacity (CompositeWindow::get (w)->opacity ()), | ||
4002 | 442 | mCurWindowEvent (curWindowEvent), | ||
4003 | 443 | mInitialized (false), // store window opacity | ||
4004 | 444 | mInfo (info), | ||
4005 | 445 | mIcon (icon) | ||
4006 | 446 | { | ||
4007 | 447 | if (curWindowEvent == WindowEventShade || | ||
4008 | 448 | curWindowEvent == WindowEventUnshade) | ||
4009 | 449 | { | ||
4010 | 450 | mDecorTopHeight = w->output ().top; | ||
4011 | 451 | mDecorBottomHeight = w->output ().bottom; | ||
4012 | 452 | } | ||
4013 | 453 | |||
4014 | 454 | texturesCache = new GLTexture::List (GLWindow::get (w)->textures ()); | ||
4015 | 455 | PrivateAnimScreen *as = mAWindow->priv->paScreen (); | ||
4016 | 456 | |||
4017 | 457 | mTimestep = as->optionGetTimeStep (); | ||
4018 | 458 | } | ||
4019 | 459 | |||
4020 | 460 | Animation::~Animation () | ||
4021 | 461 | { | ||
4022 | 462 | delete texturesCache; | ||
4023 | 463 | } | ||
4024 | 464 | |||
4025 | 465 | CompOption::Value & | ||
4026 | 466 | Animation::optVal (unsigned int optionId) | ||
4027 | 467 | { | ||
4028 | 468 | return mAWindow->pluginOptVal (getExtensionPluginInfo (), optionId, this); | ||
4029 | 469 | } | ||
4030 | 470 | |||
4031 | 471 | /// Play the animation effect backwards from where it left off. | ||
4032 | 472 | void | ||
4033 | 473 | Animation::reverse () | ||
4034 | 474 | { | ||
4035 | 475 | mRemainingTime = mTotalTime - mRemainingTime; | ||
4036 | 476 | |||
4037 | 477 | // avoid window remains | ||
4038 | 478 | if (mRemainingTime <= 0) | ||
4039 | 479 | mRemainingTime = 1; | ||
4040 | 480 | |||
4041 | 481 | switch (mCurWindowEvent) // the old event | ||
4042 | 482 | { | ||
4043 | 483 | case WindowEventOpen: | ||
4044 | 484 | mCurWindowEvent = WindowEventClose; | ||
4045 | 485 | break; | ||
4046 | 486 | case WindowEventClose: | ||
4047 | 487 | mCurWindowEvent = WindowEventOpen; | ||
4048 | 488 | break; | ||
4049 | 489 | case WindowEventMinimize: | ||
4050 | 490 | mCurWindowEvent = WindowEventUnminimize; | ||
4051 | 491 | break; | ||
4052 | 492 | case WindowEventUnminimize: | ||
4053 | 493 | mCurWindowEvent = WindowEventMinimize; | ||
4054 | 494 | break; | ||
4055 | 495 | case WindowEventShade: | ||
4056 | 496 | mCurWindowEvent = WindowEventUnshade; | ||
4057 | 497 | break; | ||
4058 | 498 | case WindowEventUnshade: | ||
4059 | 499 | mCurWindowEvent = WindowEventShade; | ||
4060 | 500 | break; | ||
4061 | 501 | default: | ||
4062 | 502 | break; | ||
4063 | 503 | } | ||
4064 | 504 | |||
4065 | 505 | // 1: forward, 2: backward (3 - progressDir is opposite direction) | ||
4066 | 506 | int progressDir = 1; | ||
4067 | 507 | |||
4068 | 508 | switch (mCurWindowEvent) // the new event | ||
4069 | 509 | { | ||
4070 | 510 | case WindowEventClose: | ||
4071 | 511 | case WindowEventMinimize: | ||
4072 | 512 | case WindowEventShade: | ||
4073 | 513 | progressDir = 2; | ||
4074 | 514 | break; | ||
4075 | 515 | default: | ||
4076 | 516 | break; | ||
4077 | 517 | } | ||
4078 | 518 | |||
4079 | 519 | if (mOverrideProgressDir == 0) | ||
4080 | 520 | mOverrideProgressDir = progressDir; | ||
4081 | 521 | else if (mOverrideProgressDir == 3 - progressDir) | ||
4082 | 522 | mOverrideProgressDir = 0; // disable override | ||
4083 | 523 | } | ||
4084 | 524 | |||
4085 | 525 | PartialWindowAnim::PartialWindowAnim (CompWindow *w, | ||
4086 | 526 | WindowEvent curWindowEvent, | ||
4087 | 527 | float duration, | ||
4088 | 528 | const AnimEffect info, | ||
4089 | 529 | const CompRect &icon) : | ||
4090 | 530 | Animation::Animation (w, curWindowEvent, duration, info, icon), | ||
4091 | 531 | mUseDrawRegion (false), | ||
4092 | 532 | mDrawRegion () | ||
4093 | 533 | { | ||
4094 | 534 | } | ||
4095 | 535 | |||
4096 | 536 | void | ||
4097 | 537 | PrivateAnimWindow::updateSelectionRow (unsigned int r) | ||
4098 | 538 | { | ||
4099 | 539 | mPrevAnimSelectionRow = mCurAnimSelectionRow; | ||
4100 | 540 | mCurAnimSelectionRow = (int)r; | ||
4101 | 541 | } | ||
4102 | 542 | |||
4103 | 543 | // Assumes events in the metadata are in | ||
4104 | 544 | // [Open, Close, Minimize, Focus, Shade] order | ||
4105 | 545 | // and effects among those are in alphabetical order | ||
4106 | 546 | // but with "(Event) None" first and "(Event) Random" last. | ||
4107 | 547 | AnimEffect | ||
4108 | 548 | PrivateAnimScreen::getMatchingAnimSelection (CompWindow *w, | ||
4109 | 549 | AnimEvent e, | ||
4110 | 550 | int *duration) | ||
4111 | 551 | { | ||
4112 | 552 | PrivateAnimWindow *aw = AnimWindow::get (w)->priv; | ||
4113 | 553 | |||
4114 | 554 | EffectSet *eventEffects = &mEventEffects[e]; | ||
4115 | 555 | CompOption::Value &valMatch = | ||
4116 | 556 | getOptions ()[(unsigned)matchOptionIds[e]].value (); | ||
4117 | 557 | CompOption::Value &valDuration = | ||
4118 | 558 | getOptions ()[(unsigned)durationOptionIds[e]].value (); | ||
4119 | 559 | CompOption::Value &valCustomOptions = | ||
4120 | 560 | getOptions ()[(unsigned)customOptionOptionIds[e]].value (); | ||
4121 | 561 | |||
4122 | 562 | unsigned int nRows = valMatch.list ().size (); | ||
4123 | 563 | if (nRows != eventEffects->effects.size () || | ||
4124 | 564 | nRows != valDuration.list ().size () || | ||
4125 | 565 | nRows != valCustomOptions.list ().size ()) | ||
4126 | 566 | { | ||
4127 | 567 | compLogMessage ("animation", CompLogLevelError, | ||
4128 | 568 | "Animation settings mismatch in \"Animation " | ||
4129 | 569 | "Selection\" list for %s event.", eventNames[e]); | ||
4130 | 570 | return AnimEffectNone; | ||
4131 | 571 | } | ||
4132 | 572 | |||
4133 | 573 | // Find the first row that matches this window for this event | ||
4134 | 574 | for (unsigned int i = 0; i < nRows; i++) | ||
4135 | 575 | { | ||
4136 | 576 | if (!valMatch.list ()[i].match ().evaluate (w)) | ||
4137 | 577 | continue; | ||
4138 | 578 | |||
4139 | 579 | aw->updateSelectionRow (i); | ||
4140 | 580 | |||
4141 | 581 | if (duration) | ||
4142 | 582 | *duration = valDuration.list ()[i].i (); | ||
4143 | 583 | |||
4144 | 584 | AnimEffect effect = eventEffects->effects[i]; | ||
4145 | 585 | |||
4146 | 586 | return (effect ? effect : AnimEffectNone); | ||
4147 | 587 | } | ||
4148 | 588 | |||
4149 | 589 | return AnimEffectNone; | ||
4150 | 590 | } | ||
4151 | 591 | |||
4152 | 592 | AnimEffect | ||
4153 | 593 | PrivateAnimScreen::getActualEffect (AnimEffect effect, | ||
4154 | 594 | AnimEvent animEvent) | ||
4155 | 595 | { | ||
4156 | 596 | bool allRandom = optionGetAllRandom (); | ||
4157 | 597 | AnimEffectVector *randomEffects = &mRandomEffects[animEvent].effects; | ||
4158 | 598 | unsigned int nRandomEffects = randomEffects->size (); | ||
4159 | 599 | unsigned int nFirstRandomEffect = 0; | ||
4160 | 600 | |||
4161 | 601 | if ((effect == AnimEffectRandom) || allRandom) | ||
4162 | 602 | { | ||
4163 | 603 | if (nRandomEffects == 0) // no random animation selected, assume "all" | ||
4164 | 604 | { | ||
4165 | 605 | randomEffects = &mEventEffectsAllowed[animEvent]; | ||
4166 | 606 | |||
4167 | 607 | // exclude None and Random | ||
4168 | 608 | nFirstRandomEffect = 2; | ||
4169 | 609 | nRandomEffects = randomEffects->size () - 2; | ||
4170 | 610 | } | ||
4171 | 611 | unsigned int index = nFirstRandomEffect + | ||
4172 | 612 | (unsigned int)(nRandomEffects * (double)rand () / RAND_MAX); | ||
4173 | 613 | return (*randomEffects)[index]; | ||
4174 | 614 | } | ||
4175 | 615 | else | ||
4176 | 616 | return effect; | ||
4177 | 617 | } | ||
4178 | 618 | |||
4179 | 619 | /// Converts animation direction (up, down, left, right, random, auto) | ||
4180 | 620 | /// to an actual direction (up, down, left, or right). | ||
4181 | 621 | AnimDirection | ||
4182 | 622 | Animation::getActualAnimDirection (AnimDirection dir, | ||
4183 | 623 | bool openDir) | ||
4184 | 624 | { | ||
4185 | 625 | if (dir == AnimDirectionRandom) | ||
4186 | 626 | { | ||
4187 | 627 | dir = (AnimDirection)(rand () % 4); | ||
4188 | 628 | } | ||
4189 | 629 | else if (dir == AnimDirectionAuto) | ||
4190 | 630 | { | ||
4191 | 631 | CompRect outRect (mAWindow->savedRectsValid () ? | ||
4192 | 632 | mAWindow->savedOutRect () : | ||
4193 | 633 | mWindow->outputRect ()); | ||
4194 | 634 | |||
4195 | 635 | // away from icon | ||
4196 | 636 | int centerX = outRect.x () + outRect.width () / 2 ; | ||
4197 | 637 | int centerY = outRect.y () + outRect.height () / 2 ; | ||
4198 | 638 | float relDiffX = ((float)centerX - mIcon.x ()) / outRect.width (); | ||
4199 | 639 | float relDiffY = ((float)centerY - mIcon.y ()) / outRect.height (); | ||
4200 | 640 | |||
4201 | 641 | if (openDir) | ||
4202 | 642 | { | ||
4203 | 643 | if (mCurWindowEvent == WindowEventMinimize || | ||
4204 | 644 | mCurWindowEvent == WindowEventUnminimize) | ||
4205 | 645 | // min/unmin. should always result in +/- y direction | ||
4206 | 646 | dir = (mIcon.y () < (int)::screen->height () - mIcon.y ()) ? | ||
4207 | 647 | AnimDirectionDown : AnimDirectionUp; | ||
4208 | 648 | else if (fabs (relDiffY) > fabs (relDiffX)) | ||
4209 | 649 | dir = relDiffY > 0 ? AnimDirectionDown : AnimDirectionUp; | ||
4210 | 650 | else | ||
4211 | 651 | dir = relDiffX > 0 ? AnimDirectionRight : AnimDirectionLeft; | ||
4212 | 652 | } | ||
4213 | 653 | else | ||
4214 | 654 | { | ||
4215 | 655 | if (mCurWindowEvent == WindowEventMinimize || | ||
4216 | 656 | mCurWindowEvent == WindowEventUnminimize) | ||
4217 | 657 | // min/unmin. should always result in +/- y direction | ||
4218 | 658 | dir = (mIcon.y () < (int)::screen->height () - mIcon.y ()) ? | ||
4219 | 659 | AnimDirectionUp : AnimDirectionDown; | ||
4220 | 660 | else if (fabs (relDiffY) > fabs (relDiffX)) | ||
4221 | 661 | dir = relDiffY > 0 ? AnimDirectionUp : AnimDirectionDown; | ||
4222 | 662 | else | ||
4223 | 663 | dir = relDiffX > 0 ? AnimDirectionLeft : AnimDirectionRight; | ||
4224 | 664 | } | ||
4225 | 665 | } | ||
4226 | 666 | return dir; | ||
4227 | 667 | } | ||
4228 | 668 | |||
4229 | 669 | float | ||
4230 | 670 | Animation::progressLinear () | ||
4231 | 671 | { | ||
4232 | 672 | float forwardProgress = | ||
4233 | 673 | 1 - mRemainingTime / (mTotalTime - mTimestep); | ||
4234 | 674 | forwardProgress = MIN (forwardProgress, 1); | ||
4235 | 675 | forwardProgress = MAX (forwardProgress, 0); | ||
4236 | 676 | |||
4237 | 677 | if (mCurWindowEvent == WindowEventOpen || | ||
4238 | 678 | mCurWindowEvent == WindowEventUnminimize || | ||
4239 | 679 | mCurWindowEvent == WindowEventUnshade || | ||
4240 | 680 | mCurWindowEvent == WindowEventFocus) | ||
4241 | 681 | forwardProgress = 1 - forwardProgress; | ||
4242 | 682 | |||
4243 | 683 | return forwardProgress; | ||
4244 | 684 | } | ||
4245 | 685 | |||
4246 | 686 | float | ||
4247 | 687 | Animation::progressEaseInEaseOut () | ||
4248 | 688 | { | ||
4249 | 689 | float forwardProgress = | ||
4250 | 690 | 1 - mRemainingTime / (mTotalTime - mTimestep); | ||
4251 | 691 | forwardProgress = MIN (forwardProgress, 1); | ||
4252 | 692 | forwardProgress = MAX (forwardProgress, 0); | ||
4253 | 693 | |||
4254 | 694 | // Apply sigmoid and normalize | ||
4255 | 695 | forwardProgress = | ||
4256 | 696 | (sigmoid (forwardProgress) - sigmoid (0)) / | ||
4257 | 697 | (sigmoid (1) - sigmoid (0)); | ||
4258 | 698 | |||
4259 | 699 | if (mCurWindowEvent == WindowEventOpen || | ||
4260 | 700 | mCurWindowEvent == WindowEventUnminimize || | ||
4261 | 701 | mCurWindowEvent == WindowEventUnshade || | ||
4262 | 702 | mCurWindowEvent == WindowEventFocus) | ||
4263 | 703 | forwardProgress = 1 - forwardProgress; | ||
4264 | 704 | |||
4265 | 705 | return forwardProgress; | ||
4266 | 706 | } | ||
4267 | 707 | |||
4268 | 708 | /// Gives some acceleration (when closing a window) | ||
4269 | 709 | /// or deceleration (when opening a window). | ||
4270 | 710 | /// Applies a sigmoid with slope s, | ||
4271 | 711 | /// where minx and maxx are the | ||
4272 | 712 | /// starting and ending points on the sigmoid. | ||
4273 | 713 | float | ||
4274 | 714 | Animation::progressDecelerateCustom (float progress, float minx, float maxx) | ||
4275 | 715 | { | ||
4276 | 716 | float x = 1 - progress; | ||
4277 | 717 | float s = 8; | ||
4278 | 718 | |||
4279 | 719 | return | ||
4280 | 720 | 1 - ((sigmoid2 (minx + (x * (maxx - minx)), s) - sigmoid2 (minx, s)) / | ||
4281 | 721 | (sigmoid2 (maxx, s) - sigmoid2 (minx, s))); | ||
4282 | 722 | } | ||
4283 | 723 | |||
4284 | 724 | float | ||
4285 | 725 | Animation::progressDecelerate (float progress) | ||
4286 | 726 | { | ||
4287 | 727 | return progressDecelerateCustom (progress, 0.5, 0.75); | ||
4288 | 728 | } | ||
4289 | 729 | |||
4290 | 730 | BoxPtr | ||
4291 | 731 | AnimWindow::BB () | ||
4292 | 732 | { | ||
4293 | 733 | return &priv->mBB; | ||
4294 | 734 | } | ||
4295 | 735 | |||
4296 | 736 | CompRegion & | ||
4297 | 737 | AnimWindow::stepRegion () | ||
4298 | 738 | { | ||
4299 | 739 | return priv->mStepRegion; | ||
4300 | 740 | } | ||
4301 | 741 | |||
4302 | 742 | void | ||
4303 | 743 | PrivateAnimWindow::copyResetStepRegion () | ||
4304 | 744 | { | ||
4305 | 745 | mLastStepRegion = mStepRegion; | ||
4306 | 746 | |||
4307 | 747 | // Reset bounding box for current step | ||
4308 | 748 | mBB.x1 = mBB.y1 = MAXSHORT; | ||
4309 | 749 | mBB.x2 = mBB.y2 = MINSHORT; | ||
4310 | 750 | } | ||
4311 | 751 | |||
4312 | 752 | void | ||
4313 | 753 | AnimWindow::expandBBWithBox (Box &source) | ||
4314 | 754 | { | ||
4315 | 755 | Box &target = priv->BB (); | ||
4316 | 756 | |||
4317 | 757 | if (source.x1 < target.x1) | ||
4318 | 758 | target.x1 = source.x1; | ||
4319 | 759 | if (source.x2 > target.x2) | ||
4320 | 760 | target.x2 = source.x2; | ||
4321 | 761 | if (source.y1 < target.y1) | ||
4322 | 762 | target.y1 = source.y1; | ||
4323 | 763 | if (source.y2 > target.y2) | ||
4324 | 764 | target.y2 = source.y2; | ||
4325 | 765 | } | ||
4326 | 766 | |||
4327 | 767 | void | ||
4328 | 768 | AnimWindow::expandBBWithPoint (float fx, float fy) | ||
4329 | 769 | { | ||
4330 | 770 | Box &target = priv->BB (); | ||
4331 | 771 | |||
4332 | 772 | short x = MAX (MIN (fx, MAXSHORT - 1), MINSHORT); | ||
4333 | 773 | short y = MAX (MIN (fy, MAXSHORT - 1), MINSHORT); | ||
4334 | 774 | |||
4335 | 775 | if (target.x1 == MAXSHORT) | ||
4336 | 776 | { | ||
4337 | 777 | target.x1 = x; | ||
4338 | 778 | target.y1 = y; | ||
4339 | 779 | target.x2 = x + 1; | ||
4340 | 780 | target.y2 = y + 1; | ||
4341 | 781 | return; | ||
4342 | 782 | } | ||
4343 | 783 | if (x < target.x1) | ||
4344 | 784 | target.x1 = x; | ||
4345 | 785 | else if (x > target.x2) | ||
4346 | 786 | target.x2 = x; | ||
4347 | 787 | |||
4348 | 788 | if (y < target.y1) | ||
4349 | 789 | target.y1 = y; | ||
4350 | 790 | else if (y > target.y2) | ||
4351 | 791 | target.y2 = y; | ||
4352 | 792 | } | ||
4353 | 793 | |||
4354 | 794 | /// This will work for zoom-like 2D transforms, | ||
4355 | 795 | /// but not for glide-like 3D transforms. | ||
4356 | 796 | void | ||
4357 | 797 | AnimWindow::expandBBWithPoint2DTransform (GLVector &coords, | ||
4358 | 798 | GLMatrix &transformMat) | ||
4359 | 799 | { | ||
4360 | 800 | GLVector coordsTransformed = transformMat * coords; | ||
4361 | 801 | expandBBWithPoint (coordsTransformed[GLVector::x], | ||
4362 | 802 | coordsTransformed[GLVector::y]); | ||
4363 | 803 | } | ||
4364 | 804 | |||
4365 | 805 | /// Either points or objects should be non-0. | ||
4366 | 806 | bool | ||
4367 | 807 | AnimWindow::expandBBWithPoints3DTransform (CompOutput &output, | ||
4368 | 808 | GLMatrix &transform, | ||
4369 | 809 | const float *points, | ||
4370 | 810 | GridAnim::GridModel::GridObject *objects, | ||
4371 | 811 | unsigned int nPoints) | ||
4372 | 812 | { | ||
4373 | 813 | GLdouble dModel[16]; | ||
4374 | 814 | GLdouble dProjection[16]; | ||
4375 | 815 | GLdouble x, y, z; | ||
4376 | 816 | for (unsigned int i = 0; i < 16; i++) | ||
4377 | 817 | { | ||
4378 | 818 | dModel[i] = transform[i]; | ||
4379 | 819 | dProjection[i] = GLScreen::get (::screen)->projectionMatrix ()[i]; | ||
4380 | 820 | } | ||
4381 | 821 | GLint viewport[4] = | ||
4382 | 822 | {output.region ()->extents.x1, | ||
4383 | 823 | output.region ()->extents.y1, | ||
4384 | 824 | output.width (), | ||
4385 | 825 | output.height ()}; | ||
4386 | 826 | |||
4387 | 827 | if (points) // use points | ||
4388 | 828 | { | ||
4389 | 829 | for (; nPoints; nPoints--, points += 3) | ||
4390 | 830 | { | ||
4391 | 831 | if (!gluProject (points[0], points[1], points[2], | ||
4392 | 832 | dModel, dProjection, viewport, | ||
4393 | 833 | &x, &y, &z)) | ||
4394 | 834 | return false; | ||
4395 | 835 | |||
4396 | 836 | expandBBWithPoint (x + 0.5, (::screen->height () - y) + 0.5); | ||
4397 | 837 | } | ||
4398 | 838 | } | ||
4399 | 839 | else // use grid model objects | ||
4400 | 840 | { | ||
4401 | 841 | GridAnim::GridModel::GridObject *object = objects; | ||
4402 | 842 | for (; nPoints; nPoints--, object++) | ||
4403 | 843 | { | ||
4404 | 844 | if (!gluProject (object->position ().x (), | ||
4405 | 845 | object->position ().y (), | ||
4406 | 846 | object->position ().z (), | ||
4407 | 847 | dModel, dProjection, viewport, | ||
4408 | 848 | &x, &y, &z)) | ||
4409 | 849 | return false; | ||
4410 | 850 | |||
4411 | 851 | expandBBWithPoint (x + 0.5, (::screen->height () - y) + 0.5); | ||
4412 | 852 | } | ||
4413 | 853 | } | ||
4414 | 854 | return true; | ||
4415 | 855 | } | ||
4416 | 856 | |||
4417 | 857 | void | ||
4418 | 858 | AnimWindow::expandBBWithWindow () | ||
4419 | 859 | { | ||
4420 | 860 | CompRect outRect (savedRectsValid () ? | ||
4421 | 861 | savedOutRect () : | ||
4422 | 862 | mWindow->outputRect ()); | ||
4423 | 863 | Box windowBox = { | ||
4424 | 864 | outRect.x (), outRect.x () + outRect.width (), | ||
4425 | 865 | outRect.y (), outRect.y () + outRect.height () | ||
4426 | 866 | }; | ||
4427 | 867 | expandBBWithBox (windowBox); | ||
4428 | 868 | } | ||
4429 | 869 | |||
4430 | 870 | void | ||
4431 | 871 | AnimWindow::expandBBWithScreen () | ||
4432 | 872 | { | ||
4433 | 873 | Box screenBox = {0, ::screen->width (), | ||
4434 | 874 | 0, ::screen->height ()}; | ||
4435 | 875 | expandBBWithBox (screenBox); | ||
4436 | 876 | } | ||
4437 | 877 | |||
4438 | 878 | void | ||
4439 | 879 | Animation::prepareTransform (CompOutput &output, | ||
4440 | 880 | GLMatrix &resultTransform, | ||
4441 | 881 | GLMatrix &transform) | ||
4442 | 882 | { | ||
4443 | 883 | GLMatrix sTransform; | ||
4444 | 884 | sTransform.toScreenSpace (&output, -DEFAULT_Z_CAMERA); | ||
4445 | 885 | resultTransform = sTransform * transform; | ||
4446 | 886 | } | ||
4447 | 887 | |||
4448 | 888 | void | ||
4449 | 889 | AnimWindow::resetStepRegionWithBB () | ||
4450 | 890 | { | ||
4451 | 891 | // Have a 1 pixel margin to prevent occasional 1 pixel line artifact | ||
4452 | 892 | CompRegion region (priv->mBB.x1 - 1, | ||
4453 | 893 | priv->mBB.y1 - 1, | ||
4454 | 894 | priv->mBB.x2 - priv->mBB.x1 + 2, | ||
4455 | 895 | priv->mBB.y2 - priv->mBB.y1 + 2); | ||
4456 | 896 | priv->mStepRegion = region; | ||
4457 | 897 | } | ||
4458 | 898 | |||
4459 | 899 | /// Damage the union of window's bounding box | ||
4460 | 900 | /// before and after animStepFunc does its job. | ||
4461 | 901 | void | ||
4462 | 902 | PrivateAnimWindow::damageThisAndLastStepRegion () | ||
4463 | 903 | { | ||
4464 | 904 | // Find union of the regions for this step and last step | ||
4465 | 905 | CompRegion totalRegionToDamage (mStepRegion + mLastStepRegion); | ||
4466 | 906 | |||
4467 | 907 | mPAScreen->cScreen->damageRegion (totalRegionToDamage); | ||
4468 | 908 | } | ||
4469 | 909 | |||
4470 | 910 | CompOutput & | ||
4471 | 911 | AnimScreen::output () | ||
4472 | 912 | { | ||
4473 | 913 | return priv->output (); | ||
4474 | 914 | } | ||
4475 | 915 | |||
4476 | 916 | bool | ||
4477 | 917 | AnimScreen::getMousePointerXY (short *x, short *y) | ||
4478 | 918 | { | ||
4479 | 919 | Window w1, w2; | ||
4480 | 920 | int xp, yp, xj, yj; | ||
4481 | 921 | unsigned int m; | ||
4482 | 922 | |||
4483 | 923 | if (XQueryPointer | ||
4484 | 924 | (::screen->dpy (), ::screen->root (), &w1, &w2, &xj, &yj, &xp, &yp, &m)) | ||
4485 | 925 | { | ||
4486 | 926 | *x = xp; | ||
4487 | 927 | *y = yp; | ||
4488 | 928 | return true; | ||
4489 | 929 | } | ||
4490 | 930 | return false; | ||
4491 | 931 | } | ||
4492 | 932 | |||
4493 | 933 | unsigned int | ||
4494 | 934 | PrivateAnimWindow::getState () | ||
4495 | 935 | { | ||
4496 | 936 | Atom actual; | ||
4497 | 937 | int result, format; | ||
4498 | 938 | unsigned long n, left; | ||
4499 | 939 | unsigned char *data; | ||
4500 | 940 | unsigned int retval = WithdrawnState; | ||
4501 | 941 | |||
4502 | 942 | result = XGetWindowProperty (::screen->dpy (), mWindow->id (), | ||
4503 | 943 | Atoms::wmState, 0L, | ||
4504 | 944 | 1L, false, | ||
4505 | 945 | Atoms::wmState, | ||
4506 | 946 | &actual, &format, &n, &left, &data); | ||
4507 | 947 | |||
4508 | 948 | if (result == Success && data) | ||
4509 | 949 | { | ||
4510 | 950 | if (n) | ||
4511 | 951 | memcpy (&retval, data, sizeof (int)); | ||
4512 | 952 | |||
4513 | 953 | XFree ((void *)data); | ||
4514 | 954 | } | ||
4515 | 955 | |||
4516 | 956 | return retval; | ||
4517 | 957 | } | ||
4518 | 958 | |||
4519 | 959 | CompOption::Vector & | ||
4520 | 960 | AnimScreen::getOptions () | ||
4521 | 961 | { | ||
4522 | 962 | return priv->getOptions (); | ||
4523 | 963 | } | ||
4524 | 964 | |||
4525 | 965 | bool | ||
4526 | 966 | AnimScreen::setOption (const CompString &name, | ||
4527 | 967 | CompOption::Value &value) | ||
4528 | 968 | { | ||
4529 | 969 | return priv->setOption (name, value); | ||
4530 | 970 | } | ||
4531 | 971 | |||
4532 | 972 | void | ||
4533 | 973 | PrivateAnimScreen::eventMatchesChanged (CompOption *opt, | ||
4534 | 974 | AnimationOptions::Options num) | ||
4535 | 975 | { | ||
4536 | 976 | if (mExtensionPlugins.size () == 0) | ||
4537 | 977 | initAnimationList (); | ||
4538 | 978 | foreach (CompOption::Value &val, opt->value ().list ()) | ||
4539 | 979 | val.match ().update (); | ||
4540 | 980 | } | ||
4541 | 981 | |||
4542 | 982 | void | ||
4543 | 983 | PrivateAnimScreen::eventOptionsChanged (CompOption *opt, | ||
4544 | 984 | AnimationOptions::Options num) | ||
4545 | 985 | { | ||
4546 | 986 | if (mExtensionPlugins.size () == 0) | ||
4547 | 987 | initAnimationList (); | ||
4548 | 988 | updateOptionSets (getCorrespondingAnimEvent (num)); | ||
4549 | 989 | } | ||
4550 | 990 | |||
4551 | 991 | void | ||
4552 | 992 | PrivateAnimScreen::eventEffectsChanged (CompOption *opt, | ||
4553 | 993 | AnimationOptions::Options num) | ||
4554 | 994 | { | ||
4555 | 995 | if (mExtensionPlugins.size () == 0) | ||
4556 | 996 | initAnimationList (); | ||
4557 | 997 | updateEventEffects (getCorrespondingAnimEvent (num), false); | ||
4558 | 998 | } | ||
4559 | 999 | |||
4560 | 1000 | void | ||
4561 | 1001 | PrivateAnimScreen::eventRandomEffectsChanged (CompOption *opt, | ||
4562 | 1002 | AnimationOptions::Options num) | ||
4563 | 1003 | { | ||
4564 | 1004 | if (mExtensionPlugins.size () == 0) | ||
4565 | 1005 | initAnimationList (); | ||
4566 | 1006 | updateEventEffects (getCorrespondingAnimEvent (num), true); | ||
4567 | 1007 | } | ||
4568 | 1008 | |||
4569 | 1009 | void | ||
4570 | 1010 | PrivateAnimWindow::postAnimationCleanUpCustom (bool closing, | ||
4571 | 1011 | bool destructing, | ||
4572 | 1012 | bool clearMatchingRow) | ||
4573 | 1013 | { | ||
4574 | 1014 | bool shouldDamageWindow = false; | ||
4575 | 1015 | |||
4576 | 1016 | notifyAnimation (false); | ||
4577 | 1017 | |||
4578 | 1018 | if (mCurAnimation) | ||
4579 | 1019 | { | ||
4580 | 1020 | if (mCurAnimation->shouldDamageWindowOnEnd ()) | ||
4581 | 1021 | shouldDamageWindow = true; | ||
4582 | 1022 | } | ||
4583 | 1023 | enablePainting (false); | ||
4584 | 1024 | |||
4585 | 1025 | if (shouldDamageWindow) | ||
4586 | 1026 | mAWindow->expandBBWithWindow (); | ||
4587 | 1027 | |||
4588 | 1028 | if (shouldDamageWindow || | ||
4589 | 1029 | (mCurAnimation && | ||
4590 | 1030 | !mCurAnimation->stepRegionUsed () && | ||
4591 | 1031 | mAWindow->BB ()->x1 != MAXSHORT)) // BB intialized | ||
4592 | 1032 | mAWindow->resetStepRegionWithBB (); | ||
4593 | 1033 | |||
4594 | 1034 | damageThisAndLastStepRegion (); | ||
4595 | 1035 | |||
4596 | 1036 | if (mCurAnimation) | ||
4597 | 1037 | { | ||
4598 | 1038 | mCurAnimation->cleanUp (closing, destructing); | ||
4599 | 1039 | delete mCurAnimation; | ||
4600 | 1040 | mCurAnimation = 0; | ||
4601 | 1041 | } | ||
4602 | 1042 | |||
4603 | 1043 | mBB.x1 = mBB.y1 = MAXSHORT; | ||
4604 | 1044 | mBB.x2 = mBB.y2 = MINSHORT; | ||
4605 | 1045 | |||
4606 | 1046 | mState = mNewState; | ||
4607 | 1047 | |||
4608 | 1048 | if (clearMatchingRow) | ||
4609 | 1049 | mCurAnimSelectionRow = -1; | ||
4610 | 1050 | |||
4611 | 1051 | mFinishingAnim = true; | ||
4612 | 1052 | if (!destructing) | ||
4613 | 1053 | { | ||
4614 | 1054 | mIgnoreDamage = true; | ||
4615 | 1055 | while (mUnmapCnt > 0) | ||
4616 | 1056 | { | ||
4617 | 1057 | mWindow->unmap (); | ||
4618 | 1058 | mUnmapCnt--; | ||
4619 | 1059 | } | ||
4620 | 1060 | if (mUnmapCnt < 0) | ||
4621 | 1061 | mUnmapCnt = 0; | ||
4622 | 1062 | mIgnoreDamage = false; | ||
4623 | 1063 | } | ||
4624 | 1064 | |||
4625 | 1065 | while (mDestroyCnt) | ||
4626 | 1066 | { | ||
4627 | 1067 | mWindow->destroy (); | ||
4628 | 1068 | mDestroyCnt--; | ||
4629 | 1069 | } | ||
4630 | 1070 | mFinishingAnim = false; | ||
4631 | 1071 | |||
4632 | 1072 | foreach (ExtensionPluginInfo *extPlugin, mPAScreen->mExtensionPlugins) | ||
4633 | 1073 | extPlugin->cleanUpAnimation (closing, destructing); | ||
4634 | 1074 | } | ||
4635 | 1075 | |||
4636 | 1076 | void | ||
4637 | 1077 | AnimWindow::postAnimationCleanUp () | ||
4638 | 1078 | { | ||
4639 | 1079 | priv->postAnimationCleanUp (); | ||
4640 | 1080 | } | ||
4641 | 1081 | |||
4642 | 1082 | void | ||
4643 | 1083 | PrivateAnimWindow::postAnimationCleanUp () | ||
4644 | 1084 | { | ||
4645 | 1085 | if (mCurAnimation->curWindowEvent () == WindowEventClose) | ||
4646 | 1086 | postAnimationCleanUpCustom (true, false, true); | ||
4647 | 1087 | else | ||
4648 | 1088 | postAnimationCleanUpCustom (false, false, true); | ||
4649 | 1089 | } | ||
4650 | 1090 | |||
4651 | 1091 | void | ||
4652 | 1092 | PrivateAnimWindow::postAnimationCleanUpPrev (bool closing, | ||
4653 | 1093 | bool clearMatchingRow) | ||
4654 | 1094 | { | ||
4655 | 1095 | int curAnimSelectionRow = mCurAnimSelectionRow; | ||
4656 | 1096 | // Use previous event's anim selection row | ||
4657 | 1097 | mCurAnimSelectionRow = mPrevAnimSelectionRow; | ||
4658 | 1098 | |||
4659 | 1099 | postAnimationCleanUpCustom (closing, false, clearMatchingRow); | ||
4660 | 1100 | |||
4661 | 1101 | // Restore current event's anim selection row | ||
4662 | 1102 | mCurAnimSelectionRow = curAnimSelectionRow; | ||
4663 | 1103 | } | ||
4664 | 1104 | |||
4665 | 1105 | void | ||
4666 | 1106 | PrivateAnimScreen::activateEvent (bool activating) | ||
4667 | 1107 | { | ||
4668 | 1108 | if (activating) | ||
4669 | 1109 | { | ||
4670 | 1110 | if (mAnimInProgress) | ||
4671 | 1111 | return; | ||
4672 | 1112 | } | ||
4673 | 1113 | else | ||
4674 | 1114 | { | ||
4675 | 1115 | // Animations have finished for all windows | ||
4676 | 1116 | // (Keep preparePaint enabled) | ||
4677 | 1117 | |||
4678 | 1118 | aScreen->enableCustomPaintList (false); | ||
4679 | 1119 | } | ||
4680 | 1120 | cScreen->donePaintSetEnabled (this, activating); | ||
4681 | 1121 | gScreen->glPaintOutputSetEnabled (this, activating); | ||
4682 | 1122 | |||
4683 | 1123 | mAnimInProgress = activating; | ||
4684 | 1124 | |||
4685 | 1125 | CompOption::Vector o (0); | ||
4686 | 1126 | |||
4687 | 1127 | o.push_back (CompOption ("root", CompOption::TypeInt)); | ||
4688 | 1128 | o.push_back (CompOption ("active", CompOption::TypeBool)); | ||
4689 | 1129 | |||
4690 | 1130 | o[0].value ().set ((int) ::screen->root ()); | ||
4691 | 1131 | o[1].value ().set (activating); | ||
4692 | 1132 | |||
4693 | 1133 | ::screen->handleCompizEvent ("animation", "activate", o); | ||
4694 | 1134 | } | ||
4695 | 1135 | |||
4696 | 1136 | void | ||
4697 | 1137 | PrivateAnimWindow::notifyAnimation (bool activation) | ||
4698 | 1138 | { | ||
4699 | 1139 | CompOption::Vector o (0); | ||
4700 | 1140 | |||
4701 | 1141 | if (!mCurAnimation) | ||
4702 | 1142 | return; | ||
4703 | 1143 | |||
4704 | 1144 | o.push_back (CompOption ("root", CompOption::TypeInt)); | ||
4705 | 1145 | o.push_back (CompOption ("window", CompOption::TypeInt)); | ||
4706 | 1146 | o.push_back (CompOption ("type", CompOption::TypeString)); | ||
4707 | 1147 | o.push_back (CompOption ("active", CompOption::TypeBool)); | ||
4708 | 1148 | |||
4709 | 1149 | o[0].value ().set ((int) ::screen->root ()); | ||
4710 | 1150 | o[1].value ().set ((int) mWindow->id ()); | ||
4711 | 1151 | |||
4712 | 1152 | switch (mCurAnimation->curWindowEvent ()) | ||
4713 | 1153 | { | ||
4714 | 1154 | case WindowEventOpen: | ||
4715 | 1155 | o[2].value ().set ("open"); | ||
4716 | 1156 | break; | ||
4717 | 1157 | case WindowEventClose: | ||
4718 | 1158 | o[2].value ().set ("close"); | ||
4719 | 1159 | break; | ||
4720 | 1160 | case WindowEventMinimize: | ||
4721 | 1161 | o[2].value ().set ("minimize"); | ||
4722 | 1162 | break; | ||
4723 | 1163 | case WindowEventUnminimize: | ||
4724 | 1164 | o[2].value ().set ("unminimize"); | ||
4725 | 1165 | break; | ||
4726 | 1166 | case WindowEventShade: | ||
4727 | 1167 | o[2].value ().set ("shade"); | ||
4728 | 1168 | break; | ||
4729 | 1169 | case WindowEventUnshade: | ||
4730 | 1170 | o[2].value ().set ("unshade"); | ||
4731 | 1171 | break; | ||
4732 | 1172 | case WindowEventFocus: | ||
4733 | 1173 | o[2].value ().set ("focus"); | ||
4734 | 1174 | break; | ||
4735 | 1175 | case WindowEventNum: | ||
4736 | 1176 | case WindowEventNone: | ||
4737 | 1177 | default: | ||
4738 | 1178 | o[2].value ().set ("none"); | ||
4739 | 1179 | break; | ||
4740 | 1180 | } | ||
4741 | 1181 | |||
4742 | 1182 | o[3].value ().set (activation); | ||
4743 | 1183 | |||
4744 | 1184 | screen->handleCompizEvent ("animation", "window_animation", o); | ||
4745 | 1185 | } | ||
4746 | 1186 | |||
4747 | 1187 | bool | ||
4748 | 1188 | PrivateAnimScreen::otherPluginsActive () | ||
4749 | 1189 | { | ||
4750 | 1190 | for (int i = 0; i < WatchedScreenPluginNum; i++) | ||
4751 | 1191 | if (mPluginActive[i]) | ||
4752 | 1192 | return true; | ||
4753 | 1193 | return false; | ||
4754 | 1194 | } | ||
4755 | 1195 | |||
4756 | 1196 | bool | ||
4757 | 1197 | Animation::shouldSkipFrame (int msSinceLastPaintActual) | ||
4758 | 1198 | { | ||
4759 | 1199 | mTimeElapsedWithinTimeStep += msSinceLastPaintActual; | ||
4760 | 1200 | if (mTimeElapsedWithinTimeStep < mTimestep) // if timestep not yet completed | ||
4761 | 1201 | return true; | ||
4762 | 1202 | |||
4763 | 1203 | mTimeElapsedWithinTimeStep = fmod (mTimeElapsedWithinTimeStep, mTimestep); | ||
4764 | 1204 | return false; | ||
4765 | 1205 | } | ||
4766 | 1206 | |||
4767 | 1207 | bool | ||
4768 | 1208 | Animation::advanceTime (int msSinceLastPaint) | ||
4769 | 1209 | { | ||
4770 | 1210 | mRemainingTime -= msSinceLastPaint; | ||
4771 | 1211 | mRemainingTime = MAX (mRemainingTime, 0); // avoid sub-zero values | ||
4772 | 1212 | |||
4773 | 1213 | mTimeSinceLastPaint = msSinceLastPaint; | ||
4774 | 1214 | |||
4775 | 1215 | return (mRemainingTime > 0); | ||
4776 | 1216 | } | ||
4777 | 1217 | |||
4778 | 1218 | void | ||
4779 | 1219 | PrivateAnimScreen::preparePaint (int msSinceLastPaint) | ||
4780 | 1220 | { | ||
4781 | 1221 | // Check and update "switcher post wait" counter | ||
4782 | 1222 | if (mSwitcherPostWait > 0) | ||
4783 | 1223 | { | ||
4784 | 1224 | mSwitcherPostWait++; | ||
4785 | 1225 | if (mSwitcherPostWait > 5) // wait over | ||
4786 | 1226 | { | ||
4787 | 1227 | mSwitcherPostWait = 0; | ||
4788 | 1228 | |||
4789 | 1229 | // Reset stacking related info since it will | ||
4790 | 1230 | // cause problems because of the restacking | ||
4791 | 1231 | // just done by Switcher. | ||
4792 | 1232 | ExtensionPluginAnimation *extPlugin = | ||
4793 | 1233 | static_cast<ExtensionPluginAnimation *> (mExtensionPlugins[0]); | ||
4794 | 1234 | extPlugin->resetStackingInfo (); | ||
4795 | 1235 | } | ||
4796 | 1236 | } | ||
4797 | 1237 | |||
4798 | 1238 | foreach (ExtensionPluginInfo *extPlugin, mExtensionPlugins) | ||
4799 | 1239 | extPlugin->prePreparePaintGeneral (); | ||
4800 | 1240 | |||
4801 | 1241 | if (mAnimInProgress) | ||
4802 | 1242 | { | ||
4803 | 1243 | int msSinceLastPaintActual; | ||
4804 | 1244 | const CompWindowList &pl = pushLockedPaintList (); | ||
4805 | 1245 | CompWindowList windowsFinishedAnimations; | ||
4806 | 1246 | |||
4807 | 1247 | struct timeval curTime; | ||
4808 | 1248 | gettimeofday (&curTime, 0); | ||
4809 | 1249 | |||
4810 | 1250 | if (mLastRedrawTimeFresh) | ||
4811 | 1251 | { | ||
4812 | 1252 | msSinceLastPaintActual = timer::timeval_diff (&curTime, &mLastRedrawTime); | ||
4813 | 1253 | // handle clock rollback | ||
4814 | 1254 | if (msSinceLastPaintActual < 0) | ||
4815 | 1255 | msSinceLastPaintActual = 0; | ||
4816 | 1256 | } | ||
4817 | 1257 | else | ||
4818 | 1258 | msSinceLastPaintActual = 20; // assume 20 ms passed | ||
4819 | 1259 | |||
4820 | 1260 | mLastRedrawTime = curTime; // Store current time for next time | ||
4821 | 1261 | mLastRedrawTimeFresh = true; | ||
4822 | 1262 | |||
4823 | 1263 | bool animStillInProgress = false; | ||
4824 | 1264 | |||
4825 | 1265 | /* Paint list includes destroyed windows */ | ||
4826 | 1266 | for (CompWindowList::const_reverse_iterator rit = pl.rbegin (); | ||
4827 | 1267 | rit != pl.rend (); rit++) | ||
4828 | 1268 | { | ||
4829 | 1269 | CompWindow *w = (*rit); | ||
4830 | 1270 | AnimWindow *animWin = AnimWindow::get (w); | ||
4831 | 1271 | PrivateAnimWindow *aw = animWin->priv; | ||
4832 | 1272 | Animation *curAnim = aw->curAnimation (); | ||
4833 | 1273 | |||
4834 | 1274 | if (curAnim) | ||
4835 | 1275 | { | ||
4836 | 1276 | if (!curAnim->initialized ()) | ||
4837 | 1277 | curAnim->init (); | ||
4838 | 1278 | |||
4839 | 1279 | if (curAnim->prePreparePaint (msSinceLastPaint)) | ||
4840 | 1280 | animStillInProgress = true; | ||
4841 | 1281 | |||
4842 | 1282 | /* TODO optimize grid model by reusing one GridModel | ||
4843 | 1283 | if (aw->com.mModel && | ||
4844 | 1284 | (aw->com.mModel->winWidth != outRect.width () || | ||
4845 | 1285 | aw->com.mModel->winHeight != outRect.height ())) | ||
4846 | 1286 | { | ||
4847 | 1287 | // mModel needs update | ||
4848 | 1288 | // re-create mModel | ||
4849 | 1289 | if (!animEnsureModel (w)) | ||
4850 | 1290 | { | ||
4851 | 1291 | // Abort this window's animation | ||
4852 | 1292 | postAnimationCleanUp (w); | ||
4853 | 1293 | continue; | ||
4854 | 1294 | } | ||
4855 | 1295 | }*/ | ||
4856 | 1296 | |||
4857 | 1297 | bool animShouldSkipFrame = | ||
4858 | 1298 | (curAnim->shouldSkipFrame (msSinceLastPaintActual) && | ||
4859 | 1299 | // Skip only if we're not on the first animation frame | ||
4860 | 1300 | curAnim->initialized ()); | ||
4861 | 1301 | |||
4862 | 1302 | // Skip only if we're not on the last animation frame | ||
4863 | 1303 | animShouldSkipFrame &= | ||
4864 | 1304 | curAnim->advanceTime (msSinceLastPaint); | ||
4865 | 1305 | |||
4866 | 1306 | if (!animShouldSkipFrame) | ||
4867 | 1307 | { | ||
4868 | 1308 | if (curAnim->updateBBUsed ()) | ||
4869 | 1309 | { | ||
4870 | 1310 | aw->copyResetStepRegion (); | ||
4871 | 1311 | |||
4872 | 1312 | if (!curAnim->initialized () && | ||
4873 | 1313 | curAnim->shouldDamageWindowOnStart ()) | ||
4874 | 1314 | aw->aWindow ()->expandBBWithWindow (); | ||
4875 | 1315 | } | ||
4876 | 1316 | |||
4877 | 1317 | if (!curAnim->initialized ()) | ||
4878 | 1318 | curAnim->setInitialized (); | ||
4879 | 1319 | |||
4880 | 1320 | curAnim->step (); | ||
4881 | 1321 | |||
4882 | 1322 | if (curAnim->updateBBUsed ()) | ||
4883 | 1323 | { | ||
4884 | 1324 | foreach (CompOutput &output, ::screen->outputDevs ()) | ||
4885 | 1325 | curAnim->updateBB (output); | ||
4886 | 1326 | |||
4887 | 1327 | if (!curAnim->stepRegionUsed () && | ||
4888 | 1328 | aw->BB ().x1 != MAXSHORT) // BB initialized | ||
4889 | 1329 | { | ||
4890 | 1330 | // BB is used instead of step region, | ||
4891 | 1331 | // so reset step region here with BB. | ||
4892 | 1332 | animWin->resetStepRegionWithBB (); | ||
4893 | 1333 | } | ||
4894 | 1334 | if (!(cScreen->damageMask () & | ||
4895 | 1335 | COMPOSITE_SCREEN_DAMAGE_ALL_MASK)) | ||
4896 | 1336 | aw->damageThisAndLastStepRegion (); | ||
4897 | 1337 | } | ||
4898 | 1338 | } | ||
4899 | 1339 | |||
4900 | 1340 | bool finished = (curAnim->remainingTime () <= 0); | ||
4901 | 1341 | if (finished) // Animation is done | ||
4902 | 1342 | windowsFinishedAnimations.push_back (w); | ||
4903 | 1343 | else | ||
4904 | 1344 | animStillInProgress = true; | ||
4905 | 1345 | } | ||
4906 | 1346 | } | ||
4907 | 1347 | |||
4908 | 1348 | foreach (CompWindow *w, pl) | ||
4909 | 1349 | { | ||
4910 | 1350 | PrivateAnimWindow *aw = AnimWindow::get (w)->priv; | ||
4911 | 1351 | if (aw->curAnimation ()) | ||
4912 | 1352 | aw->curAnimation ()->postPreparePaint (); | ||
4913 | 1353 | } | ||
4914 | 1354 | |||
4915 | 1355 | popLockedPaintList (); | ||
4916 | 1356 | } | ||
4917 | 1357 | |||
4918 | 1358 | foreach (ExtensionPluginInfo *extPlugin, mExtensionPlugins) | ||
4919 | 1359 | extPlugin->postPreparePaintGeneral (); | ||
4920 | 1360 | |||
4921 | 1361 | cScreen->preparePaint (msSinceLastPaint); | ||
4922 | 1362 | |||
4923 | 1363 | if (mStartCountdown) | ||
4924 | 1364 | { | ||
4925 | 1365 | mStartCountdown--; | ||
4926 | 1366 | if (!mStartCountdown) | ||
4927 | 1367 | { | ||
4928 | 1368 | foreach (ExtensionPluginInfo *extPlugin, mExtensionPlugins) | ||
4929 | 1369 | extPlugin->postStartupCountdown (); | ||
4930 | 1370 | } | ||
4931 | 1371 | } | ||
4932 | 1372 | } | ||
4933 | 1373 | |||
4934 | 1374 | void | ||
4935 | 1375 | PrivateAnimScreen::donePaint () | ||
4936 | 1376 | { | ||
4937 | 1377 | assert (mAnimInProgress); | ||
4938 | 1378 | |||
4939 | 1379 | const CompWindowList &pl = pushLockedPaintList (); | ||
4940 | 1380 | CompWindowList windowsFinishedAnimations; | ||
4941 | 1381 | |||
4942 | 1382 | bool animStillInProgress = false; | ||
4943 | 1383 | |||
4944 | 1384 | /* Paint list includes destroyed windows */ | ||
4945 | 1385 | for (CompWindowList::const_reverse_iterator rit = pl.rbegin (); | ||
4946 | 1386 | rit != pl.rend (); rit++) | ||
4947 | 1387 | { | ||
4948 | 1388 | CompWindow *w = (*rit); | ||
4949 | 1389 | AnimWindow *animWin = AnimWindow::get (w); | ||
4950 | 1390 | PrivateAnimWindow *aw = animWin->priv; | ||
4951 | 1391 | Animation *curAnim = aw->curAnimation (); | ||
4952 | 1392 | |||
4953 | 1393 | if (curAnim) | ||
4954 | 1394 | { | ||
4955 | 1395 | bool finished = (curAnim->remainingTime () <= 0); | ||
4956 | 1396 | if (finished) // Animation is done | ||
4957 | 1397 | windowsFinishedAnimations.push_back (w); | ||
4958 | 1398 | else | ||
4959 | 1399 | animStillInProgress = true; | ||
4960 | 1400 | } | ||
4961 | 1401 | } | ||
4962 | 1402 | |||
4963 | 1403 | popLockedPaintList (); | ||
4964 | 1404 | |||
4965 | 1405 | foreach (CompWindow *w, windowsFinishedAnimations) | ||
4966 | 1406 | { | ||
4967 | 1407 | AnimWindow *aw = AnimWindow::get (w); | ||
4968 | 1408 | aw->priv->notifyAnimation (false); | ||
4969 | 1409 | aw->priv->postAnimationCleanUp (); | ||
4970 | 1410 | } | ||
4971 | 1411 | |||
4972 | 1412 | if (!animStillInProgress) | ||
4973 | 1413 | { | ||
4974 | 1414 | activateEvent (false); | ||
4975 | 1415 | mLastRedrawTimeFresh = false; | ||
4976 | 1416 | |||
4977 | 1417 | // Reset stacking related info after all animations are done. | ||
4978 | 1418 | ExtensionPluginAnimation *extPlugin = | ||
4979 | 1419 | static_cast<ExtensionPluginAnimation *> (mExtensionPlugins[0]); | ||
4980 | 1420 | extPlugin->resetStackingInfo (); | ||
4981 | 1421 | } | ||
4982 | 1422 | |||
4983 | 1423 | cScreen->damagePending (); | ||
4984 | 1424 | |||
4985 | 1425 | cScreen->donePaint (); | ||
4986 | 1426 | } | ||
4987 | 1427 | |||
4988 | 1428 | void | ||
4989 | 1429 | PrivateAnimWindow::enablePainting (bool enabling) | ||
4990 | 1430 | { | ||
4991 | 1431 | gWindow->glPaintSetEnabled (this, enabling); | ||
4992 | 1432 | gWindow->glAddGeometrySetEnabled (this, enabling); | ||
4993 | 1433 | gWindow->glDrawGeometrySetEnabled (this, enabling); | ||
4994 | 1434 | gWindow->glDrawTextureSetEnabled (this, enabling); | ||
4995 | 1435 | } | ||
4996 | 1436 | |||
4997 | 1437 | void | ||
4998 | 1438 | PrivateAnimWindow::glAddGeometry (const GLTexture::MatrixList &matrix, | ||
4999 | 1439 | const CompRegion ®ion, | ||
5000 | 1440 | const CompRegion &clip, |
Changed the branch to not do the change directly in the file but put a patch in debian/patches.