~vanvugt/compiz-animation-plugin/fix-915236

« back to all changes in this revision

Viewing changes to src/private.h

  • Committer: Erkin Bahceci
  • Date: 2009-07-15 16:05:10 UTC
  • Revision ID: git-v1:6eeaa209932c6039edd4c362c352f242468a118a
Initial C++ port. Dodge and magic lamp changes.

- New dodge mode: all windows moving (made the default).
- Fixed dodge artifacts/weirdness showing up in certain situations.
- Magic Lamp renamed to Magic Lamp Wavy.
- Vacuum renamed to Magic Lamp, allowed for minimize (made the default).
- Separated restack stuff (dodge and focus-fade) from animation core.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
#define _GNU_SOURCE
2
1
#include <string.h>
3
2
#include <stdlib.h>
4
3
#include <math.h>
5
4
 
6
 
#include <compiz-core.h>
7
 
#include "compiz-animation.h"
8
 
 
9
 
 
10
 
typedef struct _WaveParam
11
 
{
12
 
    float halfWidth;
13
 
    float amp;
14
 
    float pos;
15
 
} WaveParam;
16
 
 
17
 
typedef enum
18
 
{
19
 
    ZoomFromCenterOff = 0,
20
 
    ZoomFromCenterMin,
21
 
    ZoomFromCenterCreate,
22
 
    ZoomFromCenterOn
23
 
} ZoomFromCenter;
24
 
#define LAST_ZOOM_FROM_CENTER 3
25
 
 
26
 
//TODO remove #define RANDOM_EFFECT_OFFSET 2 /* skip None and Random */
27
 
 
28
 
typedef struct _RestackInfo
29
 
{
 
5
#include <core/core.h>
 
6
#include <composite/composite.h>
 
7
#include <opengl/opengl.h>
 
8
 
 
9
#include <boost/foreach.hpp>
 
10
#define foreach BOOST_FOREACH
 
11
 
 
12
#include <animation/animation.h>
 
13
 
 
14
#include "animation_options.h"
 
15
 
 
16
typedef std::vector<CompWindow *> CompWindowVector;
 
17
typedef std::vector<ExtensionPluginInfo *> ExtensionPluginVector;
 
18
typedef std::vector<AnimEffect> AnimEffectVector;
 
19
 
 
20
 
 
21
class RestackInfo
 
22
{
 
23
public:
 
24
    RestackInfo (CompWindow *wRestacked,
 
25
                 CompWindow *wStart,
 
26
                 CompWindow *wEnd,
 
27
                 CompWindow *wOldAbove,
 
28
                 bool raised);
 
29
 
30
30
    CompWindow *wRestacked, *wStart, *wEnd, *wOldAbove;
31
 
    Bool raised;
32
 
} RestackInfo;
 
31
    bool raised;
 
32
};
33
33
 
34
 
typedef struct _IdValuePair
 
34
class IdValuePair
35
35
{
 
36
public:
 
37
    IdValuePair () : pluginInfo (0), optionId (-1), value () {}
 
38
 
 
39
    bool matchesPluginOption (ExtensionPluginInfo *pluginInfo,
 
40
                              int optionId);
 
41
 
36
42
    const ExtensionPluginInfo *pluginInfo;
37
43
    int optionId;
38
 
    CompOptionValue value;
39
 
} IdValuePair;
40
 
    
41
 
typedef struct _OptionSet
42
 
{
43
 
    int nPairs;
44
 
    IdValuePair *pairs;
45
 
} OptionSet;
46
 
 
47
 
typedef struct _OptionSets
48
 
{
49
 
    int nSets;
50
 
    OptionSet *sets;
51
 
} OptionSets;
52
 
 
53
 
typedef struct _EffectSet
54
 
{
55
 
    int n;
56
 
    AnimEffect *effects;
57
 
} EffectSet;
58
 
 
59
 
extern int animDisplayPrivateIndex;
60
 
extern int animFunctionsPrivateIndex;
61
 
extern CompMetadata animMetadata;
 
44
    CompOption::Value value;
 
45
};
 
46
 
 
47
typedef std::vector<IdValuePair> IdValuePairVector;
 
48
 
 
49
class OptionSet
 
50
{
 
51
public:
 
52
    OptionSet () {}
 
53
 
 
54
    IdValuePairVector pairs;
 
55
};
 
56
 
 
57
typedef std::vector<OptionSet> OptionSetVector;
 
58
 
 
59
class OptionSets
 
60
{
 
61
public:
 
62
    OptionSets () {}
 
63
 
 
64
    OptionSetVector sets;
 
65
};
 
66
 
 
67
class EffectSet
 
68
{
 
69
public:
 
70
    EffectSet () {}
 
71
 
 
72
    AnimEffectVector effects;
 
73
};
62
74
 
63
75
extern AnimEffect AnimEffectNone;
64
76
extern AnimEffect AnimEffectRandom;
71
83
extern AnimEffect AnimEffectGlide2;
72
84
extern AnimEffect AnimEffectHorizontalFolds;
73
85
extern AnimEffect AnimEffectMagicLamp;
 
86
extern AnimEffect AnimEffectMagicLampWavy;
74
87
extern AnimEffect AnimEffectRollUp;
75
88
extern AnimEffect AnimEffectSidekick;
76
 
extern AnimEffect AnimEffectVacuum;
77
89
extern AnimEffect AnimEffectWave;
78
90
extern AnimEffect AnimEffectZoom;
79
91
 
81
93
 
82
94
extern int customOptionOptionIds[AnimEventNum];
83
95
 
84
 
typedef enum _AnimDisplayOptions
85
 
{
86
 
    ANIM_DISPLAY_OPTION_ABI,
87
 
    ANIM_DISPLAY_OPTION_INDEX,
88
 
    ANIM_DISPLAY_OPTION_NUM
89
 
} AnimDisplayOptions;
90
 
 
91
 
typedef struct _AnimDisplay
92
 
{
93
 
    int screenPrivateIndex;
94
 
    HandleEventProc handleEvent;
95
 
    HandleCompizEventProc handleCompizEvent;
96
 
    int activeWindow;
97
 
    CompMatch neverAnimateMatch;
98
 
 
99
 
    CompOption opt[ANIM_DISPLAY_OPTION_NUM];
100
 
} AnimDisplay;
101
 
 
102
96
typedef struct _PluginEventInfo
103
97
{
104
 
    char *pluginName;
105
 
    char *activateEventName;
 
98
    const char *pluginName;
 
99
    const char *activateEventName;
106
100
} PluginEventInfo;
107
101
 
108
 
