kwin/effects/_test/test_thumbnail.cpp

76 lines
2.1 KiB
C++
Raw Normal View History

/*****************************************************************
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
{
2011-01-30 14:34:42 +00:00
KWIN_EFFECT(test_thumbnail, TestThumbnailEffect)
TestThumbnailEffect::TestThumbnailEffect()
2011-01-30 14:34:42 +00:00
: active_window(NULL)
{
}
2011-01-30 14:34:42 +00:00
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;
2011-01-30 14:34:42 +00:00
setPositionTransformations(data, region, active_window, thumbnailRect(), Qt::KeepAspectRatio);
effects->drawWindow(active_window,
PAINT_WINDOW_OPAQUE | PAINT_WINDOW_TRANSLUCENT | PAINT_WINDOW_TRANSFORMED,
region, data);
}
2011-01-30 14:34:42 +00:00
}
2011-01-30 14:34:42 +00:00
void TestThumbnailEffect::windowActivated(EffectWindow* act)
{
active_window = act;
2011-01-30 14:34:42 +00:00
effects->addRepaint(thumbnailRect());
}
2011-01-30 14:34:42 +00:00
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?
2011-01-30 14:34:42 +00:00
}
2011-01-30 14:34:42 +00:00
void TestThumbnailEffect::windowGeometryShapeChanged(EffectWindow* w, const QRect& old)
{
if (w == active_window && w->size() != old.size())
effects->addRepaint(thumbnailRect());
}
2011-01-30 14:34:42 +00:00
void TestThumbnailEffect::windowClosed(EffectWindow* w)
{
if (w == active_window) {
active_window = NULL;
2011-01-30 14:34:42 +00:00
effects->addRepaint(thumbnailRect());
}
2011-01-30 14:34:42 +00:00
}
QRect TestThumbnailEffect::thumbnailRect() const
2011-01-30 14:34:42 +00:00
{
return QRect(displayWidth() - 100, displayHeight() - 100, 100, 100);
}
} // namespace