1 /*****************************************************************
2 KWin - the KDE window manager
3 This file is part of the KDE project.
5 Copyright (C) 2007 Lubos Lunak <l.lunak@kde.org>
7 You can Freely distribute this program under the GNU General Public
8 License. See the file "COPYING" for the exact licensing terms.
9 ******************************************************************/
18 KWIN_EFFECT( drunken
, DrunkenEffect
)
20 void DrunkenEffect::prePaintScreen( ScreenPrePaintData
& data
, int time
)
22 if( !windows
.isEmpty())
23 data
.mask
|= PAINT_SCREEN_WITH_TRANSFORMED_WINDOWS
;
24 effects
->prePaintScreen( data
, time
);
27 void DrunkenEffect::prePaintWindow( EffectWindow
* w
, WindowPrePaintData
& data
, int time
)
29 if( windows
.contains( w
))
31 windows
[ w
] += time
/ 1000.;
32 if( windows
[ w
] < 1 )
33 data
.setTransformed();
37 effects
->prePaintWindow( w
, data
, time
);
40 void DrunkenEffect::paintWindow( EffectWindow
* w
, int mask
, QRegion region
, WindowPaintData
& data
)
42 if( !windows
.contains( w
))
44 effects
->paintWindow( w
, mask
, region
, data
);
47 WindowPaintData d1
= data
;
48 // 4 cycles, decreasing amplitude
49 int diff
= int( sin( windows
[ w
] * 8 * M_PI
) * ( 1 - windows
[ w
] ) * 10 );
50 d1
.xTranslate
-= diff
;
52 effects
->paintWindow( w
, mask
, region
, d1
);
53 WindowPaintData d2
= data
;
54 d2
.xTranslate
+= diff
;
56 effects
->paintWindow( w
, mask
, region
, d2
);
59 void DrunkenEffect::postPaintWindow( EffectWindow
* w
)
61 if( windows
.contains( w
))
63 effects
->postPaintWindow( w
);
66 void DrunkenEffect::windowAdded( EffectWindow
* w
)
72 void DrunkenEffect::windowClosed( EffectWindow
* w
)