2007-04-29 17:35:43 +00:00
|
|
|
/*****************************************************************
|
|
|
|
KWin - the KDE window manager
|
|
|
|
This file is part of the KDE project.
|
|
|
|
|
|
|
|
Copyright (C) 2007 Lubos Lunak <l.lunak@kde.org>
|
|
|
|
|
|
|
|
You can Freely distribute this program under the GNU General Public
|
|
|
|
License. See the file "COPYING" for the exact licensing terms.
|
|
|
|
******************************************************************/
|
|
|
|
|
|
|
|
#include "flame.h"
|
|
|
|
|
|
|
|
#include <assert.h>
|
2007-07-07 14:01:32 +00:00
|
|
|
#include <kdebug.h>
|
2007-04-29 17:35:43 +00:00
|
|
|
|
|
|
|
namespace KWin
|
|
|
|
{
|
|
|
|
|
2007-05-28 11:16:18 +00:00
|
|
|
KWIN_EFFECT( flame, FlameEffect )
|
2007-04-29 17:35:43 +00:00
|
|
|
|
2007-07-07 14:01:32 +00:00
|
|
|
void FlameEffect::prePaintScreen( ScreenPrePaintData& data, int time )
|
2007-04-29 17:35:43 +00:00
|
|
|
{
|
|
|
|
if( !windows.isEmpty())
|
2007-07-07 14:01:32 +00:00
|
|
|
data.mask |= PAINT_SCREEN_WITH_TRANSFORMED_WINDOWS;
|
|
|
|
effects->prePaintScreen(data, time);
|
2007-04-29 17:35:43 +00:00
|
|
|
}
|
|
|
|
|
2007-07-07 14:01:32 +00:00
|
|
|
void FlameEffect::prePaintWindow( EffectWindow* w, WindowPrePaintData& data, int time )
|
2007-04-29 17:35:43 +00:00
|
|
|
{
|
|
|
|
if( windows.contains( w ))
|
|
|
|
{
|
|
|
|
if( windows[ w ] < 1 )
|
|
|
|
{
|
|
|
|
windows[ w ] += time / 500.;
|
2007-07-07 14:01:32 +00:00
|
|
|
data.mask |= PAINT_WINDOW_TRANSFORMED;
|
2007-04-29 17:35:43 +00:00
|
|
|
w->enablePainting( EffectWindow::PAINT_DISABLED_BY_DELETE );
|
2007-07-07 14:01:32 +00:00
|
|
|
data.quads = data.quads.splitAtY( windows[ w ] * w->height());
|
2007-04-29 17:35:43 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
windows.remove( w );
|
|
|
|
w->unrefWindow();
|
|
|
|
}
|
|
|
|
}
|
2007-07-07 14:01:32 +00:00
|
|
|
effects->prePaintWindow( w, data, time );
|
2007-04-29 17:35:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void FlameEffect::paintWindow( EffectWindow* w, int mask, QRegion region, WindowPaintData& data )
|
|
|
|
{
|
|
|
|
if( windows.contains( w ))
|
|
|
|
{
|
2007-07-07 14:01:32 +00:00
|
|
|
WindowQuadList new_quads;
|
|
|
|
float ylimit = windows[ w ] * w->height(); // parts above this are already away
|
|
|
|
foreach( WindowQuad quad, data.quads )
|
2007-04-29 17:35:43 +00:00
|
|
|
{
|
2007-07-07 14:01:32 +00:00
|
|
|
if( quad.bottom() <= ylimit )
|
2007-04-29 17:35:43 +00:00
|
|
|
continue;
|
2007-07-07 14:01:32 +00:00
|
|
|
new_quads.append( quad );
|
2007-04-29 17:35:43 +00:00
|
|
|
}
|
2007-07-07 14:01:32 +00:00
|
|
|
if( new_quads.isEmpty())
|
2007-04-29 17:35:43 +00:00
|
|
|
return; // nothing to paint
|
2007-07-07 14:01:32 +00:00
|
|
|
data.quads = new_quads;
|
2007-04-29 17:35:43 +00:00
|
|
|
}
|
|
|
|
effects->paintWindow( w, mask, region, data );
|
|
|
|
}
|
|
|
|
|
|
|
|
void FlameEffect::postPaintWindow( EffectWindow* w )
|
|
|
|
{
|
|
|
|
if( windows.contains( w ))
|
|
|
|
effects->addRepaint( w->geometry()); // workspace, since the window under it will need painting too
|
|
|
|
effects->postPaintScreen();
|
|
|
|
}
|
|
|
|
|
|
|
|
void FlameEffect::windowClosed( EffectWindow* c )
|
|
|
|
{
|
|
|
|
windows[ c ] = 0;
|
|
|
|
c->refWindow();
|
|
|
|
}
|
|
|
|
|
|
|
|
void FlameEffect::windowDeleted( EffectWindow* c )
|
|
|
|
{
|
|
|
|
windows.remove( c );
|
|
|
|
}
|
|
|
|
|
|
|
|
} // namespace
|