5faa397849
for use in effects (and not only). Now a list of window quads (=window areas) is created at the beginning of the paint pass, prepaint calls can modify the split itself (i.e. divide it into more parts). The actual paint calls can then modify these quads (i.e. transform their geometry). This will allow better control of how the split is done and also allow painting e.g. only the decoration differently. Still work in progress, but it works. Also pass data to prepaint functions in a struct, as there is already quite a number of them. svn path=/trunk/KDE/kdebase/workspace/; revision=684893
85 lines
2.3 KiB
C++
85 lines
2.3 KiB
C++
/*****************************************************************
|
|
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>
|
|
#include <kdebug.h>
|
|
|
|
namespace KWin
|
|
{
|
|
|
|
KWIN_EFFECT( flame, FlameEffect )
|
|
|
|
void FlameEffect::prePaintScreen( ScreenPrePaintData& data, int time )
|
|
{
|
|
if( !windows.isEmpty())
|
|
data.mask |= PAINT_SCREEN_WITH_TRANSFORMED_WINDOWS;
|
|
effects->prePaintScreen(data, time);
|
|
}
|
|
|
|
void FlameEffect::prePaintWindow( EffectWindow* w, WindowPrePaintData& data, int time )
|
|
{
|
|
if( windows.contains( w ))
|
|
{
|
|
if( windows[ w ] < 1 )
|
|
{
|
|
windows[ w ] += time / 500.;
|
|
data.mask |= PAINT_WINDOW_TRANSFORMED;
|
|
w->enablePainting( EffectWindow::PAINT_DISABLED_BY_DELETE );
|
|
data.quads = data.quads.splitAtY( windows[ w ] * w->height());
|
|
}
|
|
else
|
|
{
|
|
windows.remove( w );
|
|
w->unrefWindow();
|
|
}
|
|
}
|
|
effects->prePaintWindow( w, data, time );
|
|
}
|
|
|
|
void FlameEffect::paintWindow( EffectWindow* w, int mask, QRegion region, WindowPaintData& data )
|
|
{
|
|
if( windows.contains( w ))
|
|
{
|
|
WindowQuadList new_quads;
|
|
float ylimit = windows[ w ] * w->height(); // parts above this are already away
|
|
foreach( WindowQuad quad, data.quads )
|
|
{
|
|
if( quad.bottom() <= ylimit )
|
|
continue;
|
|
new_quads.append( quad );
|
|
}
|
|
if( new_quads.isEmpty())
|
|
return; // nothing to paint
|
|
data.quads = new_quads;
|
|
}
|
|
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
|