18
by Didier Roche
* Cherry-pick rev 27: |
1 |
#include <string.h> |
2 |
#include <stdlib.h> |
|
3 |
#include <math.h> |
|
4 |
||
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 |
CompWindow *wRestacked, *wStart, *wEnd, *wOldAbove; |
|
31 |
bool raised; |
|
32 |
};
|
|
33 |
||
34 |
class IdValuePair |
|
35 |
{
|
|
36 |
public: |
|
37 |
IdValuePair () : pluginInfo (0), optionId (-1), value () {} |
|
38 |
||
39 |
bool matchesPluginOption (ExtensionPluginInfo *pluginInfo, |
|
40 |
int optionId) const; |
|
41 |
||
42 |
const ExtensionPluginInfo *pluginInfo; |
|
43 |
int optionId; |
|
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 |
};
|
|
74 |
||
75 |
extern AnimEffect AnimEffectNone; |
|
76 |
extern AnimEffect AnimEffectRandom; |
|
77 |
extern AnimEffect AnimEffectCurvedFold; |
|
78 |
extern AnimEffect AnimEffectDodge; |
|
79 |
extern AnimEffect AnimEffectDream; |
|
80 |
extern AnimEffect AnimEffectFade; |
|
81 |
extern AnimEffect AnimEffectFocusFade; |
|
82 |
extern AnimEffect AnimEffectGlide1; |
|
83 |
extern AnimEffect AnimEffectGlide2; |
|
84 |
extern AnimEffect AnimEffectHorizontalFolds; |
|
85 |
extern AnimEffect AnimEffectMagicLamp; |
|
86 |
extern AnimEffect AnimEffectMagicLampWavy; |
|
87 |
extern AnimEffect AnimEffectRollUp; |
|
88 |
extern AnimEffect AnimEffectSidekick; |
|
89 |
extern AnimEffect AnimEffectWave; |
|
90 |
extern AnimEffect AnimEffectZoom; |
|
91 |
||
92 |
#define NUM_EFFECTS 16
|
|
93 |
||
94 |
extern int customOptionOptionIds[AnimEventNum]; |
|
95 |
||
96 |
typedef struct _PluginEventInfo |
|
97 |
{
|
|
98 |
const char *pluginName; |
|
99 |
const char *activateEventName; |
|
100 |
} PluginEventInfo; |
|
101 |
||
102 |
typedef enum |
|
103 |
{
|
|
104 |
WatchedPluginSwitcher = 0, |
|
105 |
WatchedPluginRing, |
|
106 |
WatchedPluginShift, |
|
107 |
WatchedPluginScale, |
|
108 |
WatchedPluginGroup, |
|
109 |
WatchedPluginFadedesktop, |
|
110 |
WatchedScreenPluginNum
|
|
111 |
} WatchedScreenPlugin; |
|
112 |
||
113 |
typedef enum |
|
114 |
{
|
|
115 |
WatchedPluginKDECompat, |
|
116 |
WatchedWindowPluginNum
|
|
117 |
} WatchedWindowPlugin; |
|
118 |
||
119 |
// This must have the value of the first "effect setting" above
|
|
120 |
// in PrivateAnimScreenOptions
|
|
121 |
#define NUM_NONEFFECT_OPTIONS AnimationOptions::CurvedFoldAmpMult
|
|
122 |
||
123 |
||
124 |
class ExtensionPluginAnimation : public ExtensionPluginInfo |
|
125 |
{
|
|
126 |
public: |
|
127 |
ExtensionPluginAnimation (const CompString &name, |
|
128 |
unsigned int nEffects, |
|
129 |
AnimEffect *effects, |
|
130 |
CompOption::Vector *effectOptions, |
|
131 |
unsigned int firstEffectOptionIndex); |
|
132 |
~ExtensionPluginAnimation (); |
|
133 |
||
134 |
// Overriden methods from ExtensionPluginInfo
|
|
135 |
void postPreparePaintGeneral (); |
|
136 |
void prePreparePaintGeneral (); |
|
137 |
void handleRestackNotify (AnimWindow *aw); |
|
138 |
// Always reset stacking related info when a window is opened, closed,
|
|
139 |
// minimized, or unminimized.
|
|
140 |
void preInitiateOpenAnim (AnimWindow *aw); |
|
141 |
void preInitiateCloseAnim (AnimWindow *aw); |
|
142 |
void preInitiateMinimizeAnim (AnimWindow *aw); |
|
143 |
void preInitiateUnminimizeAnim (AnimWindow *aw); |
|
144 |
void initPersistentData (AnimWindow *aw); |
|
145 |
void destroyPersistentData (AnimWindow *aw); |
|
146 |
void postUpdateEventEffects (AnimEvent e, |
|
147 |
bool forRandom); |
|
148 |
void cleanUpAnimation (bool closing, |
|
149 |
bool destructing); |
|
150 |
void postStartupCountdown (); |
|
151 |
||
152 |
// Other methods
|
|
153 |
void handleSingleRestack (AnimWindow *aw); |
|
154 |
void prePaintWindowsBackToFront (); |
|
155 |
bool paintShouldSkipWindow (CompWindow *w); |
|
156 |
const CompWindowList & getWindowPaintList (); |
|
157 |
void resetStackingInfo (); |
|
158 |
static CompWindow *getBottommostInExtendedFocusChain (CompWindow *wStartPoint); |
|
159 |
static CompWindow *getBottommostInRestackChain (CompWindow *wStartPoint); |
|
160 |
void resetMarks (); |
|
161 |
bool markNewCopy (CompWindow *w); |
|
162 |
CompWindow * walkFirst (); |
|
163 |
CompWindow * walkNext (CompWindow *w); |
|
164 |
void incrementCurRestackAnimCount (); |
|
165 |
void decrementCurRestackAnimCount (); |
|
166 |
bool wontCreateCircularChain (CompWindow *wCur, CompWindow *wNext); |
|
167 |
||
168 |
static void cleanUpParentChildChainItem (AnimWindow *aw); |
|
169 |
static bool relevantForRestackAnim (CompWindow *w); |
|
170 |
||
171 |
/// Is restackInfo still good?
|
|
172 |
static bool restackInfoStillGood (RestackInfo *restackInfo); |
|
173 |
||
174 |
void updateLastClientList (); |
|
175 |
||
176 |
/// A window was restacked this paint round.
|
|
177 |
bool mAWinWasRestackedJustNow; |
|
178 |
||
179 |
private: |
|
180 |
CompWindowVector mLastClientList; ///< Last known stacking order |
|
181 |
CompWindowVector mPrevClientList; ///< The stacking order before mLastClientList |
|
182 |
int mRestackAnimCount; ///< Count of how many windows are currently involved in |
|
183 |
///< animations that require walker (dodge & focus fade).
|
|
184 |
std::vector<AnimWindow *> mRestackedWindows; |
|
185 |
||
186 |
CompWindowList mWindowList; |
|
187 |
};
|
|
188 |
||
189 |
class PrivateAnimScreen : |
|
190 |
public ScreenInterface, |
|
191 |
public CompositeScreenInterface, |
|
192 |
public GLScreenInterface, |
|
193 |
public AnimationOptions |
|
194 |
{
|
|
195 |
friend class PrivateAnimWindow; |
|
196 |
friend class AnimWindow; |
|
197 |
||
198 |
public: |
|
199 |
CompositeScreen *cScreen; |
|
200 |
GLScreen *gScreen; |
|
201 |
AnimScreen *aScreen; |
|
202 |
||
203 |
private: |
|
204 |
struct timeval mLastRedrawTime; |
|
205 |
bool mLastRedrawTimeFresh; |
|
206 |
||
207 |
bool mPluginActive[WatchedScreenPluginNum]; |
|
208 |
int mSwitcherPostWait; |
|
209 |
int mStartCountdown; |
|
210 |
///< To mark windows as "created" if they were opened before compiz
|
|
211 |
///< was started and to prevent already opened windows from doing
|
|
212 |
///< open animation.
|
|
213 |
||
214 |
Window mLastActiveWindow; ///< Last known active window |
|
215 |
||
216 |
bool mAnimInProgress; ///< Is an animation currently being played? |
|
217 |
bool mStartingNewPaintRound; ///< Is a new round of glPaints starting? |
|
218 |
bool mPrePaintWindowsBackToFrontEnabled; |
|
219 |
||
220 |
EffectSet mRandomEffects[AnimEventNum]; |
|
221 |
||
222 |
OptionSets mEventOptionSets[AnimEventNum]; |
|
223 |
||
224 |
// Effect extension plugins
|
|
225 |
ExtensionPluginVector mExtensionPlugins; |
|
226 |
||
227 |
// Possible effects for each event
|
|
228 |
AnimEffectVector mEventEffectsAllowed[AnimEventNum]; |
|
229 |
||
230 |
// List of chosen effects for each event
|
|
231 |
EffectSet mEventEffects[AnimEventNum]; |
|
232 |
||
233 |
CompOutput *mOutput; |
|
234 |
||
235 |
Window mActiveWindow; |
|
236 |
CompMatch mNeverAnimateMatch; |
|
237 |
||
238 |
void updateEventEffects (AnimEvent e, |
|
239 |
bool forRandom, |
|
240 |
bool callPost = true); |
|
241 |
void updateAllEventEffects (); |
|
242 |
||
243 |
void updateOptionSets (AnimEvent e); |
|
244 |
void updateOptionSet (OptionSet *os, const char *optNamesValuesOrig); |
|
245 |
||
246 |
void activateEvent (bool activating); |
|
247 |
bool isWinVisible (CompWindow *w); |
|
248 |
AnimEvent getCorrespondingAnimEvent (AnimationOptions::Options optionId); |
|
249 |
void eventMatchesChanged (CompOption *opt, AnimationOptions::Options num); |
|
250 |
void eventOptionsChanged (CompOption *opt, AnimationOptions::Options num); |
|
251 |
void eventEffectsChanged (CompOption *opt, AnimationOptions::Options num); |
|
252 |
void eventRandomEffectsChanged (CompOption *opt, AnimationOptions::Options num); |
|
253 |
||
254 |
CompRect getIcon (CompWindow *w, bool alwaysUseMouse); |
|
255 |
void updateAnimStillInProgress (); |
|
256 |
||
257 |
bool isAnimEffectInList (AnimEffect theEffect, |
|
258 |
EffectSet &effectList); |
|
259 |
bool isAnimEffectPossibleForEvent (AnimEffect theEffect, |
|
260 |
AnimEvent event); |
|
261 |
||
262 |
public: |
|
263 |
PrivateAnimScreen (CompScreen *s, AnimScreen *); |
|
264 |
~PrivateAnimScreen (); |
|
265 |
||
266 |
// Utility methods
|
|
267 |
void initiateOpenAnim (PrivateAnimWindow *aw); |
|
268 |
void initiateCloseAnim (PrivateAnimWindow *aw); |
|
269 |
void initiateMinimizeAnim (PrivateAnimWindow *aw); |
|
270 |
void initiateUnminimizeAnim (PrivateAnimWindow *aw); |
|
271 |
void initiateShadeAnim (PrivateAnimWindow *aw); |
|
272 |
void initiateUnshadeAnim (PrivateAnimWindow *aw); |
|
273 |
bool initiateFocusAnim (PrivateAnimWindow *aw); |
|
274 |
||
275 |
/// Is a restacking animation currently possible?
|
|
276 |
bool isRestackAnimPossible (); |
|
277 |
||
278 |
void initAnimationList (); |
|
279 |
bool isAnimEffectPossible (AnimEffect theEffect); |
|
280 |
inline CompOutput &output () { return *mOutput; } |
|
281 |
AnimEffect getActualEffect (AnimEffect effect, |
|
282 |
AnimEvent animEvent); |
|
283 |
bool shouldIgnoreWindowForAnim (CompWindow *w, bool checkPixmap); |
|
284 |
OptionSet *getOptionSetForSelectedRow (PrivateAnimWindow *aw, |
|
285 |
Animation *anim); |
|
286 |
void addExtension (ExtensionPluginInfo *extensionPluginInfo, |
|
287 |
bool shouldInitPersistentData); |
|
288 |
void removeExtension (ExtensionPluginInfo *extensionPluginInfo); |
|
289 |
AnimEffect getMatchingAnimSelection (CompWindow *w, |
|
290 |
AnimEvent e, |
|
291 |
int *duration); |
|
292 |
bool otherPluginsActive (); |
|
293 |
||
294 |
void enablePrePaintWindowsBackToFront (bool enabled); |
|
295 |
void prePaintWindowsBackToFront (); |
|
296 |
||
297 |
// CompositeScreenInterface methods
|
|
298 |
void preparePaint (int); |
|
299 |
void donePaint (); |
|
300 |
const CompWindowList & getWindowPaintList (); |
|
301 |
||
302 |
// GLScreenInterface methods
|
|
303 |
bool glPaintOutput (const GLScreenPaintAttrib &, |
|
304 |
const GLMatrix &, |
|
305 |
const CompRegion &, |
|
306 |
CompOutput *, |
|
307 |
unsigned int); |
|
308 |
||
309 |
// ScreenInterface methods
|
|
310 |
void handleCompizEvent (const char * plugin, const char *event, |
|
311 |
CompOption::Vector &options); |
|
312 |
};
|
|
313 |
||
314 |
class PrivateAnimWindow : |
|
315 |
public WindowInterface, |
|
316 |
public GLWindowInterface |
|
317 |
{
|
|
318 |
friend class PrivateAnimScreen; |
|
319 |
friend class AnimWindow; |
|
320 |
||
321 |
public: |
|
322 |
PrivateAnimWindow (CompWindow *, AnimWindow *aw); |
|
323 |
~PrivateAnimWindow (); |
|
324 |
||
325 |
void createFocusAnimation (AnimEffect effect, int duration); |
|
326 |
inline void setShaded (bool shaded) { mNowShaded = shaded; } |
|
327 |
inline Animation *curAnimation () { return mCurAnimation; } |
|
328 |
inline PrivateAnimScreen *paScreen () { return mPAScreen; } |
|
329 |
inline AnimWindow *aWindow () { return mAWindow; } |
|
330 |
inline Box &BB () { return mBB; } |
|
331 |
inline int curAnimSelectionRow () { return mCurAnimSelectionRow; } |
|
332 |
||
333 |
void damageThisAndLastStepRegion (); |
|
334 |
void postAnimationCleanUp (); |
|
335 |
void copyResetStepRegion (); |
|
336 |
||
337 |
GLWindow *gWindow; |
|
338 |
||
339 |
private: |
|
340 |
CompWindow *mWindow; |
|
341 |
AnimWindow *mAWindow; |
|
342 |
||
343 |
PrivateAnimScreen *mPAScreen; |
|
344 |
||
345 |
unsigned int mState; |
|
346 |
unsigned int mNewState; |
|
347 |
||
348 |
Animation *mCurAnimation; |
|
349 |
||
350 |
bool mUnshadePending; |
|
351 |
bool mEventNotOpenClose; |
|
352 |
bool mNowShaded; |
|
353 |
bool mGrabbed; |
|
354 |
||
355 |
int mUnmapCnt; |
|
356 |
int mDestroyCnt; |
|
357 |
||
358 |
bool mIgnoreDamage; |
|
359 |
bool mFinishingAnim; |
|
360 |
||
361 |
int mCurAnimSelectionRow; |
|
362 |
int mPrevAnimSelectionRow; ///< For the case when one event interrupts another |
|
363 |
||
364 |
Box mBB; ///< Bounding box of area to be damaged |
|
365 |
||
366 |
CompRegion mStepRegion; ///< Region to damage this step |
|
367 |
CompRegion mLastStepRegion; ///< Region damaged last step |
|
368 |
||
369 |
bool mPluginActive[WatchedWindowPluginNum]; |
|
370 |
||
371 |
// Utility methods
|
|
372 |
unsigned int getState (); |
|
373 |
void updateSelectionRow (unsigned int i); |
|
374 |
void postAnimationCleanUpPrev (bool closing, bool clearMatchingRow); |
|
375 |
void postAnimationCleanUpCustom (bool closing, |
|
376 |
bool destructing, |
|
377 |
bool clearMatchingRow); |
|
378 |
void reverseAnimation (); |
|
379 |
void enablePainting (bool enabling); |
|
380 |
||
381 |
void notifyAnimation (bool activation); |
|
382 |
||
383 |
// WindowInterface methods
|
|
384 |
void resizeNotify (int dx, int dy, int dwidth, int dheight); |
|
385 |
void moveNotify (int dx, int dy, bool immediate); |
|
386 |
void windowNotify (CompWindowNotify n); |
|
387 |
void grabNotify (int x, int y, unsigned int state, unsigned int mask); |
|
388 |
void ungrabNotify (); |
|
389 |
||
390 |
// GLWindowInterface methods
|
|
391 |
bool glPaint (const GLWindowPaintAttrib &, const GLMatrix &, |
|
392 |
const CompRegion &, unsigned int); |
|
393 |
void glAddGeometry (const GLTexture::MatrixList &, |
|
394 |
const CompRegion &, const CompRegion &, |
|
395 |
unsigned int = MAXSHORT, unsigned int = MAXSHORT); |
|
396 |
void glDrawTexture (GLTexture *texture, GLFragment::Attrib &, |
|
397 |
unsigned int); |
|
398 |
void glDrawGeometry (); |
|
399 |
};
|
|
400 |
||
401 |
class RollUpAnim : |
|
402 |
public GridAnim |
|
403 |
{
|
|
404 |
public: |
|
405 |
RollUpAnim (CompWindow *w, |
|
406 |
WindowEvent curWindowEvent, |
|
407 |
float duration, |
|
408 |
const AnimEffect info, |
|
409 |
const CompRect &icon); |
|
410 |
protected: |
|
411 |
static const float kDurationFactor; |
|
412 |
||
413 |
void initGrid (); |
|
414 |
void step (); |
|
415 |
};
|
|
416 |
||
417 |
class MagicLampAnim : |
|
418 |
public GridAnim |
|
419 |
{
|
|
420 |
public: |
|
421 |
MagicLampAnim (CompWindow *w, |
|
422 |
WindowEvent curWindowEvent, |
|
423 |
float duration, |
|
424 |
const AnimEffect info, |
|
425 |
const CompRect &icon); |
|
426 |
virtual ~MagicLampAnim (); |
|
427 |
||
428 |
protected: |
|
429 |
bool mTargetTop; |
|
430 |
GridModel::GridObject *mTopLeftCornerObject; |
|
431 |
GridModel::GridObject *mBottomLeftCornerObject; |
|
432 |
||
433 |
void initGrid (); |
|
434 |
void step (); |
|
435 |
void updateBB (CompOutput &output); |
|
436 |
inline bool stepRegionUsed () { return true; } |
|
437 |
void adjustPointerIconSize (); |
|
438 |
||
439 |
virtual bool hasMovingEnd (); |
|
440 |
virtual void filterTargetX (float &targetX, float x) { } |
|
441 |
};
|
|
442 |
||
443 |
class MagicLampWavyAnim : |
|
444 |
public MagicLampAnim |
|
445 |
{
|
|
446 |
public: |
|
447 |
MagicLampWavyAnim (CompWindow *w, |
|
448 |
WindowEvent curWindowEvent, |
|
449 |
float duration, |
|
450 |
const AnimEffect info, |
|
451 |
const CompRect &icon); |
|
452 |
~MagicLampWavyAnim (); |
|
453 |
||
454 |
protected: |
|
455 |
struct WaveParam |
|
456 |
{
|
|
457 |
float halfWidth; |
|
458 |
float amp; |
|
459 |
float pos; |
|
460 |
};
|
|
461 |
||
462 |
unsigned int mNumWaves; |
|
463 |
WaveParam *mWaves; |
|
464 |
||
465 |
void initGrid (); |
|
466 |
void updateBB (CompOutput &output); |
|
467 |
inline bool stepRegionUsed () { return false; } |
|
468 |
void adjustPointerIconSize (); |
|
469 |
||
470 |
bool hasMovingEnd (); |
|
471 |
void filterTargetX (float &targetX, float x); |
|
472 |
};
|
|
473 |
||
474 |
class SidekickAnim : |
|
475 |
public ZoomAnim |
|
476 |
{
|
|
477 |
public: |
|
478 |
SidekickAnim (CompWindow *w, |
|
479 |
WindowEvent curWindowEvent, |
|
480 |
float duration, |
|
481 |
const AnimEffect info, |
|
482 |
const CompRect &icon); |
|
483 |
protected: |
|
484 |
float mNumRotations; |
|
485 |
||
486 |
float getSpringiness (); |
|
487 |
bool isZoomFromCenter (); |
|
488 |
inline bool hasExtraTransform () { return true; } |
|
489 |
void applyExtraTransform (float progress); |
|
490 |
inline bool shouldAvoidParallelogramLook () { return true; } |
|
491 |
};
|
|
492 |
||
493 |
class WaveAnim : |
|
494 |
public GridTransformAnim |
|
495 |
{
|
|
496 |
public: |
|
497 |
WaveAnim (CompWindow *w, |
|
498 |
WindowEvent curWindowEvent, |
|
499 |
float duration, |
|
500 |
const AnimEffect info, |
|
501 |
const CompRect &icon); |
|
502 |
protected: |
|
503 |
void adjustDuration (); |
|
504 |
void initGrid (); |
|
505 |
inline bool using3D () { return true; } |
|
506 |
void step (); |
|
507 |
||
508 |
static const float kMinDuration; |
|
509 |
};
|
|
510 |
||
511 |
class GlideAnim : |
|
512 |
public ZoomAnim |
|
513 |
{
|
|
514 |
public: |
|
515 |
GlideAnim (CompWindow *w, |
|
516 |
WindowEvent curWindowEvent, |
|
517 |
float duration, |
|
518 |
const AnimEffect info, |
|
519 |
const CompRect &icon); |
|
520 |
||
521 |
protected: |
|
522 |
void prePaintWindow (); |
|
523 |
inline bool postPaintWindowUsed () { return true; } |
|
524 |
void postPaintWindow (); |
|
525 |
void adjustDuration (); |
|
526 |
bool zoomToIcon (); |
|
527 |
void applyTransform (); |
|
528 |
float getFadeProgress (); |
|
529 |
||
530 |
float getProgress (); |
|
531 |
virtual void getParams (float *finalDistFac, |
|
532 |
float *finalRotAng, |
|
533 |
float *thickness); |
|
534 |
||
535 |
float glideModRotAngle; ///< The angle of rotation, modulo 360. |
|
536 |
};
|
|
537 |
||
538 |
class Glide2Anim : |
|
539 |
public GlideAnim |
|
540 |
{
|
|
541 |
public: |
|
542 |
Glide2Anim (CompWindow *w, |
|
543 |
WindowEvent curWindowEvent, |
|
544 |
float duration, |
|
545 |
const AnimEffect info, |
|
546 |
const CompRect &icon); |
|
547 |
protected: |
|
548 |
bool zoomToIcon (); |
|
549 |
void getParams (float *finalDistFac, |
|
550 |
float *finalRotAng, |
|
551 |
float *thickness); |
|
552 |
};
|
|
553 |
||
554 |
class RestackPersistentData; |
|
555 |
||
556 |
class RestackAnim : |
|
557 |
virtual public Animation |
|
558 |
{
|
|
559 |
public: |
|
560 |
RestackAnim (CompWindow *w, |
|
561 |
WindowEvent curWindowEvent, |
|
562 |
float duration, |
|
563 |
const AnimEffect info, |
|
564 |
const CompRect &icon); |
|
565 |
void cleanUp (bool closing, |
|
566 |
bool destructing); |
|
567 |
bool initiateRestackAnim (int duration); |
|
568 |
inline bool moveUpdate () { return false; } |
|
569 |
static bool onSameRestackChain (CompWindow *wSubject, CompWindow *wOther); |
|
570 |
||
571 |
/// Find union of restack chain (group)
|
|
572 |
static CompRegion unionRestackChain (CompWindow *w); |
|
573 |
||
574 |
virtual bool paintedElsewhere () { return false; } |
|
575 |
||
576 |
protected: |
|
577 |
// Overridable methods
|
|
578 |
virtual void processCandidate (CompWindow *candidateWin, |
|
579 |
CompWindow *subjectWin, |
|
580 |
CompRegion &candidateAndSubjectIntersection, |
|
581 |
int &numSelectedCandidates) {} |
|
582 |
virtual void postInitiateRestackAnim (int numSelectedCandidates, |
|
583 |
int duration, |
|
584 |
CompWindow *wStart, |
|
585 |
CompWindow *wEnd, |
|
586 |
bool raised) {} |
|
587 |
||
588 |
// Other methods
|
|
589 |
bool overNewCopy (); ///< Is glPaint on the copy at the new position? |
|
590 |
||
591 |
RestackPersistentData *mRestackData; |
|
592 |
};
|
|
593 |
||
594 |
class RestackPersistentData : |
|
595 |
public PersistentData |
|
596 |
{
|
|
597 |
friend class ExtensionPluginAnimation; |
|
598 |
friend class RestackAnim; |
|
599 |
friend class FocusFadeAnim; |
|
600 |
friend class DodgeAnim; |
|
601 |
||
602 |
public: |
|
603 |
RestackPersistentData (); |
|
604 |
~RestackPersistentData (); |
|
605 |
||
606 |
protected: |
|
607 |
inline RestackInfo *restackInfo () { return mRestackInfo; } |
|
608 |
void resetRestackInfo (bool alsoResetChain = false); |
|
609 |
void setRestackInfo (CompWindow *wRestacked, |
|
610 |
CompWindow *wStart, |
|
611 |
CompWindow *wEnd, |
|
612 |
CompWindow *wOldAbove, |
|
613 |
bool raised); |
|
614 |
void getHostedOnWin (CompWindow *wGuest, CompWindow *wHost); |
|
615 |
||
616 |
RestackInfo *mRestackInfo; ///< restack info if window was restacked this paint round |
|
617 |
CompWindow *mWinToBePaintedBeforeThis; ///< Window which should be painted before this |
|
618 |
CompWindow *mWinThisIsPaintedBefore; ///< the inverse relation of mWinToBePaintedBeforeThis |
|
619 |
CompWindow *mMoreToBePaintedPrev; |
|
620 |
CompWindow *mMoreToBePaintedNext; ///< doubly linked list for windows underneath that |
|
621 |
///< raise together with this one
|
|
622 |
bool mConfigureNotified; ///< was mConfigureNotified before restack check |
|
623 |
CompWindow *mWinPassingThrough; ///< win. passing through this one during focus effect |
|
624 |
bool mWalkerOverNewCopy; ///< whether walker is on the copy at the new pos. |
|
625 |
int mVisitCount; ///< how many times walker/glPaint has visited this window |
|
626 |
bool mIsSecondary; ///< whether this is one of the secondary (non-topmost) in its restack chain |
|
627 |
};
|
|
628 |
||
629 |
class FocusFadeAnim : |
|
630 |
public RestackAnim, |
|
631 |
public FadeAnim |
|
632 |
{
|
|
633 |
public: |
|
634 |
FocusFadeAnim (CompWindow *w, |
|
635 |
WindowEvent curWindowEvent, |
|
636 |
float duration, |
|
637 |
const AnimEffect info, |
|
638 |
const CompRect &icon); |
|
639 |
void updateAttrib (GLWindowPaintAttrib &attrib); |
|
640 |
void cleanUp (bool closing, |
|
641 |
bool destructing); |
|
642 |
||
643 |
protected: |
|
644 |
void processCandidate (CompWindow *candidateWin, |
|
645 |
CompWindow *subjectWin, |
|
646 |
CompRegion &candidateAndSubjectIntersection, |
|
647 |
int &numSelectedCandidates); |
|
648 |
GLushort computeOpacity (GLushort opacityInt); |
|
649 |
};
|
|
650 |
||
651 |
typedef enum |
|
652 |
{
|
|
653 |
DodgeDirectionUp = 0, |
|
654 |
DodgeDirectionRight, |
|
655 |
DodgeDirectionDown, |
|
656 |
DodgeDirectionLeft, |
|
657 |
DodgeDirectionXY, // movement possibly in both X and Y (for subjects) |
|
658 |
DodgeDirectionNone
|
|
659 |
} DodgeDirection; |
|
660 |
||
661 |
class DodgePersistentData; |
|
662 |
||
663 |
class DodgeAnim : |
|
664 |
public RestackAnim, |
|
665 |
public TransformAnim |
|
666 |
{
|
|
667 |
public: |
|
668 |
DodgeAnim (CompWindow *w, |
|
669 |
WindowEvent curWindowEvent, |
|
670 |
float duration, |
|
671 |
const AnimEffect info, |
|
672 |
const CompRect &icon); |
|
673 |
void cleanUp (bool closing, |
|
674 |
bool destructing); |
|
675 |
static int getDodgeAmount (CompRect &rect, |
|
676 |
CompWindow *dw, |
|
677 |
DodgeDirection dir); |
|
678 |
void step (); |
|
679 |
void updateTransform (GLMatrix &wTransform); |
|
680 |
bool shouldDamageWindowOnStart (); |
|
681 |
void updateBB (CompOutput &output); |
|
682 |
void postPreparePaint (); |
|
683 |
void calculateDodgeAmounts (); |
|
684 |
bool moveUpdate (); |
|
685 |
||
686 |
protected: |
|
687 |
void processCandidate (CompWindow *candidateWin, |
|
688 |
CompWindow *subjectWin, |
|
689 |
CompRegion &candidateAndSubjectIntersection, |
|
690 |
int &numSelectedCandidates); |
|
691 |
void postInitiateRestackAnim (int numSelectedCandidates, |
|
692 |
int duration, |
|
693 |
CompWindow *wStart, |
|
694 |
CompWindow *wEnd, |
|
695 |
bool raised); |
|
696 |
bool paintedElsewhere (); |
|
697 |
void applyDodgeTransform (); |
|
698 |
float dodgeProgress (); |
|
699 |
void updateDodgerDodgeAmount (); |
|
700 |
||
701 |
DodgePersistentData *mDodgeData; |
|
702 |
||
703 |
CompWindow *mDodgeSubjectWin;///< The window being dodged |
|
704 |
float mDodgeMaxAmountX; ///< max # pixels it should dodge |
|
705 |
///< (neg. value dodges leftward)
|
|
706 |
float mDodgeMaxAmountY; ///< max # pixels it should dodge |
|
707 |
///< (neg. value dodges upward)
|
|
708 |
DodgeDirection mDodgeDirection; |
|
709 |
int mDodgeMode; |
|
710 |
};
|
|
711 |
||
712 |
class DodgePersistentData : |
|
713 |
public PersistentData |
|
714 |
{
|
|
715 |
friend class ExtensionPluginAnimation; |
|
716 |
friend class DodgeAnim; |
|
717 |
||
718 |
public: |
|
719 |
DodgePersistentData (); |
|
720 |
||
721 |
private: |
|
722 |
int dodgeOrder; ///< dodge order (used temporarily) |
|
723 |
||
724 |
// TODO mov the below members into DodgeAnim
|
|
725 |
bool isDodgeSubject; ///< true if this window is the cause of dodging |
|
726 |
bool skipPostPrepareScreen; |
|
727 |
CompWindow *dodgeChainStart;///< for the subject window |
|
728 |
CompWindow *dodgeChainPrev; ///< for dodging windows |
|
729 |
CompWindow *dodgeChainNext; ///< for dodging windows |
|
730 |
};
|
|
731 |
||
732 |
class DreamAnim : |
|
733 |
public GridZoomAnim |
|
734 |
{
|
|
735 |
public: |
|
736 |
DreamAnim (CompWindow *w, |
|
737 |
WindowEvent curWindowEvent, |
|
738 |
float duration, |
|
739 |
const AnimEffect info, |
|
740 |
const CompRect &icon); |
|
741 |
protected: |
|
742 |
void init (); |
|
743 |
void initGrid (); |
|
744 |
void step (); |
|
745 |
void adjustDuration (); |
|
746 |
float getFadeProgress (); |
|
747 |
bool zoomToIcon (); |
|
748 |
||
749 |
static const float kDurationFactor; |
|
750 |
};
|
|
751 |
||
752 |
class FoldAnim : |
|
753 |
public GridZoomAnim |
|
754 |
{
|
|
755 |
public: |
|
756 |
FoldAnim (CompWindow *w, |
|
757 |
WindowEvent curWindowEvent, |
|
758 |
float duration, |
|
759 |
const AnimEffect info, |
|
760 |
const CompRect &icon); |
|
761 |
protected: |
|
762 |
inline bool using3D () { return true; } |
|
763 |
float getFadeProgress (); |
|
764 |
void updateWindowAttrib (GLWindowPaintAttrib &attrib); |
|
765 |
};
|
|
766 |
||
767 |
class CurvedFoldAnim : |
|
768 |
public FoldAnim |
|
769 |
{
|
|
770 |
public: |
|
771 |
CurvedFoldAnim (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 |
void updateBB (CompOutput &output); |
|
780 |
bool zoomToIcon (); |
|
781 |
float getObjectZ (GridAnim::GridModel *mModel, |
|
782 |
float forwardProgress, |
|
783 |
float sinForProg, |
|
784 |
float relDistToCenter, |
|
785 |
float curveMaxAmp); |
|
786 |
};
|
|
787 |
||
788 |
class HorizontalFoldsAnim : |
|
789 |
public FoldAnim |
|
790 |
{
|
|
791 |
public: |
|
792 |
HorizontalFoldsAnim (CompWindow *w, |
|
793 |
WindowEvent curWindowEvent, |
|
794 |
float duration, |
|
795 |
const AnimEffect info, |
|
796 |
const CompRect &icon); |
|
797 |
protected: |
|
798 |
void initGrid (); |
|
799 |
void step (); |
|
800 |
bool zoomToIcon (); |
|
801 |
float getObjectZ (GridAnim::GridModel *mModel, |
|
802 |
float forwardProgress, |
|
803 |
float sinForProg, |
|
804 |
float relDistToFoldCenter, |
|
805 |
float foldMaxAmp); |
|
806 |
};
|