Merge lp:~mniess/ubuntu/precise/compiz-plugins-main/lp953278 into lp:ubuntu/precise/compiz-plugins-main

Proposed by Matthias Niess on 2012-03-26
Status: Merged
Merge reported by: Didier Roche
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
Reviewer Review Type Date Requested Status
Didier Roche Approve on 2012-03-28
Ubuntu branches 2012-03-26 Pending
Review via email: mp+99407@code.launchpad.net

Description of the change

Disabled super+r as bad default for fit_to_window_key (LP: #953278)

To post a comment you must log in.
31. By Matthias Niess on 2012-03-26

* 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 :

Changed the branch to not do the change directly in the file but put a patch in debian/patches.

Didier Roche (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://bazaar.launchpad.net/~compiz/compcomm-plugins-main/ubuntu
(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/patches/ubuntu_config.patch as it's really where this change should be.

Thanks again for your contribution :)
I'm marking this branch as merged then.

review: Approve
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

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

Subscribers

People subscribed via source and target branches