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

« back to all changes in this revision

Viewing changes to kwin/effects/_test/test_thumbnail.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
/*
 
12
 
 
13
 Testing of painting a window more than once. The active window is painted
 
14
 once more as a thumbnail in the bottom-right corner of the screen.
 
15
 
 
16
*/
 
17
 
 
18
#include "test_thumbnail.h"
 
19
 
 
20
namespace KWin
 
21
{
 
22
 
 
23
KWIN_EFFECT(test_thumbnail, TestThumbnailEffect)
 
24
 
 
25
TestThumbnailEffect::TestThumbnailEffect()
 
26
    : active_window(NULL)
 
27
{
 
28
}
 
29
 
 
30
void TestThumbnailEffect::paintScreen(int mask, QRegion region, ScreenPaintData& data)
 
31
{
 
32
    effects->paintScreen(mask, region, data);
 
33
    if (active_window != NULL && region.contains(thumbnailRect())) {
 
34
        WindowPaintData data(active_window);
 
35
        QRect region;
 
36
        setPositionTransformations(data, region, active_window, thumbnailRect(), Qt::KeepAspectRatio);
 
37
        effects->drawWindow(active_window,
 
38
                            PAINT_WINDOW_OPAQUE | PAINT_WINDOW_TRANSLUCENT | PAINT_WINDOW_TRANSFORMED,
 
39
                            region, data);
 
40
    }
 
41
}
 
42
 
 
43
void TestThumbnailEffect::windowActivated(EffectWindow* act)
 
44
{
 
45
    active_window = act;
 
46
    effects->addRepaint(thumbnailRect());
 
47
}
 
48
 
 
49
void TestThumbnailEffect::windowDamaged(EffectWindow* w, const QRect&)
 
50
{
 
51
    if (w == active_window)
 
52
        effects->addRepaint(thumbnailRect());
 
53
    // TODO maybe just the relevant part of the area should be repainted?
 
54
}
 
55
 
 
56
void TestThumbnailEffect::windowGeometryShapeChanged(EffectWindow* w, const QRect& old)
 
57
{
 
58
    if (w == active_window && w->size() != old.size())
 
59
        effects->addRepaint(thumbnailRect());
 
60
}
 
61
 
 
62
void TestThumbnailEffect::windowClosed(EffectWindow* w)
 
63
{
 
64
    if (w == active_window) {
 
65
        active_window = NULL;
 
66
        effects->addRepaint(thumbnailRect());
 
67
    }
 
68
}
 
69
 
 
70
QRect TestThumbnailEffect::thumbnailRect() const
 
71
{
 
72
    return QRect(displayWidth() - 100, displayHeight() - 100, 100, 100);
 
73
}
 
74
 
 
75
} // namespace