kwin/effects/_test/test_thumbnail.cpp
Lucas Murray 846496d2c1 Cleaned up the effects/ directory by moving each individual effect into
its own directory, cleaned up the effect config macros and renamed
"MakeTransparent" to "Translucency" so that it matches its visible name.

svn path=/trunk/KDE/kdebase/workspace/; revision=921749
2009-02-05 15:35:38 +00:00

77 lines
2.2 KiB
C++

/*****************************************************************
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