#define NUM_WATCHED_PLUGINS 5
109
 
 
110
102
typedef enum
111
103
{
112
 
    // Event settings
113
 
    ANIM_SCREEN_OPTION_OPEN_EFFECTS = 0,
114
 
    ANIM_SCREEN_OPTION_OPEN_DURATIONS,
115
 
    ANIM_SCREEN_OPTION_OPEN_MATCHES,
116
 
    ANIM_SCREEN_OPTION_OPEN_OPTIONS,
117
 
    ANIM_SCREEN_OPTION_OPEN_RANDOM_EFFECTS,
118
 
    ANIM_SCREEN_OPTION_CLOSE_EFFECTS,
119
 
    ANIM_SCREEN_OPTION_CLOSE_DURATIONS,
120
 
    ANIM_SCREEN_OPTION_CLOSE_MATCHES,
121
 
    ANIM_SCREEN_OPTION_CLOSE_OPTIONS,
122
 
    ANIM_SCREEN_OPTION_CLOSE_RANDOM_EFFECTS,
123
 
    ANIM_SCREEN_OPTION_MINIMIZE_EFFECTS,
124
 
    ANIM_SCREEN_OPTION_MINIMIZE_DURATIONS,
125
 
    ANIM_SCREEN_OPTION_MINIMIZE_MATCHES,
126
 
    ANIM_SCREEN_OPTION_MINIMIZE_OPTIONS,
127
 
    ANIM_SCREEN_OPTION_MINIMIZE_RANDOM_EFFECTS,
128
 
    ANIM_SCREEN_OPTION_SHADE_EFFECTS,
129
 
    ANIM_SCREEN_OPTION_SHADE_DURATIONS,
130
 
    ANIM_SCREEN_OPTION_SHADE_MATCHES,
131
 
    ANIM_SCREEN_OPTION_SHADE_OPTIONS,
132
 
    ANIM_SCREEN_OPTION_SHADE_RANDOM_EFFECTS,
133
 
    ANIM_SCREEN_OPTION_FOCUS_EFFECTS,
134
 
    ANIM_SCREEN_OPTION_FOCUS_DURATIONS,
135
 
    ANIM_SCREEN_OPTION_FOCUS_MATCHES,
136
 
    ANIM_SCREEN_OPTION_FOCUS_OPTIONS,
137
 
    // Misc. settings
138
 
    ANIM_SCREEN_OPTION_ALL_RANDOM,
139
 
    ANIM_SCREEN_OPTION_TIME_STEP,
140
 
    // Effect settings
141
 
    ANIM_SCREEN_OPTION_CURVED_FOLD_AMP_MULT,
142
 
    ANIM_SCREEN_OPTION_CURVED_FOLD_Z2TOM,
143
 
    ANIM_SCREEN_OPTION_DODGE_GAP_RATIO,
144
 
    ANIM_SCREEN_OPTION_DREAM_Z2TOM,
145
 
    ANIM_SCREEN_OPTION_GLIDE1_AWAY_POS,
146
 
    ANIM_SCREEN_OPTION_GLIDE1_AWAY_ANGLE,
147
 
    ANIM_SCREEN_OPTION_GLIDE1_Z2TOM,
148
 
    ANIM_SCREEN_OPTION_GLIDE2_AWAY_POS,
149
 
    ANIM_SCREEN_OPTION_GLIDE2_AWAY_ANGLE,
150
 
    ANIM_SCREEN_OPTION_GLIDE2_Z2TOM,
151
 
    ANIM_SCREEN_OPTION_HORIZONTAL_FOLDS_AMP_MULT,
152
 
    ANIM_SCREEN_OPTION_HORIZONTAL_FOLDS_NUM_FOLDS,
153
 
    ANIM_SCREEN_OPTION_HORIZONTAL_FOLDS_Z2TOM,
154
 
    ANIM_SCREEN_OPTION_MAGIC_LAMP_MOVING_END,
155
 
    ANIM_SCREEN_OPTION_MAGIC_LAMP_GRID_RES,
156
 
    ANIM_SCREEN_OPTION_MAGIC_LAMP_MAX_WAVES,
157
 
    ANIM_SCREEN_OPTION_MAGIC_LAMP_WAVE_AMP_MIN,
158
 
    ANIM_SCREEN_OPTION_MAGIC_LAMP_WAVE_AMP_MAX,
159
 
    ANIM_SCREEN_OPTION_MAGIC_LAMP_OPEN_START_WIDTH,
160
 
    ANIM_SCREEN_OPTION_ROLLUP_FIXED_INTERIOR,
161
 
    ANIM_SCREEN_OPTION_SIDEKICK_NUM_ROTATIONS,
162
 
    ANIM_SCREEN_OPTION_SIDEKICK_SPRINGINESS,
163
 
    ANIM_SCREEN_OPTION_SIDEKICK_ZOOM_FROM_CENTER,
164
 
    ANIM_SCREEN_OPTION_VACUUM_MOVING_END,
165
 
    ANIM_SCREEN_OPTION_VACUUM_GRID_RES,
166
 
    ANIM_SCREEN_OPTION_VACUUM_OPEN_START_WIDTH,
167
 
    ANIM_SCREEN_OPTION_WAVE_WIDTH,
168
 
    ANIM_SCREEN_OPTION_WAVE_AMP_MULT,
169
 
    ANIM_SCREEN_OPTION_ZOOM_FROM_CENTER,
170
 
    ANIM_SCREEN_OPTION_ZOOM_SPRINGINESS,
171
 
 
172
 
    ANIM_SCREEN_OPTION_NUM
173
 
} AnimScreenOptions;
 
104
    WatchedPluginSwitcher = 0,
 
105
    WatchedPluginScale,
 
106
    WatchedPluginGroup,
 
107
    WatchedPluginFadedesktop,
 
108
    WatchedPluginShift,
 
109
    WatchedPluginNum
 
110
} WatchedPlugin;
174
111
 
175
112
// This must have the value of the first "effect setting" above
176
 
// in AnimScreenOptions
177
 
#define NUM_NONEFFECT_OPTIONS ANIM_SCREEN_OPTION_CURVED_FOLD_AMP_MULT
178
 
 
179
 
 
180
 
typedef struct _AnimScreen
181
 
