2006-11-08 19:10:07 +00:00
|
|
|
/*****************************************************************
|
|
|
|
KWin - the KDE window manager
|
|
|
|
This file is part of the KDE project.
|
|
|
|
|
|
|
|
Copyright (C) 2006 Rivo Laks <rivolaks@hot.ee>
|
|
|
|
|
|
|
|
You can Freely distribute this program under the GNU General Public
|
|
|
|
License. See the file "COPYING" for the exact licensing terms.
|
|
|
|
******************************************************************/
|
|
|
|
|
|
|
|
|
|
|
|
#include "dialogparent.h"
|
|
|
|
|
|
|
|
#include <client.h>
|
|
|
|
|
2007-04-05 12:07:35 +00:00
|
|
|
namespace KWin
|
2006-11-08 19:10:07 +00:00
|
|
|
{
|
|
|
|
|
2007-03-25 10:48:07 +00:00
|
|
|
void DialogParentEffect::prePaintWindow( EffectWindow* w, int* mask, QRegion* paint, QRegion* clip, int time )
|
2006-11-08 19:10:07 +00:00
|
|
|
{
|
|
|
|
// How long does it take for the effect to get it's full strength (in ms)
|
|
|
|
const float changeTime = 200;
|
|
|
|
|
|
|
|
// Check if this window has a modal dialog and change the window's
|
|
|
|
// effect's strength accordingly
|
|
|
|
bool hasDialog = hasModalWindow(w->window());
|
|
|
|
if( hasDialog )
|
|
|
|
{
|
|
|
|
// Increase effect strength of this window
|
|
|
|
effectStrength[w] = qMin(1.0f, effectStrength[w] + time/changeTime);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
effectStrength[w] = qMax(0.0f, effectStrength[w] - time/changeTime);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Call the next effect
|
2007-03-25 10:48:07 +00:00
|
|
|
effects->prePaintWindow( w, mask, paint, clip, time );
|
2006-11-08 19:10:07 +00:00
|
|
|
}
|
|
|
|
|
2007-01-22 22:57:22 +00:00
|
|
|
void DialogParentEffect::paintWindow( EffectWindow* w, int mask, QRegion region, WindowPaintData& data )
|
2006-11-08 19:10:07 +00:00
|
|
|
{
|
|
|
|
float s = effectStrength[w];
|
|
|
|
if(s > 0.0f)
|
|
|
|
{
|
|
|
|
// Brightness will be within [1.0; 0.6]
|
|
|
|
data.brightness *= (1.0 - s * 0.4);
|
|
|
|
// Saturation within [1.0; 0.4]
|
|
|
|
data.saturation *= (1.0 - s * 0.6);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Call the next effect.
|
|
|
|
effects->paintWindow( w, mask, region, data );
|
|
|
|
}
|
|
|
|
|
2007-01-22 22:57:22 +00:00
|
|
|
void DialogParentEffect::postPaintWindow( EffectWindow* w )
|
2006-11-08 19:10:07 +00:00
|
|
|
{
|
|
|
|
float s = effectStrength[w];
|
|
|
|
|
|
|
|
// If strength is between 0 and 1, the effect is still in progress and the
|
|
|
|
// window has to be repainted during the next pass
|
|
|
|
if( s > 0.0 && s < 1.0 )
|
2007-02-12 15:22:43 +00:00
|
|
|
w->window()->addRepaintFull(); // trigger next animation repaint
|
2006-11-08 19:10:07 +00:00
|
|
|
|
|
|
|
// Call the next effect.
|
|
|
|
effects->postPaintWindow( w );
|
|
|
|
}
|
|
|
|
|
2007-01-22 22:57:22 +00:00
|
|
|
void DialogParentEffect::windowActivated( EffectWindow* t )
|
2006-11-08 19:10:07 +00:00
|
|
|
{
|
2007-02-12 15:22:43 +00:00
|
|
|
// If this window is a dialog, we need to repaint it's parent window, so
|
2006-11-08 19:10:07 +00:00
|
|
|
// that the effect could be run for it
|
|
|
|
// Set the window to be faded (or NULL if no window is active).
|
2007-01-22 22:57:22 +00:00
|
|
|
Client* c = qobject_cast<Client *>(t?t->window():NULL);
|
2006-11-08 19:10:07 +00:00
|
|
|
if ( c && c->isModal() )
|
|
|
|
{
|
|
|
|
// c is a modal dialog
|
2006-11-08 19:29:29 +00:00
|
|
|
ClientList mainclients = c->mainClients();
|
|
|
|
foreach( Client* parent, mainclients )
|
2007-02-12 15:22:43 +00:00
|
|
|
parent->addRepaintFull();
|
2006-11-08 19:10:07 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-01-22 22:57:22 +00:00
|
|
|
void DialogParentEffect::windowClosed( EffectWindow* t )
|
2006-11-08 19:10:07 +00:00
|
|
|
{
|
2007-02-12 15:22:43 +00:00
|
|
|
// If this window is a dialog, we need to repaint it's parent window, so
|
2006-11-08 19:10:07 +00:00
|
|
|
// that the effect could be run for it
|
|
|
|
// Set the window to be faded (or NULL if no window is active).
|
2007-01-22 22:57:22 +00:00
|
|
|
Client* c = qobject_cast<Client *>(t->window());
|
2006-11-08 19:10:07 +00:00
|
|
|
if ( c && c->isModal() )
|
|
|
|
{
|
|
|
|
// c is a modal dialog
|
2006-11-08 19:29:29 +00:00
|
|
|
ClientList mainclients = c->mainClients();
|
|
|
|
foreach( Client* parent, mainclients )
|
2007-02-12 15:22:43 +00:00
|
|
|
parent->addRepaintFull();
|
2006-11-08 19:10:07 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
bool DialogParentEffect::hasModalWindow( Toplevel* t )
|
|
|
|
{
|
|
|
|
Client* c = qobject_cast<Client *>(t);
|
|
|
|
if( !c )
|
|
|
|
return false;
|
2007-02-10 21:55:31 +00:00
|
|
|
return c->findModal() != NULL;
|
2006-11-08 19:10:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
} // namespace
|