1 /*****************************************************************
2 KWin - the KDE window manager
3 This file is part of the KDE project.
5 Copyright (C) 2006 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 ******************************************************************/
11 #include "demo_shakymove.h"
16 KWIN_EFFECT( demo_shakymove
, ShakyMoveEffect
)
18 ShakyMoveEffect::ShakyMoveEffect()
20 connect( &timer
, SIGNAL( timeout()), SLOT( tick()));
23 static const int shaky_diff
[] = { 0, 1, 2, 3, 2, 1, 0, -1, -2, -3, -2, -1 };
24 static const int SHAKY_MAX
= sizeof( shaky_diff
) / sizeof( shaky_diff
[ 0 ] );
26 void ShakyMoveEffect::prePaintScreen( ScreenPrePaintData
& data
, int time
)
28 if( !windows
.isEmpty())
29 data
.mask
|= PAINT_SCREEN_WITH_TRANSFORMED_WINDOWS
;
30 effects
->prePaintScreen( data
, time
);
33 void ShakyMoveEffect::prePaintWindow( EffectWindow
* w
, WindowPrePaintData
& data
, int time
)
35 if( windows
.contains( w
))
36 data
.setTransformed();
37 effects
->prePaintWindow( w
, data
, time
);
40 void ShakyMoveEffect::paintWindow( EffectWindow
* w
, int mask
, QRegion region
, WindowPaintData
& data
)
42 if( windows
.contains( w
))
43 data
.xTranslate
+= shaky_diff
[ windows
[ w
]];
44 effects
->paintWindow( w
, mask
, region
, data
);
47 void ShakyMoveEffect::windowUserMovedResized( EffectWindow
* c
, bool first
, bool last
)
51 if( windows
.isEmpty())
58 // just repaint whole screen, transformation is involved
59 effects
->addRepaintFull();
60 if( windows
.isEmpty())
65 void ShakyMoveEffect::windowClosed( EffectWindow
* c
)
68 if( windows
.isEmpty())
72 // TODO use time provided with prePaintWindow() instead
73 void ShakyMoveEffect::tick()
75 for( QHash
< const EffectWindow
*, int >::Iterator it
= windows
.begin();
79 if( *it
== SHAKY_MAX
- 1 )
83 // just repaint whole screen, transformation is involved
84 effects
->addRepaintFull();
90 #include "demo_shakymove.moc"