2006-10-29 19:08:09 +00:00
|
|
|
/*****************************************************************
|
|
|
|
KWin - the KDE window manager
|
|
|
|
This file is part of the KDE project.
|
|
|
|
|
|
|
|
Copyright (C) 2006 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.
|
|
|
|
******************************************************************/
|
|
|
|
|
|
|
|
#include "scalein.h"
|
|
|
|
|
|
|
|
#include <client.h>
|
|
|
|
|
|
|
|
namespace KWinInternal
|
|
|
|
{
|
|
|
|
|
2006-11-17 08:43:24 +00:00
|
|
|
void ScaleInEffect::prePaintScreen( int* mask, QRegion* region, int time )
|
|
|
|
{
|
|
|
|
if( !windows.isEmpty())
|
2007-02-11 17:35:10 +00:00
|
|
|
*mask |= Scene::PAINT_SCREEN_WITH_TRANSFORMED_WINDOWS;
|
2006-11-17 08:43:24 +00:00
|
|
|
effects->prePaintScreen( mask, region, time );
|
|
|
|
}
|
|
|
|
|
2007-01-22 22:57:22 +00:00
|
|
|
void ScaleInEffect::prePaintWindow( EffectWindow* w, int* mask, QRegion* region, int time )
|
2006-10-29 19:08:09 +00:00
|
|
|
{
|
2007-01-22 22:57:22 +00:00
|
|
|
if( windows.contains( w ))
|
2006-10-29 19:08:09 +00:00
|
|
|
{
|
2007-01-22 22:57:22 +00:00
|
|
|
windows[ w ] += time / 500.; // complete change in 500ms
|
|
|
|
if( windows[ w ] < 1 )
|
2006-10-29 19:08:09 +00:00
|
|
|
*mask |= Scene::PAINT_WINDOW_TRANSFORMED;
|
|
|
|
else
|
2007-01-22 22:57:22 +00:00
|
|
|
windows.remove( w );
|
2006-10-29 19:08:09 +00:00
|
|
|
}
|
|
|
|
effects->prePaintWindow( w, mask, region, time );
|
|
|
|
}
|
|
|
|
|
2007-01-22 22:57:22 +00:00
|
|
|
void ScaleInEffect::paintWindow( EffectWindow* w, int mask, QRegion region, WindowPaintData& data )
|
2006-10-29 19:08:09 +00:00
|
|
|
{
|
2007-01-22 22:57:22 +00:00
|
|
|
if( windows.contains( w ))
|
2006-10-29 19:08:09 +00:00
|
|
|
{
|
2007-01-22 22:57:22 +00:00
|
|
|
data.xScale *= windows[ w ];
|
|
|
|
data.yScale *= windows[ w ];
|
|
|
|
data.xTranslate += int( w->window()->width() / 2 * ( 1 - windows[ w ] ));
|
|
|
|
data.yTranslate += int( w->window()->height() / 2 * ( 1 - windows[ w ] ));
|
2006-10-29 19:08:09 +00:00
|
|
|
}
|
|
|
|
effects->paintWindow( w, mask, region, data );
|
|
|
|
}
|
|
|
|
|
2007-01-22 22:57:22 +00:00
|
|
|
void ScaleInEffect::postPaintWindow( EffectWindow* w )
|
2006-10-29 19:08:09 +00:00
|
|
|
{
|
2007-01-22 22:57:22 +00:00
|
|
|
if( windows.contains( w ))
|
2007-02-12 15:22:43 +00:00
|
|
|
w->window()->addRepaintFull(); // trigger next animation repaint
|
2006-10-29 19:08:09 +00:00
|
|
|
effects->postPaintWindow( w );
|
|
|
|
}
|
|
|
|
|
2007-01-22 22:57:22 +00:00
|
|
|
void ScaleInEffect::windowAdded( EffectWindow* c )
|
2006-10-29 19:08:09 +00:00
|
|
|
{
|
2007-01-22 22:57:22 +00:00
|
|
|
Client* cc = dynamic_cast< Client* >( c->window());
|
2006-10-29 19:08:09 +00:00
|
|
|
if( cc == NULL || cc->isOnCurrentDesktop())
|
|
|
|
{
|
|
|
|
windows[ c ] = 0;
|
2007-02-12 15:22:43 +00:00
|
|
|
c->window()->addRepaintFull();
|
2006-10-29 19:08:09 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-01-22 22:57:22 +00:00
|
|
|
void ScaleInEffect::windowClosed( EffectWindow* c )
|
2006-10-29 19:08:09 +00:00
|
|
|
{
|
|
|
|
windows.remove( c );
|
|
|
|
}
|
|
|
|
|
|
|
|
} // namespace
|