kwin/effects/_test/flame.cpp

80 lines
2.2 KiB
C++
Raw Normal View History

/*****************************************************************
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
{
2011-01-30 14:34:42 +00:00
KWIN_EFFECT(flame, FlameEffect)
2011-01-30 14:34:42 +00:00
void FlameEffect::prePaintScreen(ScreenPrePaintData& data, int time)
{
if (!windows.isEmpty())
data.mask |= PAINT_SCREEN_WITH_TRANSFORMED_WINDOWS;
effects->prePaintScreen(data, time);
2011-01-30 14:34:42 +00:00
}
2011-01-30 14:34:42 +00:00
void FlameEffect::prePaintWindow(EffectWindow* w, WindowPrePaintData& data, int time)
{
if (windows.contains(w)) {
if (windows[ w ] < 1) {
windows[ w ] += time / 500.;
data.setTransformed();
2011-01-30 14:34:42 +00:00
w->enablePainting(EffectWindow::PAINT_DISABLED_BY_DELETE);
data.quads = data.quads.splitAtY(windows[ w ] * w->height());
} else {
windows.remove(w);
w->unrefWindow();
}
}
2011-01-30 14:34:42 +00:00
effects->prePaintWindow(w, data, time);
}
2011-01-30 14:34:42 +00:00
void FlameEffect::paintWindow(EffectWindow* w, int mask, QRegion region, WindowPaintData& data)
{
if (windows.contains(w)) {
WindowQuadList new_quads;
double ylimit = windows[ w ] * w->height(); // parts above this are already away
2011-01-30 14:34:42 +00:00
foreach (const WindowQuad & quad, data.quads) {
if (quad.bottom() <= ylimit)
continue;
2011-01-30 14:34:42 +00:00
new_quads.append(quad);
}
if (new_quads.isEmpty())
return; // nothing to paint
data.quads = new_quads;
}
2011-01-30 14:34:42 +00:00
effects->paintWindow(w, mask, region, data);
}
2011-01-30 14:34:42 +00:00
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();
2011-01-30 14:34:42 +00:00
}
2011-01-30 14:34:42 +00:00
void FlameEffect::windowClosed(EffectWindow* c)
{
windows[ c ] = 0;
c->refWindow();
2011-01-30 14:34:42 +00:00
}
2011-01-30 14:34:42 +00:00
void FlameEffect::windowDeleted(EffectWindow* c)
{
windows.remove(c);
}
} // namespace