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
|
|
|
|
{
|
|
|
|
|
2011-01-30 14:34:42 +00:00
|
|
|
KWIN_EFFECT(flame, FlameEffect)
|
2007-04-29 17:35:43 +00:00
|
|
|
|
2011-01-30 14:34:42 +00:00
|
|
|
void FlameEffect::prePaintScreen(ScreenPrePaintData& data, int time)
|
|
|
|
{
|
|
|
|
if (!windows.isEmpty())
|
2007-07-07 14:01:32 +00:00
|
|
|
data.mask |= PAINT_SCREEN_WITH_TRANSFORMED_WINDOWS;
|
|
|
|
effects->prePaintScreen(data, time);
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2007-04-29 17:35:43 +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) {
|
2007-04-29 17:35:43 +00:00
|
|
|
windows[ w ] += time / 500.;
|
2007-07-19 14:05:59 +00:00
|
|
|
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);
|
2007-04-29 17:35:43 +00:00
|
|
|
w->unrefWindow();
|
|
|
|
}
|
|
|
|
}
|
2011-01-30 14:34:42 +00:00
|
|
|
effects->prePaintWindow(w, data, time);
|
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
2011-01-30 14:34:42 +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;
|
2007-09-03 15:00:43 +00:00
|
|
|
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)
|
2007-04-29 17:35:43 +00:00
|
|
|
continue;
|
2011-01-30 14:34:42 +00:00
|
|
|
new_quads.append(quad);
|
|
|
|
}
|
|
|
|
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
|
|
|
}
|
2011-01-30 14:34:42 +00:00
|
|
|
effects->paintWindow(w, mask, region, data);
|
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
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
|
2007-04-29 17:35:43 +00:00
|
|
|
effects->postPaintScreen();
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
2011-01-30 14:34:42 +00:00
|
|
|
void FlameEffect::windowClosed(EffectWindow* c)
|
|
|
|
{
|
2007-04-29 17:35:43 +00:00
|
|
|
windows[ c ] = 0;
|
|
|
|
c->refWindow();
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
2011-01-30 14:34:42 +00:00
|
|
|
void FlameEffect::windowDeleted(EffectWindow* c)
|
|
|
|
{
|
|
|
|
windows.remove(c);
|
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
|
|
|
} // namespace
|