{
182
 
    int windowPrivateIndex;
183
 
 
184
 
    PreparePaintScreenProc preparePaintScreen;
185
 
    DonePaintScreenProc donePaintScreen;
186
 
    PaintOutputProc paintOutput;
187
 
    PaintWindowProc paintWindow;
188
 
    DamageWindowRectProc damageWindowRect;
189
 
    AddWindowGeometryProc addWindowGeometry;
190
 
    DrawWindowTextureProc drawWindowTexture;
191
 
    InitWindowWalkerProc initWindowWalker;
192
 
 
193
 
    WindowResizeNotifyProc windowResizeNotify;
194
 
    WindowMoveNotifyProc windowMoveNotify;
195
 
    WindowGrabNotifyProc windowGrabNotify;
196
 
    WindowUngrabNotifyProc windowUngrabNotify;
197
 
 
198
 
    CompOption opt[ANIM_SCREEN_OPTION_NUM];
199
 
 
200
 
    Bool aWinWasRestackedJustNow; // a window was restacked this paint round
201
 
 
202
 
    Bool pluginActive[NUM_WATCHED_PLUGINS];
203
 
 
204
 
    Window *lastClientListStacking; // to store last known stacking order
205
 
    int nLastClientListStacking;
206
 
    int markAllWinCreatedCountdown;
207
 
    // to mark windows as "created" if they were opened before compiz
208
 
    // was started
209
 
 
210
 
    Bool animInProgress;
211
 
 
212
 
    int walkerAnimCount; // count of how many windows are currently involved in
213
 
                         // animations that require walker (dodge & focus fade)
214
 
 
215
 
    EffectSet randomEffects[AnimEventNum];
216
 
 
217
 
    OptionSets eventOptionSets[AnimEventNum];
218
 
 
219
 
    // Effect extensions
220
 
    ExtensionPluginInfo **extensionPlugins;
221
 
    unsigned int nExtensionPlugins;
222
 
    unsigned int maxExtensionPlugins;
223
 
 
224
 
    // List of all possible effects for each event
225
 
    AnimEffect *eventEffectsAllowed[AnimEventNum];
226
 
    unsigned int nEventEffectsAllowed[AnimEventNum];
227
 
    unsigned int maxEventEffectsAllowed[AnimEventNum];
 
113
// in PrivateAnimScreenOptions
 
114
#define NUM_NONEFFECT_OPTIONS AnimationOptions::CurvedFoldAmpMult
 
115
 
 
116
 
 
117
class ExtensionPluginAnimation : public ExtensionPluginInfo
 
118
{
 
119
public:
 
120
    ExtensionPluginAnimation (unsigned int nEffects,
 
121
                              AnimEffect *effects,
 
122
                              CompOption::Vector *effectOptions,
 
123
                              unsigned int firstEffectOptionIndex);
 
124
    ~ExtensionPluginAnimation ();
 
125
 
 
126
    // Overriden methods from ExtensionPluginInfo
 
127
    void postPreparePaintGeneral ();
 
128
    void prePreparePaintGeneral ();
 
129
    void handleRestackNotify (AnimWindow *aw);
 
130
    // Always reset stacking related info when a window is opened, closed,
 
131
    // minimized, or unminimized.
 
132
    void preInitiateOpenAnim (AnimWindow *aw);
 
133
    void preInitiateCloseAnim (AnimWindow *aw);
 
134
    void preInitiateMinimizeAnim (AnimWindow *aw);
 
135
    void preInitiateUnminimizeAnim (AnimWindow *aw);
 
136
    void initPersistentData (AnimWindow *aw);
 
137
    void destroyPersistentData (AnimWindow *aw);
 
138
    void postUpdateEventEffects (AnimEvent e,
 
139
                                 bool forRandom);
 
140
    void cleanUpAnimation (bool closing,
 
141
                           bool destructing);
 
142
    void postStartupCountdown ();
 
143
 
 
144
    // Other methods
 
145
    void handleSingleRestack (AnimWindow *aw);
 
146
    void prePaintWindowsBackToFront ();
 
147
    bool paintShouldSkipWindow (CompWindow *w);
 
148
    CompWindowList getWindowPaintList ();
 
149
    void resetStackingInfo ();
 
150
    static CompWindow *getBottommostInExtendedFocusChain (CompWindow *wStartPoint);
 
151
    static CompWindow *getBottommostInRestackChain (CompWindow *wStartPoint);
 
152
    void resetMarks ();
 
153
    bool markNewCopy (CompWindow *w);
 
154
    CompWindow * walkFirst ();
 
155
    CompWindow * walkNext (CompWindow *w);
 
156
    void incrementCurRestackAnimCount ();
 
157
    void decrementCurRestackAnimCount ();
 
158
    bool wontCreateCircularChain (CompWindow *wCur, CompWindow *wNext);
 
159
 
 
160
    static void cleanUpParentChildChainItem (AnimWindow *aw);
 
161
    static bool relevantForRestackAnim (CompWindow *w);
 
162
 
 
163
    /// Is restackInfo still good?
 
164
    static bool restackInfoStillGood (RestackInfo *restackInfo);
 
165
 
 
166
    void updateLastClientList ();
 
167
 
 
168
    /// A window was restacked this paint round.
 
169
    bool mAWinWasRestackedJustNow;
 
170
 
 
171
private:
 
172
    CompWindowVector mLastClientList; ///< Last known stacking order
 
173
    CompWindowVector mPrevClientList; ///< The stacking order before mLastClientList
 
174
    int mRestackAnimCount; ///< Count of how many windows are currently involved in
 
175
                           ///< animations that require walker (dodge & focus fade).
 
176
    std::vector<AnimWindow *> mRestackedWindows;
 
177
};
 
178
 
 
179
class PrivateAnimScreen :
 
180
    public ScreenInterface,
 
181
    public CompositeScreenInterface,
 
182
    public GLScreenInterface,
 
183
    public AnimationOptions
 
184
{
 
185
    friend class PrivateAnimWindow;
 
186
    friend class AnimWindow;
 
187
 
 
188
public:
 
189
    GLScreen *gScreen;
 
190
    CompositeScreen *cScreen;
 
191
    AnimScreen *aScreen;
 
192
 
 
193
private:
 
194
    struct timeval mLastRedrawTime;
 
195
    bool mLastRedrawTimeFresh;
 
196
 
 
197
    bool mPluginActive[WatchedPluginNum];
 
198
    int mSwitcherPostWait;
 
199
 
 
200
    Window mLastActiveWindow; ///< Last known active window
 
201
 
 
202
    bool mAnimInProgress;         ///< Is an animation currently being played?
 
203
    bool mStartingNewPaintRound;  ///< Is a new round of glPaints starting?
 
204
    bool mPrePaintWindowsBackToFrontEnabled;
 
205
 
 
206
    EffectSet mRandomEffects[AnimEventNum];
 
207
 
 
208
    OptionSets mEventOptionSets[AnimEventNum];
 
209
 
 
210
    // Effect extension plugins
 
211
    ExtensionPluginVector mExtensionPlugins;
 
212
 
 
213
    // Possible effects for each event
 
214
    AnimEffectVector mEventEffectsAllowed[AnimEventNum];
228
215
 
229
216
    // List of chosen effects for each event
230
 
    EffectSet eventEffects[AnimEventNum];
231
 
 
232
 
    CompOutput *output;
233
 
} AnimScreen;
234
 
 
235
 
typedef struct _AnimWindow
236
 
{
237
 
    AnimWindowCommon com;
238
 
 
239
 
    unsigned int state;
240
 
    unsigned int newState;
241
 
 
242
 
    Bool animInitialized;       // whether the animation effect (not the window) is initialized
243
 
    float remainderSteps;
244
 
 
245
 
    Bool nowShaded;
246
 
    Bool grabbed;
247
 
 
248
 
    int unmapCnt;
249
 
    int destroyCnt;
250
 
 
251
 
    Bool ignoreDamage;
252
 
 
253
 
    int curAnimSelectionRow;
254
 
    int prevAnimSelectionRow;   // For the case when one event interrupts another
255
 
 
256
 
    Box BB;       // Bounding box for damage region calc. of CompTransform fx
257
 
    Box lastBB;   // Last bounding box
258
 
 
259
 
    // for magic lamp
260
 
    Bool minimizeToTop;
261
 
    int magicLampWaveCount;
262
 
    WaveParam *magicLampWaves;
263
 
 
264
 
    // for glide effect
265
 
    float glideModRotAngle;     // The angle of rotation modulo 360
266
 
 
267
 
    // for zoom
268
 
    float numZoomRotations;
269
 
 
270
 
    // for focus fade & dodge
271
 
    RestackInfo *restackInfo;   // restack info if window was restacked this paint round
272
 
    CompWindow *winToBePaintedBeforeThis; // Window which should be painted before this
273
 
    CompWindow *winThisIsPaintedBefore; // the inverse relation of the above
274
 
    CompWindow *moreToBePaintedPrev; // doubly linked list for windows underneath that
275
 
    CompWindow *moreToBePaintedNext; //   raise together with this one
276
 
    Bool created;
277
 
    Bool configureNotified;     // was configureNotified before restack check
278
 
    CompWindow *winPassingThrough; // win. passing through this one during focus effect
279
 
 
280
 
    // for dodge
281
 
    Bool isDodgeSubject;        // TRUE if this window is the cause of dodging
282
 
    Bool skipPostPrepareScreen;
283
 
    CompWindow *dodgeSubjectWin;// The window being dodged
284
 
    float dodgeMaxAmount;       /* max # pixels it should dodge
285
 
                                   (neg. values dodge left) */
286
 
    int dodgeOrder;             // dodge order (used temporarily)
287
 
    Bool dodgeDirection;        // 0: up, down, left, right
288
 
 
289
 
    CompWindow *dodgeChainStart;// for the subject window
290
 
    CompWindow *dodgeChainPrev; // for dodging windows
291
 
    CompWindow *dodgeChainNext; // for dodging windows
292
 
    Bool walkerOverNewCopy;     // whether walker is on the copy at the new pos.
293
 
    unsigned int walkerVisitCount; // how many times walker has visited this window
294
 
} AnimWindow;
295
 
 
296
 
#define GET_ANIM_DISPLAY(d)                                             \
297
 
    ((AnimDisplay *) (d)->base.privates[animDisplayPrivateIndex].ptr)
298
 
 
299
 
#define ANIM_DISPLAY(d)                         \
300
 
    AnimDisplay *ad = GET_ANIM_DISPLAY (d)
301
 
 
302
 
#define GET_ANIM_SCREEN(s, ad)                                          \
303
 
    ((AnimScreen *) (s)->base.privates[(ad)->screenPrivateIndex].ptr)
304
 
 
305
 
#define ANIM_SCREEN(s)                                                  \
306
 
    AnimScreen *as = GET_ANIM_SCREEN (s, GET_ANIM_DISPLAY (s->display))
307
 
 
308
 
#define GET_ANIM_WINDOW(w, as)                                          \
309
 
    ((AnimWindow *) (w)->base.privates[(as)->windowPrivateIndex].ptr)
310
 
 
311
 
#define ANIM_WINDOW(w)                                       \
312
 
    AnimWindow *aw = GET_ANIM_WINDOW (w,                     \
313
 
                     GET_ANIM_SCREEN (w->screen,             \
314
 
                     GET_ANIM_DISPLAY (w->screen->display)))
315
 
 
316
 
// up, down, left, right
317
 
#define DODGE_AMOUNT(w, dw, dir)                        \
318
 
    ((dir) == 0 ? BORDER_Y(w) - (BORDER_Y(dw) + BORDER_H(dw)) : \
319
 
     (dir) == 1 ? (BORDER_Y(w) + BORDER_H(w)) - BORDER_Y(dw) :  \
320
 
     (dir) == 2 ? BORDER_X(w) - (BORDER_X(dw) + BORDER_W(dw)) : \
321
 
     (BORDER_X(w) + BORDER_W(w)) - BORDER_X(dw))
322
 
 
323
 
// up, down, left, right
324
 
#define DODGE_AMOUNT_BOX(box, dw, dir)                          \
325
 
    ((dir) == 0 ? (box).y - (BORDER_Y(dw) + BORDER_H(dw)) :             \
326
 
     (dir) == 1 ? ((box).y + (box).height) - BORDER_Y(dw) :     \
327
 
     (dir) == 2 ? (box).x - (BORDER_X(dw) + BORDER_W(dw)) :             \
328
 
     ((box).x + (box).width) - BORDER_X(dw))
329
 
 
330
 
// ratio of perceived length of animation compared to real duration
331
 
// to make it appear to have the same speed with other animation effects
332
 
 
333
 
#define DREAM_PERCEIVED_T 0.6f
334
 
#define ROLLUP_PERCEIVED_T 0.6f
335
 
 
336
 
 
337
 
/*
338
 
 * Function prototypes
339
 
 *
340
 
 */
341
 
 
342
 
/* animation.c*/
343
 
 
344
 
void
345
 
modelInitObjects (Model * model,
346
 
                  int x, int y,
347
 
                  int width, int height);
348
 
 
349
 
void
350
 
postAnimationCleanup (CompWindow * w);
351
 
 
352
 
float
353
 
defaultAnimProgress (CompWindow *w);
354
 
 
355
 
float
356
 
sigmoidAnimProgress (CompWindow *w);
357
 
 
358
 
float
359
 
decelerateProgressCustom (float progress,
360
 
                          float minx, float maxx);
361
 
 
362
 
float
363
 
decelerateProgress (float progress);
364
 
 
365
 
void
366
 
applyTransformToObject (Object *obj, GLfloat *mat);
367
 
 
368
 
AnimDirection
369
 
getActualAnimDirection (CompWindow * w,
370
 
                        AnimDirection dir,
371
 
                        Bool openDir);
372
 
 
373
 
void
374
 
defaultAnimStep (CompWindow * w,
375
 
                 float time);
376
 
 
377
 
Bool
378
 
defaultAnimInit (CompWindow * w);
379
 
 
380
 
void
381
 
defaultUpdateWindowTransform (CompWindow *w,
382
 
                              CompTransform *wTransform);
383
 
 
384
 
Bool
385
 
animZoomToIcon (CompWindow *w);
386
 
 
387
 
void
388
 
animDrawWindowGeometry(CompWindow * w);
389
 
 
390
 
Bool
391
 
getMousePointerXY(CompScreen * s, short *x, short *y);
392
 
 
393
 
void
394
 
expandBoxWithBox (Box *target, Box *source);
395
 
 
396
 
void
397
 
expandBoxWithPoint (Box *target, float fx, float fy);
398
 
 
399
 
void
400
 
updateBBWindow (CompOutput *output,
401
 
                CompWindow * w,
402
 
                Box *BB);
403
 
 
404
 
void
405
 
updateBBScreen (CompOutput *output,
406
 
                CompWindow * w,
407
 
                Box *BB);
408
 
 
409
 
void
410
 
compTransformUpdateBB (CompOutput *output,
411
 
                       CompWindow *w,
412
 
                       Box *BB);
413
 
 
414
 
void
415
 
prepareTransform (CompScreen *s,
416
 
                  CompOutput *output,
417
 
                  CompTransform *resultTransform,
418
 
                  CompTransform *transform);
419
 
 
420
 
void
421
 
perspectiveDistortAndResetZ (CompScreen *s,
422
 
                             CompTransform *wTransform);
423
 
 
424
 
void
425
 
applyPerspectiveSkew (CompOutput *output,
426
 
                      CompTransform *transform,
427
 
                      Point *center);
428
 
 
429
 
inline void
430
 
applyTransform (CompTransform *wTransform,
431
 
                CompTransform *transform);
432
 
 
433
 
float
434
 
getProgressAndCenter (CompWindow *w,
435
 
                      Point *center);
436
 
 
437
 
/* curvedfold.c */
438
 
 
439
 
void
440
 
fxCurvedFoldModelStep (CompWindow *w,
441
 
                       float time);
442
 
 
443
 
void
444
 
fxFoldUpdateWindowAttrib (CompWindow * w,
445
 
                          WindowPaintAttrib * wAttrib);
446
 
 
447
 
Bool
448
 
fxCurvedFoldZoomToIcon (CompWindow *w);
449
 
 
450
 
/* dodge.c */
451
 
 
452
 
void
453
 
fxDodgePostPreparePaintScreen (CompWindow *w);
454
 
 
455
 
void
456
 
fxDodgeUpdateWindowTransform (CompWindow *w,
457
 
                              CompTransform *wTransform);
458
 
 
459
 
void
460
 
fxDodgeAnimStep (CompWindow *w,
461
 
                 float time);
462
 
 
463
 
void
464
 
fxDodgeUpdateBB (CompOutput *output,
465
 
                 CompWindow * w,
466
 
                 Box *BB);
467
 
 
468
 
/* dream.c */
469
 
 
470
 
Bool
471
 
fxDreamAnimInit (CompWindow * w);
472
 
 
473
 
void
474
 
fxDreamModelStep (CompWindow * w,
475
 
                  float time);
476
 
 
477
 
void
478
 
fxDreamUpdateWindowAttrib (CompWindow * w,
479
 
                           WindowPaintAttrib * wAttrib);
480
 
 
481
 
Bool
482
 
fxDreamZoomToIcon (CompWindow *w);
483
 
 
484
 
/* fade.c */
485
 
 
486
 
void
487
 
fxFadeUpdateWindowAttrib (CompWindow * w,
488
 
                          WindowPaintAttrib *wAttrib);
489
 
 
490
 
 
491
 
/* focusfade.c */
492
 
 
493
 
void
494
 
fxFocusFadeUpdateWindowAttrib (CompWindow * w,
495
 
                               WindowPaintAttrib *wAttrib);
496
 
 
497
 
/* glide.c */
498
 
 
499
 
Bool
500
 
fxGlideInit (CompWindow *w);
501
 
 
502
 
void
503
 
fxGlideUpdateWindowAttrib (CompWindow * w,
504
 
                           WindowPaintAttrib *wAttrib);
505
 
 
506
 
void
507
 
fxGlideAnimStep (CompWindow *w,
508
 
                 float time);
509
 
 
510
 
float
511
 
fxGlideAnimProgress (CompWindow *w);
512
 
 
513
 
void
514
 
fxGlideUpdateWindowTransform (CompWindow *w,
515
 
                              CompTransform *wTransform);
516
 
 
517
 
void
518
 
fxGlidePrePaintWindow (CompWindow * w);
519
 
 
520
 
void
521
 
fxGlidePostPaintWindow (CompWindow * w);
522
 
 
523
 
Bool
524
 
fxGlideZoomToIcon (CompWindow *w);
525
 
 
526
 
/* horizontalfold.c */
527
 
 
528
 
void
529
 
fxHorizontalFoldsModelStep (CompWindow *w,
530
 
                            float time);
531
 
 
532
 
void
533
 
fxHorizontalFoldsInitGrid (CompWindow *w,
534
 
                           int *gridWidth,
535
 
                           int *gridHeight);
536
 
 
537
 
Bool
538
 
fxHorizontalFoldsZoomToIcon (CompWindow *w);
539
 
 
540
 
/* magiclamp.c */
541
 
 
542
 
void
543
 
fxMagicLampInitGrid (CompWindow *w,
544
 
                     int *gridWidth, 
545
 
                     int *gridHeight);
546
 
 
547
 
void
548
 
fxVacuumInitGrid (CompWindow *w,
549
 
                  int *gridWidth, 
550
 
                  int *gridHeight);
551
 
 
552
 
Bool
553
 
fxMagicLampInit (CompWindow * w);
554
 
 
555
 
void
556
 
fxMagicLampModelStep (CompWindow * w,
557
 
                      float time);
558
 
 
559
 
/* options.c */
560
 
 
561
 
void
562
 
updateOptionSets (CompScreen *s,
563
 
                  AnimEvent e);
564
 
 
565
 
void
566
 
freeAllOptionSets (AnimScreen *as);
567
 
 
568
 
CompOptionValue *
569
 
animGetPluginOptVal (CompWindow *w,
570
 
                     ExtensionPluginInfo *pluginInfo,
571
 
                     int optionId);
572
 
 
573
 
OPTION_GETTERS_HDR
574
 
 
575
 
/* rollup.c */
576
 
 
577
 
void
578
 
fxRollUpModelStep (CompWindow *w,
579
 
                   float time);
580
 
 
581
 
void fxRollUpInitGrid (CompWindow *w,
582
 
                       int *gridWidth,
583
 
                       int *gridHeight);
584
 
 
585
 
Bool
586
 
fxRollUpAnimInit (CompWindow * w);
587
 
 
588
 
/* wave.c */
589
 
 
590
 
void
591
 
fxWaveModelStep (CompWindow * w,
592
 
                 float time);
593
 
 
594
 
 
595
 
/* zoomside.c */
596
 
 
597
 
void
598
 
fxZoomUpdateWindowAttrib (CompWindow * w,
599
 
                          WindowPaintAttrib *wAttrib);
600
 
 
601
 
void
602
 
fxZoomAnimProgress (CompWindow *w,
603
 
                    float *moveProgress,
604
 
                    float *scaleProgress,
605
 
                    Bool neverSpringy);
606
 
 
607
 
Bool
608
 
fxSidekickInit (CompWindow *w);
609
 
 
610
 
Bool
611
 
fxZoomInit (CompWindow * w);
612
 
 
613
 
void
614
 
applyZoomTransform (CompWindow * w);
615
 
 
616
 
void
617
 
getZoomCenterScale (CompWindow *w,
618
 
                    Point *pCurCenter, Point *pCurScale);
 
217
    EffectSet mEventEffects[AnimEventNum];
 
218
 
 
219
    CompOutput *mOutput;
 
220
 
 
221
    Window mActiveWindow;
 
222
    CompMatch mNeverAnimateMatch;
 
223
 
 
224
    int mStartCountdown;
 
225
    ///< To mark windows as "created" if they were opened before compiz
 
226
    ///< was started and to prevent already opened windows from doing
 
227
    ///< open animation.
 
228
 
 
229
    void updateEventEffects (AnimEvent e,
 
230
                             bool forRandom,
 
231
                             bool callPost = true);
 
232
    void updateAllEventEffects ();
 
233
 
 
234
    void updateOptionSets (AnimEvent e);
 
235
    void updateOptionSet (OptionSet *os, const char *optNamesValuesOrig);
 
236
 
 
237
    void activateEvent (bool activating);
 
238
    bool isWinVisible (CompWindow *w);
 
239
    AnimEvent getCorrespondingAnimEvent (AnimationOptions::Options optionId);
 
240
    void eventMatchesChanged (CompOption *opt, AnimationOptions::Options num);
 
241
    void eventOptionsChanged (CompOption *opt, AnimationOptions::Options num);
 
242
    void eventEffectsChanged (CompOption *opt, AnimationOptions::Options num);
 
243
    void eventRandomEffectsChanged (CompOption *opt, AnimationOptions::Options num);
 
244
 
 
245
    CompRect getIcon (CompWindow *w, bool alwaysUseMouse);
 
246
    void updateAnimStillInProgress ();
 
247
 
 
248
    bool isAnimEffectInList (AnimEffect theEffect,
 
249
                             EffectSet &effectList);
 
250
    bool isAnimEffectPossibleForEvent (AnimEffect theEffect,
 
251
                                       AnimEvent event);
 
252
 
 
253
public:
 
254
    PrivateAnimScreen (CompScreen *s, AnimScreen *);
 
255
    ~PrivateAnimScreen ();
 
256
 
 
257
    // Utility methods
 
258
    void initiateOpenAnim (PrivateAnimWindow *aw);
 
259
    void initiateCloseAnim (PrivateAnimWindow *aw);
 
260
    void initiateMinimizeAnim (PrivateAnimWindow *aw);
 
261
    void initiateUnminimizeAnim (PrivateAnimWindow *aw);
 
262
    void initiateShadeAnim (PrivateAnimWindow *aw);
 
263
    void initiateUnshadeAnim (PrivateAnimWindow *aw);
 
264
    bool initiateFocusAnim (PrivateAnimWindow *aw);
 
265
 
 
266
    /// Is a restacking animation currently possible?
 
267
    bool isRestackAnimPossible ();
 
268
 
 
269
    void initAnimationList ();
 
270
    bool isAnimEffectPossible (AnimEffect theEffect);
 
271
    CompOutput &output () { return *mOutput; }
 
272
    AnimEffect getActualEffect (AnimEffect effect,
 
273
                                AnimEvent animEvent);
 
274
    bool shouldIgnoreWindowForAnim (CompWindow *w, bool checkPixmap);
 
275
    OptionSet *getOptionSetForSelectedRow (PrivateAnimWindow *aw,
 
276
                                           Animation *anim);
 
277
    void addExtension (ExtensionPluginInfo *extensionPluginInfo,
 
278
                       bool shouldInitPersistentData);
 
279
    void removeExtension (ExtensionPluginInfo *extensionPluginInfo);
 
280
    AnimEffect getMatchingAnimSelection (CompWindow *w,
 
281
                                         AnimEvent e,
 
282
                                         int *duration);
 
283
    bool otherPluginsActive ();
 
284
 
 
285
    void enablePrePaintWindowsBackToFront (bool enabled);
 
286
    void prePaintWindowsBackToFront ();
 
287
 
 
288
    // CompositeScreenInterface methods
 
289
    void preparePaint (int);
 
290
    void donePaint ();
 
291
    CompWindowList getWindowPaintList ();
 
292
 
 
293
    // GLScreenInterface methods
 
294
    bool glPaintOutput (const GLScreenPaintAttrib &,
 
295
                        const GLMatrix &,
 
296
                        const CompRegion &,
 
297
                        CompOutput *,
 
298
                        unsigned int);
 
299
 
 
300
    // ScreenInterface methods
 
301
    void handleCompizEvent (const char * plugin, const char *event,
 
302
                            CompOption::Vector &options);
 
303
};
 
