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