Change effects->windowOpacityChanged to also pass the old opacity; thanks Lubos!
Clean up FadeEffect a bit, and make it replace FadeOut in the default effects list. svn path=/branches/work/kwin_composite/; revision=633032
This commit is contained in:
parent
f3fb636b33
commit
a71753e5cd
7 changed files with 65 additions and 60 deletions
|
@ -48,7 +48,7 @@ void Effect::windowUserMovedResized( EffectWindow* , bool, bool )
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
void Effect::windowOpacityChanged( EffectWindow* )
|
void Effect::windowOpacityChanged( EffectWindow*, double )
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -168,10 +168,12 @@ void EffectsHandler::windowUserMovedResized( EffectWindow* c, bool first, bool l
|
||||||
ep.second->windowUserMovedResized( c, first, last );
|
ep.second->windowUserMovedResized( c, first, last );
|
||||||
}
|
}
|
||||||
|
|
||||||
void EffectsHandler::windowOpacityChanged( EffectWindow* c )
|
void EffectsHandler::windowOpacityChanged( EffectWindow* c, double old_opacity )
|
||||||
{
|
{
|
||||||
|
if( c->window()->opacity() == old_opacity )
|
||||||
|
return;
|
||||||
foreach( EffectPair ep, loaded_effects )
|
foreach( EffectPair ep, loaded_effects )
|
||||||
ep.second->windowOpacityChanged( c );
|
ep.second->windowOpacityChanged( c, old_opacity );
|
||||||
}
|
}
|
||||||
|
|
||||||
void EffectsHandler::windowAdded( EffectWindow* c )
|
void EffectsHandler::windowAdded( EffectWindow* c )
|
||||||
|
|
|
@ -73,7 +73,7 @@ class Effect
|
||||||
virtual void postPaintWindow( EffectWindow* w );
|
virtual void postPaintWindow( EffectWindow* w );
|
||||||
// called when moved/resized or once after it's finished
|
// called when moved/resized or once after it's finished
|
||||||
virtual void windowUserMovedResized( EffectWindow* c, bool first, bool last );
|
virtual void windowUserMovedResized( EffectWindow* c, bool first, bool last );
|
||||||
virtual void windowOpacityChanged( EffectWindow* c );
|
virtual void windowOpacityChanged( EffectWindow* c, double old_opacity );
|
||||||
virtual void windowAdded( EffectWindow* c );
|
virtual void windowAdded( EffectWindow* c );
|
||||||
virtual void windowClosed( EffectWindow* c );
|
virtual void windowClosed( EffectWindow* c );
|
||||||
virtual void windowDeleted( EffectWindow* c );
|
virtual void windowDeleted( EffectWindow* c );
|
||||||
|
@ -138,7 +138,7 @@ class EffectsHandler
|
||||||
// internal (used by kwin core or compositing code)
|
// internal (used by kwin core or compositing code)
|
||||||
void startPaint();
|
void startPaint();
|
||||||
void windowUserMovedResized( EffectWindow* c, bool first, bool last );
|
void windowUserMovedResized( EffectWindow* c, bool first, bool last );
|
||||||
void windowOpacityChanged( EffectWindow* c );
|
void windowOpacityChanged( EffectWindow* c, double old_opacity );
|
||||||
void windowAdded( EffectWindow* c );
|
void windowAdded( EffectWindow* c );
|
||||||
void windowClosed( EffectWindow* c );
|
void windowClosed( EffectWindow* c );
|
||||||
void windowDeleted( EffectWindow* c );
|
void windowDeleted( EffectWindow* c );
|
||||||
|
|
|
@ -58,7 +58,7 @@ void FadeEffect::prePaintWindow( EffectWindow* w, int* mask, QRegion* region, in
|
||||||
void FadeEffect::paintWindow( EffectWindow* w, int mask, QRegion region, WindowPaintData& data )
|
void FadeEffect::paintWindow( EffectWindow* w, int mask, QRegion region, WindowPaintData& data )
|
||||||
{
|
{
|
||||||
if( windows.contains( w ))
|
if( windows.contains( w ))
|
||||||
data.opacity = ( data.opacity + ( windows[ w ].opacity_is_zero ? 1 : 0 )) * windows[ w ].current;
|
data.opacity = ( data.opacity + ( w->window()->opacity() == 0.0 ? 1 : 0 )) * windows[ w ].current;
|
||||||
effects->paintWindow( w, mask, region, data );
|
effects->paintWindow( w, mask, region, data );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -69,53 +69,37 @@ void FadeEffect::postPaintWindow( EffectWindow* w )
|
||||||
effects->postPaintWindow( w );
|
effects->postPaintWindow( w );
|
||||||
}
|
}
|
||||||
|
|
||||||
void FadeEffect::windowOpacityChanged( EffectWindow* c )
|
void FadeEffect::windowOpacityChanged( EffectWindow* c, double old_opacity )
|
||||||
{
|
{
|
||||||
double new_opacity = c->window()->opacity();
|
double new_opacity = c->window()->opacity();
|
||||||
if( !windows.contains( c ))
|
if( !windows.contains( c ))
|
||||||
{ // we don't know the old opacity, so don't fade
|
|
||||||
windows[ c ].current = 1;
|
windows[ c ].current = 1;
|
||||||
windows[ c ].target = 1;
|
if( new_opacity == 0.0 )
|
||||||
|
{ // special case; if opacity is 0, we can't just multiply data.opacity
|
||||||
|
windows[ c ].current = windows[ c ].current * ( old_opacity == 0.0 ? 1 : old_opacity );
|
||||||
|
windows[ c ].target = 0;
|
||||||
|
windows[ c ].step_mult = 1;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if( windows[ c ].old_opacity == 0.0 )
|
windows[ c ].current = ( windows[ c ].current * ( old_opacity == 0.0 ? 1 : old_opacity )) / new_opacity;
|
||||||
windows[ c ].old_opacity = 1;
|
windows[ c ].target = 1;
|
||||||
if( new_opacity == 0.0 )
|
windows[ c ].step_mult = 1 / new_opacity;
|
||||||
{ // special case; if opacity is 0, we can't just multiply data.opacity
|
|
||||||
windows[ c ].opacity_is_zero = true;
|
|
||||||
windows[ c ].current = windows[ c ].current * windows[ c ].old_opacity;
|
|
||||||
windows[ c ].target = 0;
|
|
||||||
windows[ c ].step_mult = 1;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
windows[ c ].opacity_is_zero = false;
|
|
||||||
windows[ c ].current = ( windows[ c ].current * windows[ c ].old_opacity ) / new_opacity;
|
|
||||||
windows[ c ].target = 1;
|
|
||||||
windows[ c ].step_mult = 1 / new_opacity;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
windows[ c ].old_opacity = new_opacity;
|
|
||||||
c->window()->addRepaintFull();
|
c->window()->addRepaintFull();
|
||||||
}
|
}
|
||||||
|
|
||||||
void FadeEffect::windowAdded( EffectWindow* c )
|
void FadeEffect::windowAdded( EffectWindow* c )
|
||||||
{
|
{
|
||||||
if( !windows.contains( c ))
|
if( !windows.contains( c ))
|
||||||
{
|
|
||||||
windows[ c ].old_opacity = c->window()->opacity();
|
|
||||||
windows[ c ].current = 0;
|
windows[ c ].current = 0;
|
||||||
}
|
|
||||||
if( c->window()->opacity() == 0.0 )
|
if( c->window()->opacity() == 0.0 )
|
||||||
{
|
{
|
||||||
windows[ c ].opacity_is_zero = true;
|
|
||||||
windows[ c ].target = 0;
|
windows[ c ].target = 0;
|
||||||
windows[ c ].step_mult = 1;
|
windows[ c ].step_mult = 1;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
windows[ c ].opacity_is_zero = false;
|
|
||||||
windows[ c ].target = 1;
|
windows[ c ].target = 1;
|
||||||
windows[ c ].step_mult = 1 / c->window()->opacity();
|
windows[ c ].step_mult = 1 / c->window()->opacity();
|
||||||
}
|
}
|
||||||
|
@ -125,22 +109,13 @@ void FadeEffect::windowAdded( EffectWindow* c )
|
||||||
void FadeEffect::windowClosed( EffectWindow* c )
|
void FadeEffect::windowClosed( EffectWindow* c )
|
||||||
{
|
{
|
||||||
if( !windows.contains( c ))
|
if( !windows.contains( c ))
|
||||||
{
|
|
||||||
windows[ c ].old_opacity = c->window()->opacity();
|
|
||||||
windows[ c ].current = 1;
|
windows[ c ].current = 1;
|
||||||
}
|
|
||||||
if( c->window()->opacity() == 0.0 )
|
if( c->window()->opacity() == 0.0 )
|
||||||
{
|
|
||||||
windows[ c ].opacity_is_zero = true;
|
|
||||||
windows[ c ].step_mult = 1;
|
windows[ c ].step_mult = 1;
|
||||||
}
|
|
||||||
else
|
else
|
||||||
{
|
|
||||||
windows[ c ].opacity_is_zero = false;
|
|
||||||
windows[ c ].step_mult = 1 / c->window()->opacity();
|
windows[ c ].step_mult = 1 / c->window()->opacity();
|
||||||
}
|
|
||||||
windows[ c ].deleted = true;
|
|
||||||
windows[ c ].target = 0;
|
windows[ c ].target = 0;
|
||||||
|
windows[ c ].deleted = true;
|
||||||
c->window()->addRepaintFull();
|
c->window()->addRepaintFull();
|
||||||
static_cast< Deleted* >( c->window())->refWindow();
|
static_cast< Deleted* >( c->window())->refWindow();
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,7 +27,7 @@ class FadeEffect
|
||||||
virtual void paintWindow( EffectWindow* w, int mask, QRegion region, WindowPaintData& data );
|
virtual void paintWindow( EffectWindow* w, int mask, QRegion region, WindowPaintData& data );
|
||||||
virtual void postPaintWindow( EffectWindow* w );
|
virtual void postPaintWindow( EffectWindow* w );
|
||||||
// TODO react also on virtual desktop changes
|
// TODO react also on virtual desktop changes
|
||||||
virtual void windowOpacityChanged( EffectWindow* c );
|
virtual void windowOpacityChanged( EffectWindow* c, double old_opacity );
|
||||||
virtual void windowAdded( EffectWindow* c );
|
virtual void windowAdded( EffectWindow* c );
|
||||||
virtual void windowClosed( EffectWindow* c );
|
virtual void windowClosed( EffectWindow* c );
|
||||||
virtual void windowDeleted( EffectWindow* c );
|
virtual void windowDeleted( EffectWindow* c );
|
||||||
|
@ -41,20 +41,16 @@ class FadeEffect::WindowInfo
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
WindowInfo()
|
WindowInfo()
|
||||||
: deleted( false )
|
: current( 0 )
|
||||||
, opacity_is_zero( false )
|
|
||||||
, old_opacity( 0 )
|
|
||||||
, current( 0 )
|
|
||||||
, target( 0 )
|
, target( 0 )
|
||||||
, step_mult( 0 )
|
, step_mult( 0 )
|
||||||
|
, deleted( false )
|
||||||
{};
|
{};
|
||||||
bool isFading() const;
|
bool isFading() const;
|
||||||
bool deleted;
|
|
||||||
bool opacity_is_zero;
|
|
||||||
double old_opacity;
|
|
||||||
double current;
|
double current;
|
||||||
double target;
|
double target;
|
||||||
double step_mult;
|
double step_mult;
|
||||||
|
bool deleted;
|
||||||
};
|
};
|
||||||
|
|
||||||
inline bool FadeEffect::WindowInfo::isFading() const
|
inline bool FadeEffect::WindowInfo::isFading() const
|
||||||
|
|
15
events.cpp
15
events.cpp
|
@ -561,6 +561,7 @@ bool Client::windowEvent( XEvent* e )
|
||||||
if( e->xany.window == window()) // avoid doing stuff on frame or wrapper
|
if( e->xany.window == window()) // avoid doing stuff on frame or wrapper
|
||||||
{
|
{
|
||||||
unsigned long dirty[ 2 ];
|
unsigned long dirty[ 2 ];
|
||||||
|
double old_opacity = opacity();
|
||||||
info->event( e, dirty, 2 ); // pass through the NET stuff
|
info->event( e, dirty, 2 ); // pass through the NET stuff
|
||||||
|
|
||||||
if ( ( dirty[ WinInfo::PROTOCOLS ] & NET::WMName ) != 0 )
|
if ( ( dirty[ WinInfo::PROTOCOLS ] & NET::WMName ) != 0 )
|
||||||
|
@ -598,7 +599,7 @@ bool Client::windowEvent( XEvent* e )
|
||||||
addRepaintFull();
|
addRepaintFull();
|
||||||
scene->windowOpacityChanged( this );
|
scene->windowOpacityChanged( this );
|
||||||
if( effects )
|
if( effects )
|
||||||
effects->windowOpacityChanged( effectWindow());
|
effects->windowOpacityChanged( effectWindow(), old_opacity );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{ // forward to the frame if there's possibly another compositing manager running
|
{ // forward to the frame if there's possibly another compositing manager running
|
||||||
|
@ -1603,14 +1604,18 @@ void Client::keyPressEvent( uint key_code )
|
||||||
|
|
||||||
bool Unmanaged::windowEvent( XEvent* e )
|
bool Unmanaged::windowEvent( XEvent* e )
|
||||||
{
|
{
|
||||||
|
double old_opacity = opacity();
|
||||||
unsigned long dirty[ 2 ];
|
unsigned long dirty[ 2 ];
|
||||||
info->event( e, dirty, 2 ); // pass through the NET stuff
|
info->event( e, dirty, 2 ); // pass through the NET stuff
|
||||||
if( dirty[ NETWinInfo::PROTOCOLS2 ] & NET::WM2Opacity )
|
if( dirty[ NETWinInfo::PROTOCOLS2 ] & NET::WM2Opacity )
|
||||||
{
|
{
|
||||||
scene->windowOpacityChanged( this );
|
if( compositing())
|
||||||
if( effects )
|
{
|
||||||
effects->windowOpacityChanged( effectWindow());
|
addRepaintFull();
|
||||||
addRepaintFull();
|
scene->windowOpacityChanged( this );
|
||||||
|
if( effects )
|
||||||
|
effects->windowOpacityChanged( effectWindow(), old_opacity );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
switch (e->type)
|
switch (e->type)
|
||||||
{
|
{
|
||||||
|
|
24
options.cpp
24
options.cpp
|
@ -174,9 +174,8 @@ unsigned long Options::updateSettings()
|
||||||
CmdAllWheel = mouseWheelCommand(config->readEntry("CommandAllWheel","Nothing"));
|
CmdAllWheel = mouseWheelCommand(config->readEntry("CommandAllWheel","Nothing"));
|
||||||
|
|
||||||
//translucency settings - TODO
|
//translucency settings - TODO
|
||||||
config->setGroup( "Notification Messages" );
|
|
||||||
useTranslucency = config->readEntry("UseTranslucency", false);
|
|
||||||
config->setGroup( "Translucency");
|
config->setGroup( "Translucency");
|
||||||
|
useTranslucency = config->readEntry("UseTranslucency", true);
|
||||||
translucentActiveWindows = config->readEntry("TranslucentActiveWindows", false);
|
translucentActiveWindows = config->readEntry("TranslucentActiveWindows", false);
|
||||||
activeWindowOpacity = uint((config->readEntry("ActiveWindowOpacity", 100)/100.0)*0xFFFFFFFF);
|
activeWindowOpacity = uint((config->readEntry("ActiveWindowOpacity", 100)/100.0)*0xFFFFFFFF);
|
||||||
translucentInactiveWindows = config->readEntry("TranslucentInactiveWindows", false);
|
translucentInactiveWindows = config->readEntry("TranslucentInactiveWindows", false);
|
||||||
|
@ -195,6 +194,27 @@ unsigned long Options::updateSettings()
|
||||||
removeShadowsOnResize = config->readEntry("RemoveShadowsOnResize", true);
|
removeShadowsOnResize = config->readEntry("RemoveShadowsOnResize", true);
|
||||||
onlyDecoTranslucent = config->readEntry("OnlyDecoTranslucent", false);
|
onlyDecoTranslucent = config->readEntry("OnlyDecoTranslucent", false);
|
||||||
|
|
||||||
|
refreshRate = config->readEntry( "RefreshRate", 0 );
|
||||||
|
smoothScale = qBound( -1, config->readEntry( "SmoothScale", -1 ), 2 );
|
||||||
|
|
||||||
|
QString glmode = config->readEntry("GLMode", "TFP" ).upper();
|
||||||
|
if( glmode == "TFP" )
|
||||||
|
glMode = GLTFP;
|
||||||
|
else if( glmode == "SHM" )
|
||||||
|
glMode = GLSHM;
|
||||||
|
else
|
||||||
|
glMode = GLFallback;
|
||||||
|
glAlwaysRebind = config->readEntry("GLAlwaysRebind", false );
|
||||||
|
glDirect = config->readEntry("GLDirect", true );
|
||||||
|
glVSync = config->readEntry("GLVSync", true );
|
||||||
|
|
||||||
|
config->setGroup( "Effects" );
|
||||||
|
defaultEffects = config->readEntry( "Load", QStringList() << "ShowFps" << "Fade" );
|
||||||
|
|
||||||
|
config->setGroup( "EffectShowFps" );
|
||||||
|
effectShowFpsAlpha = config->readEntry( "Alpha", 0.5 );
|
||||||
|
effectShowFpsX = config->readEntry( "X", -10000 );
|
||||||
|
effectShowFpsY = config->readEntry( "Y", 0 );
|
||||||
// Read button tooltip animation effect from kdeglobals
|
// Read button tooltip animation effect from kdeglobals
|
||||||
// Since we want to allow users to enable window decoration tooltips
|
// Since we want to allow users to enable window decoration tooltips
|
||||||
// and not kstyle tooltips and vise-versa, we don't read the
|
// and not kstyle tooltips and vise-versa, we don't read the
|
||||||
|
|
15
toplevel.cpp
15
toplevel.cpp
|
@ -292,11 +292,18 @@ double Toplevel::opacity() const
|
||||||
return info->opacity() * 1.0 / 0xffffffff;
|
return info->opacity() * 1.0 / 0xffffffff;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Toplevel::setOpacity( double opacity )
|
void Toplevel::setOpacity( double new_opacity )
|
||||||
{
|
{
|
||||||
opacity = qBound( 0.0, opacity, 1.0 );
|
double old_opacity = opacity();
|
||||||
info->setOpacity( static_cast< unsigned long >( opacity * 0xffffffff ));
|
new_opacity = qBound( 0.0, new_opacity, 1.0 );
|
||||||
// we'll react on PropertyNotify
|
info->setOpacity( static_cast< unsigned long >( new_opacity * 0xffffffff ));
|
||||||
|
if( compositing())
|
||||||
|
{
|
||||||
|
addRepaintFull();
|
||||||
|
scene->windowOpacityChanged( this );
|
||||||
|
if( effects )
|
||||||
|
effects->windowOpacityChanged( effectWindow(), old_opacity );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
Loading…
Reference in a new issue