304
 
 
305
class PrivateAnimWindow :
 
306
    public WindowInterface,
 
307
    public CompositeWindowInterface,
 
308
    public GLWindowInterface
 
309
{
 
310
    friend class PrivateAnimScreen;
 
311
    friend class AnimWindow;
 
312
 
 
313
public:
 
314
    PrivateAnimWindow (CompWindow *, AnimWindow *aw);
 
315
    ~PrivateAnimWindow ();
 
316
 
 
317
    void createFocusAnimation (AnimEffect effect, int duration);
 
318
    inline void setShaded (bool shaded) { mNowShaded = shaded; }
 
319
    inline Animation *curAnimation () { return mCurAnimation; }
 
320
    inline PrivateAnimScreen *paScreen () { return mPAScreen; }
 
321
    inline AnimWindow *aWindow () { return mAWindow; }
 
322
    inline Box &BB () { return mBB; }
 
323
    inline int curAnimSelectionRow () { return mCurAnimSelectionRow; }
 
324
 
 
325
    void damageBoundingBox ();
 
326
    void postAnimationCleanUp ();
 
327
    void copyResetBB ();
 
328
 
 
329
    GLWindow          *gWindow;
 
330
 
 
331
private:
 
332
    CompWindow        *mWindow;
 
333
    CompositeWindow   *mCWindow;
 
334
    AnimWindow        *mAWindow;
 
335
 
 
336
    PrivateAnimScreen *mPAScreen;
 
337
 
 
338
    unsigned int mState;
 
339
    unsigned int mNewState;
 
340
 
 
341
    Animation *mCurAnimation;
 
342
 
 
343
    bool mUnshadePending;
 
344
    bool mEventNotOpenClose;
 
345
    bool mNowShaded;
 
346
    bool mGrabbed;
 
347
 
 
348
    int mUnmapCnt;
 
349
    int mDestroyCnt;
 
350
    int mUpdateFrameCnt;
 
351
 
 
352
    bool mIgnoreDamage;
 
353
    bool mFinishingAnim;
 
354
 
 
355
    int mCurAnimSelectionRow;
 
356
    int mPrevAnimSelectionRow;  ///< For the case when one event interrupts another
 
357
 
 
358
    Box mBB;       ///< Bounding box for damage region calc. of GLMatrix fx
 
359
    Box mLastBB;   ///< Last bounding box
 
360
 
 
361
    // Utility methods
 
362
    unsigned int getState ();
 
363
    void updateSelectionRow (int i);
 
364
    void postAnimationCleanUpPrev (bool closing, bool clearMatchingRow);
 
365
    void postAnimationCleanUpCustom (bool closing,
 
366
                                     bool destructing,
 
367
                                     bool clearMatchingRow);
 
368
    void reverseAnimation ();
 
369
 
 
370
    // WindowInterface methods
 
371
    void resizeNotify (int dx, int dy, int dwidth, int dheight);
 
372
    void moveNotify (int dx, int dy, bool immediate);
 
373
    void windowNotify (CompWindowNotify n);
 
374
    void grabNotify (int x, int y, unsigned int state, unsigned int mask);
 
375
    void ungrabNotify ();
 
376
 
 
377
    // GLWindowInterface methods
 
378
    bool glPaint (const GLWindowPaintAttrib &, const GLMatrix &,
 
379
                  const CompRegion &, unsigned int);
 
380
    void glAddGeometry (const GLTexture::MatrixList &,
 
381
                        const CompRegion &, const CompRegion &);
 
382
    void glDrawTexture (GLTexture *texture, GLFragment::Attrib &,
 
383
                        unsigned int);
 
384
    void glDrawGeometry ();
 
385
};
 
