2007-04-29 17:35:43 +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 "maketransparent.h"
|
|
|
|
|
|
|
|
namespace KWin
|
|
|
|
{
|
|
|
|
|
2007-05-28 11:16:18 +00:00
|
|
|
KWIN_EFFECT( maketransparent, MakeTransparentEffect )
|
2007-04-29 17:35:43 +00:00
|
|
|
|
2007-07-19 10:07:49 +00:00
|
|
|
MakeTransparentEffect::MakeTransparentEffect()
|
|
|
|
{
|
|
|
|
// TODO options
|
|
|
|
decoration = 0.7;
|
|
|
|
moveresize = 0.5;
|
|
|
|
dialogs = 1.0;
|
|
|
|
}
|
|
|
|
|
2007-07-07 14:01:32 +00:00
|
|
|
void MakeTransparentEffect::prePaintWindow( EffectWindow* w, WindowPrePaintData& data, int time )
|
2007-04-29 17:35:43 +00:00
|
|
|
{
|
2007-07-19 10:07:49 +00:00
|
|
|
if( decoration != 1.0 )
|
|
|
|
{
|
|
|
|
data.mask |= PAINT_WINDOW_TRANSLUCENT;
|
|
|
|
data.mask &= ~PAINT_WINDOW_OPAQUE;
|
|
|
|
}
|
|
|
|
if(( moveresize != 1.0 && ( w->isUserMove() || w->isUserResize()))
|
|
|
|
|| ( dialogs != 1.0 && w->isDialog()))
|
2007-04-29 17:35:43 +00:00
|
|
|
{
|
2007-07-07 14:01:32 +00:00
|
|
|
data.mask |= PAINT_WINDOW_TRANSLUCENT;
|
|
|
|
data.mask &= ~PAINT_WINDOW_OPAQUE;
|
2007-04-29 17:35:43 +00:00
|
|
|
}
|
2007-07-07 14:01:32 +00:00
|
|
|
effects->prePaintWindow( w, data, time );
|
2007-04-29 17:35:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void MakeTransparentEffect::paintWindow( EffectWindow* w, int mask, QRegion region, WindowPaintData& data )
|
|
|
|
{
|
2007-07-19 10:07:49 +00:00
|
|
|
if( decoration != 1.0 )
|
|
|
|
data.decoration_opacity *= decoration;
|
|
|
|
if( dialogs != 1.0 && w->isDialog())
|
|
|
|
data.opacity *= dialogs;
|
|
|
|
if( moveresize != 1.0 && ( w->isUserMove() || w->isUserResize()))
|
|
|
|
data.opacity *= moveresize;
|
2007-04-29 17:35:43 +00:00
|
|
|
effects->paintWindow( w, mask, region, data );
|
|
|
|
}
|
|
|
|
|
|
|
|
void MakeTransparentEffect::windowUserMovedResized( EffectWindow* w, bool first, bool last )
|
|
|
|
{
|
2007-07-19 10:07:49 +00:00
|
|
|
if( moveresize != 1.0 && ( first || last ))
|
2007-04-29 17:35:43 +00:00
|
|
|
w->addRepaintFull();
|
|
|
|
}
|
|
|
|
|
|
|
|
} // namespace
|