Make a branch to make krunner Good Enough For Aaron™.
[kdebase/uwolfer.git] / workspace / kwin / effects / test / flame.cpp
blob797293abed749ae6cc5d3bc057ddd6046ca8eaf9
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 ******************************************************************/
11 #include "flame.h"
13 #include <assert.h>
14 #include <kdebug.h>
16 namespace KWin
19 KWIN_EFFECT( flame, FlameEffect )
21 void FlameEffect::prePaintScreen( ScreenPrePaintData& data, int time )
23 if( !windows.isEmpty())
24 data.mask |= PAINT_SCREEN_WITH_TRANSFORMED_WINDOWS;
25 effects->prePaintScreen(data, time);
28 void FlameEffect::prePaintWindow( EffectWindow* w, WindowPrePaintData& data, int time )
30 if( windows.contains( w ))
32 if( windows[ w ] < 1 )
34 windows[ w ] += time / 500.;
35 data.setTransformed();
36 w->enablePainting( EffectWindow::PAINT_DISABLED_BY_DELETE );
37 data.quads = data.quads.splitAtY( windows[ w ] * w->height());
39 else
41 windows.remove( w );
42 w->unrefWindow();
45 effects->prePaintWindow( w, data, time );
48 void FlameEffect::paintWindow( EffectWindow* w, int mask, QRegion region, WindowPaintData& data )
50 if( windows.contains( w ))
52 WindowQuadList new_quads;
53 double ylimit = windows[ w ] * w->height(); // parts above this are already away
54 foreach( WindowQuad quad, data.quads )
56 if( quad.bottom() <= ylimit )
57 continue;
58 new_quads.append( quad );
60 if( new_quads.isEmpty())
61 return; // nothing to paint
62 data.quads = new_quads;
64 effects->paintWindow( w, mask, region, data );
67 void FlameEffect::postPaintWindow( EffectWindow* w )
69 if( windows.contains( w ))
70 effects->addRepaint( w->geometry()); // workspace, since the window under it will need painting too
71 effects->postPaintScreen();
74 void FlameEffect::windowClosed( EffectWindow* c )
76 windows[ c ] = 0;
77 c->refWindow();
80 void FlameEffect::windowDeleted( EffectWindow* c )
82 windows.remove( c );
85 } // namespace