386
 
 
387
class RollUpAnim :
 
388
    public GridAnim
 
389
{
 
390
public:
 
391
    RollUpAnim (CompWindow *w,
 
392
                WindowEvent curWindowEvent,
 
393
                float duration,
 
394
                const AnimEffect info,
 
395
                const CompRect &icon);
 
396
protected:
 
397
    static const float kDurationFactor;
 
398
 
 
399
    void initGrid ();
 
400
    void step ();
 
401
};
 
402
 
 
403
class MagicLampAnim :
 
404
    public GridAnim
 
405
{
 
406
public:
 
407
    MagicLampAnim (CompWindow *w,
 
408
                   WindowEvent curWindowEvent,
 
409
                   float duration,
 
410
                   const AnimEffect info,
 
411
                   const CompRect &icon);
 
412
    ~MagicLampAnim ();
 
413
 
 
414
protected:
 
415
    bool mTargetTop;
 
416
 
 
417
    void initGrid ();
 
418
    void step ();
 
419
    void adjustPointerIconSize ();
 
420
 
 
421
    virtual bool hasMovingEnd ();
 
422
    virtual void filterTargetX (float &targetX, float x) { }
 
423
};
 
424
 
 
425
class MagicLampWavyAnim :
 
426
    public MagicLampAnim
 
