1
/*****************************************************************
2
KWin - the KDE window manager
3
This file is part of the KDE project.
5
Copyright (C) 2006 Lubos Lunak <l.lunak@kde.org>
7
You can Freely distribute this program under the GNU General Public
8
License. See the file "COPYING" for the exact licensing terms.
9
******************************************************************/
11
#include "demo_shakymove.h"
16
KWIN_EFFECT(demo_shakymove, ShakyMoveEffect)
18
ShakyMoveEffect::ShakyMoveEffect()
20
connect(&timer, SIGNAL(timeout()), SLOT(tick()));
23
static const int shaky_diff[] = { 0, 1, 2, 3, 2, 1, 0, -1, -2, -3, -2, -1 };
24
static const int SHAKY_MAX = sizeof(shaky_diff) / sizeof(shaky_diff[ 0 ]);
26
void ShakyMoveEffect::prePaintScreen(ScreenPrePaintData& data, int time)
28
if (!windows.isEmpty())
29
data.mask |= PAINT_SCREEN_WITH_TRANSFORMED_WINDOWS;
30
effects->prePaintScreen(data, time);
33
void ShakyMoveEffect::prePaintWindow(EffectWindow* w, WindowPrePaintData& data, int time)
35
if (windows.contains(w))
36
data.setTransformed();
37
effects->prePaintWindow(w, data, time);
40
void ShakyMoveEffect::paintWindow(EffectWindow* w, int mask, QRegion region, WindowPaintData& data)
42
if (windows.contains(w))
43
data.xTranslate += shaky_diff[ windows[ w ]];
44
effects->paintWindow(w, mask, region, data);
47
void ShakyMoveEffect::windowUserMovedResized(EffectWindow* c, bool first, bool last)
50
if (windows.isEmpty())
55
// just repaint whole screen, transformation is involved
56
effects->addRepaintFull();
57
if (windows.isEmpty())
62
void ShakyMoveEffect::windowClosed(EffectWindow* c)
65
if (windows.isEmpty())
69
// TODO use time provided with prePaintWindow() instead
70
void ShakyMoveEffect::tick()
72
for (QHash< const EffectWindow*, int >::Iterator it = windows.begin();
75
if (*it == SHAKY_MAX - 1)
79
// just repaint whole screen, transformation is involved
80
effects->addRepaintFull();
86
#include "demo_shakymove.moc"