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 "shakymove.h"
|
|
|
|
|
|
|
|
#include <workspace.h>
|
|
|
|
|
2007-04-05 12:07:35 +00:00
|
|
|
namespace KWin
|
2006-10-29 19:08:09 +00:00
|
|
|
{
|
|
|
|
|
|
|
|
ShakyMoveEffect::ShakyMoveEffect()
|
|
|
|
{
|
|
|
|
connect( &timer, SIGNAL( timeout()), SLOT( tick()));
|
|
|
|
}
|
|
|
|
|
|
|
|
static const int shaky_diff[] = { 0, 1, 2, 3, 2, 1, 0, -1, -2, -3, -2, -1 };
|
|
|
|
static const int SHAKY_MAX = sizeof( shaky_diff ) / sizeof( shaky_diff[ 0 ] );
|
|
|
|
|
|
|
|
void ShakyMoveEffect::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-10-29 19:08:09 +00:00
|
|
|
effects->prePaintScreen( mask, region, time );
|
|
|
|
}
|
|
|
|
|
2007-03-25 10:48:07 +00:00
|
|
|
void ShakyMoveEffect::prePaintWindow( EffectWindow* w, int* mask, QRegion* paint, QRegion* clip, 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
|
|
|
*mask |= Scene::PAINT_WINDOW_TRANSFORMED;
|
2007-03-25 10:48:07 +00:00
|
|
|
effects->prePaintWindow( w, mask, paint, clip, time );
|
2006-10-29 19:08:09 +00:00
|
|
|
}
|
|
|
|
|
2007-01-22 22:57:22 +00:00
|
|
|
void ShakyMoveEffect::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 ))
|
|
|
|
data.xTranslate += shaky_diff[ 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 ShakyMoveEffect::windowUserMovedResized( EffectWindow* c, bool first, bool last )
|
2006-10-29 19:08:09 +00:00
|
|
|
{
|
|
|
|
if( first )
|
|
|
|
{
|
|
|
|
if( windows.isEmpty())
|
|
|
|
timer.start( 50 );
|
|
|
|
windows[ c ] = 0;
|
|
|
|
}
|
|
|
|
else if( last )
|
|
|
|
{
|
|
|
|
windows.remove( c );
|
2007-02-12 15:22:43 +00:00
|
|
|
// just repaint whole screen, transformation is involved
|
|
|
|
c->window()->workspace()->addRepaintFull();
|
2006-10-29 19:08:09 +00:00
|
|
|
if( windows.isEmpty())
|
|
|
|
timer.stop();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-01-22 22:57:22 +00:00
|
|
|
void ShakyMoveEffect::windowClosed( EffectWindow* c )
|
2006-10-29 19:08:09 +00:00
|
|
|
{
|
|
|
|
windows.remove( c );
|
|
|
|
if( windows.isEmpty())
|
|
|
|
timer.stop();
|
|
|
|
}
|
|
|
|
|
|
|
|
// TODO use time provided with prePaintWindow() instead
|
|
|
|
void ShakyMoveEffect::tick()
|
|
|
|
{
|
2007-03-14 16:50:19 +00:00
|
|
|
for( QHash< const EffectWindow*, int >::Iterator it = windows.begin();
|
2006-10-29 19:08:09 +00:00
|
|
|
it != windows.end();
|
|
|
|
++it )
|
|
|
|
{
|
|
|
|
if( *it == SHAKY_MAX - 1 )
|
|
|
|
*it = 0;
|
|
|
|
else
|
|
|
|
++(*it);
|
2007-02-12 15:22:43 +00:00
|
|
|
// just repaint whole screen, transformation is involved
|
|
|
|
it.key()->window()->workspace()->addRepaintFull();
|
2006-10-29 19:08:09 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
} // namespace
|
|
|
|
|
|
|
|
#include "shakymove.moc"
|