427
{
 
428
public:
 
429
    MagicLampWavyAnim (CompWindow *w,
 
430
                       WindowEvent curWindowEvent,
 
431
                       float duration,
 
432
                       const AnimEffect info,
 
433
                       const CompRect &icon);
 
434
    ~MagicLampWavyAnim ();
 
435
 
 
436
protected:
 
437
    struct WaveParam
 
438
    {
 
439
        float halfWidth;
 
440
        float amp;
 
441
        float pos;
 
442
    };
 
443
 
 
444
    unsigned int mNumWaves;
 
445
    WaveParam *mWaves;
 
446
 
 
447
    void initGrid ();
 
448
    void adjustPointerIconSize ();
 
449
 
 
450
    bool hasMovingEnd ();
 
451
    void filterTargetX (float &targetX, float x);
 
452
};
 
453
 
 
454
class SidekickAnim :
 
455
    public ZoomAnim
 
456
{
 
457
public:
 
458
    SidekickAnim (CompWindow *w,
 
459
                  WindowEvent curWindowEvent,
 
460
                  float duration,
 
461
                  const AnimEffect info,
 
462
                  const CompRect &icon);
 
463
protected:
 
464
    float mNumRotations;
 
465
 
 
466
    float getSpringiness ();
 
467
    bool isZoomFromCenter ();
 
468
    bool hasExtraTransform () { return true; }
 
469
    void applyExtraTransform (float progress);
 
470
    bool shouldAvoidParallelogramLook () { return true; }
 
471
};
 
