summaryrefslogtreecommitdiff
path: root/flyingwindows.h
blob: de6ac0cce0b1579651391bc76af59910286e2fae (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
#ifndef FLYINGWINDOWS_H
#define FLYINGWINDOWS_H

#include "screensaver_internal.h"

class DisplayFlyingWindows : public DisplayEffect
{
public:
	DisplayFlyingWindows( CompDisplay* d ) : DisplayEffect(d) {}
	virtual ~DisplayFlyingWindows() {}
	
	virtual void handleEvent( XEvent *event );
};

class ScreenFlyingWindows : public ScreenEffect
{
public:
	ScreenFlyingWindows( CompScreen* s ) : ScreenEffect(s) {}
	virtual ~ScreenFlyingWindows() {}
	
	virtual bool enable();
	virtual void disable();
	virtual void preparePaintScreen( int msSinceLastPaint );
	virtual void donePaintScreen();
	virtual void paintScreen (CompOutput   *outputs,
				  int          numOutputs,
				  unsigned int mask);
	virtual Bool paintOutput(	const ScreenPaintAttrib *sAttrib, \
								const CompTransform* transform, Region region, \
								CompOutput* output, unsigned int mask);
	virtual void paintTransformedOutput(	const ScreenPaintAttrib* sAttrib, \
											const CompTransform* transform, Region region, \
											CompOutput *output, unsigned int mask);
private:
	void initWindow( CompWindow* _w );
	void recalcVertices( CompWindow* _w );
	void addForce( const Point& p1, const Point& p2, const Point& center, Vector& resultante, Vector& couple, float w, Bool attract );
};

class WindowFlyingWindows : public WindowEffect
{
	friend class ScreenFlyingWindows;
	
public:
	WindowFlyingWindows( CompWindow* w );
	virtual ~WindowFlyingWindows() {}
	void initWindow();
	virtual Bool paintWindow(	const WindowPaintAttrib* attrib, \
								const CompTransform* transform, Region region, unsigned int mask);
	void recalcVertices();
	
	static WindowFlyingWindows& getInstance( CompWindow* w )
		{ SCREENSAVER_WINDOW(w); return ( WindowFlyingWindows& )( *sw->effect ); }
		
private:
	bool isActiveWin();
	
	// isScreenSaverWin()
	bool active;
	
	// used for non-active window like the desktop
	GLushort opacity;
	GLushort opacityFadeOut;
	GLushort opacityOld;
	int steps;
	
	// used for active window
	// translate matrix
	Matrix transformTrans;
	
	// rotation matrix
	Matrix centerTrans, transformRot, centerTransInv;
	
	// precomputed transform matrix
	Matrix transform;
	
	Matrix transformFadeOut;

	// 5 normalized vertices are stored, the four corners and the center
	Point vertex[5];
	
	// normalized speed vectors
	Vector speed;
	Vector speedrot;
};

#endif