~ubuntu-branches/ubuntu/utopic/kde-workspace/utopic-proposed

« back to all changes in this revision

Viewing changes to kwin/effects/_test/flame.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Michał Zając
  • Date: 2011-07-09 08:31:15 UTC
  • Revision ID: james.westby@ubuntu.com-20110709083115-ohyxn6z93mily9fc
Tags: upstream-4.6.90
Import upstream version 4.6.90

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*****************************************************************
 
2
 KWin - the KDE window manager
 
3
 This file is part of the KDE project.
 
4
 
 
5
Copyright (C) 2007 Lubos Lunak <l.lunak@kde.org>
 
6
 
 
7
You can Freely distribute this program under the GNU General Public
 
8
License. See the file "COPYING" for the exact licensing terms.
 
9
******************************************************************/
 
10
 
 
11
#include "flame.h"
 
12
 
 
13
#include <assert.h>
 
14
#include <kdebug.h>
 
15
 
 
16
namespace KWin
 
17
{
 
18
 
 
19
KWIN_EFFECT(flame, FlameEffect)
 
20
 
 
21
void FlameEffect::prePaintScreen(ScreenPrePaintData& data, int time)
 
22
{
 
23
    if (!windows.isEmpty())
 
24
        data.mask |= PAINT_SCREEN_WITH_TRANSFORMED_WINDOWS;
 
25
    effects->prePaintScreen(data, time);
 
26
}
 
27
 
 
28
void FlameEffect::prePaintWindow(EffectWindow* w, WindowPrePaintData& data, int time)
 
29
{
 
30
    if (windows.contains(w)) {
 
31
        if (windows[ w ] < 1) {
 
32
            windows[ w ] += time / 500.;
 
33
            data.setTransformed();
 
34
            w->enablePainting(EffectWindow::PAINT_DISABLED_BY_DELETE);
 
35
            data.quads = data.quads.splitAtY(windows[ w ] * w->height());
 
36
        } else {
 
37
            windows.remove(w);
 
38
            w->unrefWindow();
 
39
        }
 
40
    }
 
41
    effects->prePaintWindow(w, data, time);
 
42
}
 
43
 
 
44
void FlameEffect::paintWindow(EffectWindow* w, int mask, QRegion region, WindowPaintData& data)
 
45
{
 
46
    if (windows.contains(w)) {
 
47
        WindowQuadList new_quads;
 
48
        double ylimit = windows[ w ] * w->height(); // parts above this are already away
 
49
        foreach (const WindowQuad & quad, data.quads) {
 
50
            if (quad.bottom() <= ylimit)
 
51
                continue;
 
52
            new_quads.append(quad);
 
53
        }
 
54
        if (new_quads.isEmpty())
 
55
            return; // nothing to paint
 
56
        data.quads = new_quads;
 
57
    }
 
58
    effects->paintWindow(w, mask, region, data);
 
59
}
 
60
 
 
61
void FlameEffect::postPaintWindow(EffectWindow* w)
 
62
{
 
63
    if (windows.contains(w))
 
64
        effects->addRepaint(w->geometry());  // workspace, since the window under it will need painting too
 
65
    effects->postPaintScreen();
 
66
}
 
67
 
 
68
void FlameEffect::windowClosed(EffectWindow* c)
 
69
{
 
70
    windows[ c ] = 0;
 
71
    c->refWindow();
 
72
}
 
73
 
 
74
void FlameEffect::windowDeleted(EffectWindow* c)
 
75
{
 
76
    windows.remove(c);
 
77
}
 
78
 
 
79
} // namespace