472
 
 
473
class WaveAnim :
 
474
    public GridTransformAnim
 
475
{
 
476
public:
 
477
    WaveAnim (CompWindow *w,
 
478
              WindowEvent curWindowEvent,
 
479
              float duration,
 
480
              const AnimEffect info,
 
481
              const CompRect &icon);
 
482
protected:
 
483
    void adjustDuration ();
 
484
    void initGrid ();
 
485
    bool using3D () { return true; }
 
486
    void step ();
 
487
 
 
488
    static const float kMinDuration;
 
489
};
 
490
 
 
491
class GlideAnim :
 
492
    public ZoomAnim
 
493
{
 
494
public:
 
495
    GlideAnim (CompWindow *w,
 
496
               WindowEvent curWindowEvent,
 
497
               float duration,
 
498
               const AnimEffect info,
 
499
               const CompRect &icon);
 
500
 
 
501
protected:
 
502
    void prePaintWindow ();
 
503
    bool postPaintWindowUsed () { return true; }
 
504
    void postPaintWindow ();
 
505
    void adjustDuration ();
 
506
    bool zoomToIcon ();
 
507
    void applyTransform ();
 
508
    float getFadeProgress ();
 
509
 
 
510
    float getProgress ();
 
511
    virtual void getParams (float *finalDistFac,
 
512
                            float *finalRotAng,
 
513
                            float *thickness);
 
514
 
 
515
    float glideModRotAngle;     ///< The angle of rotation, modulo 360.
 
516
};
 
517
 
 
518
class Glide2Anim :
 
519
    public GlideAnim
 
520
{
 
521
public:
 
522
    Glide2Anim (CompWindow *w,
 
523
                WindowEvent curWindowEvent,
 
524
                float duration,
 
525
                const AnimEffect info,
 
526
                const CompRect &icon);
 
527
protected:
 
528
    bool zoomToIcon ();
 
529
    void getParams (float *finalDistFac,
 
530
                    float *finalRotAng,
 
531
                    float *thickness);
 
532
};
 
533
 
 
534
class RestackPersistentData;
 
535
 
 
536
class RestackAnim :
 
537
    virtual public Animation
 
538
{
 
539
public:
 
540
    RestackAnim (CompWindow *w,
 
541
                 WindowEvent curWindowEvent,
 
542
                 float duration,
 
543
                 const AnimEffect info,
 
544
                 const CompRect &icon);
 
545
    void cleanUp (bool closing,
 
546
                  bool destructing);
 
547
    bool initiateRestackAnim (int duration);
 
548
    bool moveUpdate () { return false; }
 
549
    static bool onSameRestackChain (CompWindow *wSubject, CompWindow *wOther);
 
550
 
 
551
    /// Find union of restack chain (group)
 
552
    static CompRegion unionRestackChain (CompWindow *w);
 
553
 
 
554
    virtual bool paintedElsewhere () { return false; }
 
555
 
 
556
protected:
 
557
    // Overridable methods
 
558
    virtual void processCandidate (CompWindow *candidateWin,
 
559
                                   CompWindow *subjectWin,
 
560
                                   CompRegion &candidateAndSubjectIntersection,
 
561
                                   int &numSelectedCandidates) {}
 
562
    virtual void postInitiateRestackAnim (int numSelectedCandidates,
 
563
                                          int duration,
 
564
                                          CompWindow *wStart,
 
565
                                          CompWindow *wEnd,
 
566
                                          bool raised) {}
 
567
 
 
568
    // Other methods
 
569
    bool overNewCopy (); ///< Is glPaint on the copy at the new position?
 
570
 
 
571
    RestackPersistentData *mRestackData;
 
572
};
 
573
 
 
574
class RestackPersistentData :
 
575
    public PersistentData
 
576
{
 
577
    friend class ExtensionPluginAnimation;
 
578
    friend class RestackAnim;
 
579
    friend class FocusFadeAnim;
 
580
    friend class DodgeAnim;
 
581
 
 
582
public:
 
583
    RestackPersistentData ();
 
584
    ~RestackPersistentData ();
 
585
 
 
586
protected:
 
587
    RestackInfo *restackInfo () { return mRestackInfo; }
 
588
    void resetRestackInfo () { delete mRestackInfo; mRestackInfo = 0; }
 
589
    void setRestackInfo (CompWindow *wRestacked,
 
590
                         CompWindow *wStart,
 
591
                         CompWindow *wEnd,
 
592
                         CompWindow *wOldAbove,
 
593
                         bool raised);
 
594
    void getHostedOnWin (CompWindow *wGuest, CompWindow *wHost);
 
595
 
 
596
    RestackInfo *mRestackInfo;   ///< restack info if window was restacked this paint round
 
597
    CompWindow *mWinToBePaintedBeforeThis; ///< Window which should be painted before this
 
598
    CompWindow *mWinThisIsPaintedBefore; ///< the inverse relation of mWinToBePaintedBeforeThis
 
599
    CompWindow *mMoreToBePaintedPrev;
 
600
    CompWindow *mMoreToBePaintedNext; ///< doubly linked list for windows underneath that
 
601
                                     ///< raise together with this one
 
602
    bool mConfigureNotified;     ///< was mConfigureNotified before restack check
 
603
    CompWindow *mWinPassingThrough; ///< win. passing through this one during focus effect
 
604
    bool mWalkerOverNewCopy;  ///< whether walker is on the copy at the new pos.
 
605
    unsigned int mVisitCount; ///< how many times walker/glPaint has visited this window
 
606
    bool mIsSecondary; ///< whether this is one of the secondary (non-topmost) in its restack chain
 
607
};
 
608
 
 
609
class FocusFadeAnim :
 
610
    public RestackAnim,
 
611
    public FadeAnim
 
612
{
 
613
public:
 
614
    FocusFadeAnim (CompWindow *w,
 
615
                   WindowEvent curWindowEvent,
 
616
                   float duration,
 
617
                   const AnimEffect info,
 
618
                   const CompRect &icon);
 
619
    void updateAttrib (GLWindowPaintAttrib &attrib);
 
620
    void cleanUp (bool closing,
 
621
                  bool destructing);
 
622
 
 
623
protected:
 
624
    void processCandidate (CompWindow *candidateWin,
 
625
                           CompWindow *subjectWin,
 
626
                           CompRegion &candidateAndSubjectIntersection,
 
627
                           int &numSelectedCandidates);
 
628
    GLushort computeOpacity (GLushort opacityInt);
 
629
};
 
630
 
 
631
typedef enum
 
632
{
 
633
    DodgeDirectionUp = 0,
 
634
    DodgeDirectionRight,
 
635
    DodgeDirectionDown,
 
636
    DodgeDirectionLeft,
 
637
    DodgeDirectionXY, // movement possibly in both X and Y (for subjects)
 
638
    DodgeDirectionNone
 
639
} DodgeDirection;
 
640
 
 
641
class DodgePersistentData;
 
642
 
 
643
class DodgeAnim :
 
644
    public RestackAnim,
 
645
    public TransformAnim
 
646
{
 
647
public:
 
648
    DodgeAnim (CompWindow *w,
 
649
               WindowEvent curWindowEvent,
 
650
               float duration,
 
651
               const AnimEffect info,
 
652
               const CompRect &icon);
 
653
    void cleanUp (bool closing,
 
654
                  bool destructing);
 
655
    static int getDodgeAmount (CompRect &rect,
 
656
                               CompWindow *dw,
 
657
                               DodgeDirection dir);
 
658
    void step ();
 
659
    void updateTransform (GLMatrix &wTransform);
 
660
    bool shouldDamageWindowOnStart ();
 
661
    void updateBB (CompOutput &output);
 
662
    void postPreparePaint ();
 
663
    void calculateDodgeAmounts ();
 
664
    bool moveUpdate ();
 
665
 
 
666
protected:
 
667
    void processCandidate (CompWindow *candidateWin,
 
668
                           CompWindow *subjectWin,
 
669
                           CompRegion &candidateAndSubjectIntersection,
 
670
                           int &numSelectedCandidates);
 
671
    void postInitiateRestackAnim (int numSelectedCandidates,
 
672
                                  int duration,
 
673
                                  CompWindow *wStart,
 
674
                                  CompWindow *wEnd,
 
675
                                  bool raised);
 
676
    bool paintedElsewhere ();
 
677
    void applyDodgeTransform ();
 
678
    float dodgeProgress ();
 
679
    void updateDodgerDodgeAmount ();
 
680
 
 
681
    DodgePersistentData *mDodgeData;
 
682
 
 
683
    CompWindow *mDodgeSubjectWin;///< The window being dodged
 
684
    float mDodgeMaxAmountX;     ///< max # pixels it should dodge
 
685
                                ///<  (neg. value dodges leftward)
 
686
    float mDodgeMaxAmountY;     ///< max # pixels it should dodge
 
687
                                ///<  (neg. value dodges upward)
 
688
    DodgeDirection mDodgeDirection;
 
689
    int mDodgeMode;
 
690
};
 
691
 
 
692
class DodgePersistentData :
 
693
    public PersistentData
 
694
{
 
695
    friend class ExtensionPluginAnimation;
 
696
    friend class DodgeAnim;
 
697
 
 
698
public:
 
699
    DodgePersistentData ();
 
700
 
 
701
private:
 
702
    int dodgeOrder;             ///< dodge order (used temporarily)
 
703
 
 
704
    // TODO mov the below members into DodgeAnim
 
705
    bool isDodgeSubject;        ///< true if this window is the cause of dodging
 
706
    bool skipPostPrepareScreen;
 
707
    CompWindow *dodgeChainStart;///< for the subject window
 
708
    CompWindow *dodgeChainPrev; ///< for dodging windows
 
709
    CompWindow *dodgeChainNext; ///< for dodging windows
 
710
};
 
711
 
 
712
class DreamAnim :
 
713
    public GridZoomAnim
 
714
{
 
715
public:
 
716
    DreamAnim (CompWindow *w,
 
717
               WindowEvent curWindowEvent,
 
718
               float duration,
 
719
               const AnimEffect info,
 
720
               const CompRect &icon);
 
721
protected:
 
722
    void init ();
 
723
    void initGrid ();
 
724
    void step ();
 
725
    void adjustDuration ();
 
726
    float getFadeProgress ();
 
727
    bool zoomToIcon ();
 
728
 
 
729
    static const float kDurationFactor;
 
730
};
 
731
 
 
732
class FoldAnim :
 
733
    public GridZoomAnim
 
734
{
 
735
public:
 
736
    FoldAnim (CompWindow *w,
 
737
              WindowEvent curWindowEvent,
 
738
              float duration,
 
739
              const AnimEffect info,
 
740
              const CompRect &icon);
 
741
protected:
 
742
    bool using3D () { return true; }
 
743
    float getFadeProgress ();
 
744
    void updateWindowAttrib (GLWindowPaintAttrib &attrib);
 
745
};
 
746
 
 
747
class CurvedFoldAnim :
 
748
    public FoldAnim
 
749
{
 
750
public:
 
751
    CurvedFoldAnim (CompWindow *w,
 
752
                    WindowEvent curWindowEvent,
 
753
                    float duration,
 
754
                    const AnimEffect info,
 
755
                    const CompRect &icon);
 
756
protected:
 
757
    void initGrid ();
 
758
    void step ();
 
759
    bool zoomToIcon ();
 
760
    float getObjectZ (GridAnim::GridModel *mModel,
 
761
                      float forwardProgress,
 
762
                      float sinForProg,
 
763
                      float relDistToCenter,
 
764
                      float curveMaxAmp);
 
765
};
 
766
 
 
767
class HorizontalFoldsAnim :
 
768
    public FoldAnim
 
769
{
 
770
public:
 
771
    HorizontalFoldsAnim (CompWindow *w,
 
772
                         WindowEvent curWindowEvent,
 
773
                         float duration,
 
774
                         const AnimEffect info,
 
775
                         const CompRect &icon);
 
776
protected:
 
777
    void initGrid ();
 
778
    void step ();
 
779
    bool zoomToIcon ();
 
780
    float getObjectZ (GridAnim::GridModel *mModel,
 
781
                      float forwardProgress,
 
782
                      float sinForProg,
 
783
                      float relDistToFoldCenter,
 
784
                      float foldMaxAmp);
 
785
};
619
786