Rework of dim screen for administration mode effect. Now it changes brightness and saturation of all windows instead of painting a semi-transparent area on the screen. And it works nicely with fullscreen effects. So the windows are not dimmed in e.g. coverswitch.
BUG: 183046 svn path=/trunk/KDE/kdebase/workspace/; revision=923844
This commit is contained in:
parent
7249ca2cfb
commit
5d54cf9445
2 changed files with 42 additions and 110 deletions
|
@ -2,7 +2,7 @@
|
|||
KWin - the KDE window manager
|
||||
This file is part of the KDE project.
|
||||
|
||||
Copyright (C) 2008 Martin Gräßlin <ubuntu@martin-graesslin.com
|
||||
Copyright (C) 2008, 2009 Martin Gräßlin <kde@martin-graesslin.com>
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
|
@ -21,10 +21,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||
|
||||
#include <kwinglutils.h>
|
||||
|
||||
#ifdef KWIN_HAVE_OPENGL_COMPOSITING
|
||||
#include <GL/gl.h>
|
||||
#endif
|
||||
|
||||
namespace KWin
|
||||
{
|
||||
|
||||
|
@ -32,13 +28,10 @@ KWIN_EFFECT( dimscreen, DimScreenEffect )
|
|||
|
||||
DimScreenEffect::DimScreenEffect()
|
||||
: mActivated( false )
|
||||
, animation( false )
|
||||
, deactivate( false )
|
||||
, activateAnimation( false )
|
||||
, deactivateAnimation( false )
|
||||
{
|
||||
reconfigure( ReconfigureAll );
|
||||
#ifdef KWIN_HAVE_XRENDER_COMPOSITING
|
||||
alphaFormat = XRenderFindStandardFormat( display(), PictStandardARGB32 );
|
||||
#endif
|
||||
}
|
||||
|
||||
DimScreenEffect::~DimScreenEffect()
|
||||
|
@ -47,99 +40,51 @@ DimScreenEffect::~DimScreenEffect()
|
|||
|
||||
void DimScreenEffect::reconfigure( ReconfigureFlags )
|
||||
{
|
||||
animationDuration = Effect::animationTime( 300 );
|
||||
timeline.setDuration( animationTime( 250 ));
|
||||
}
|
||||
|
||||
void DimScreenEffect::prePaintScreen( ScreenPrePaintData& data, int time )
|
||||
{
|
||||
if( mActivated && activateAnimation && !effects->activeFullScreenEffect() )
|
||||
timeline.addTime( time );
|
||||
if( mActivated && deactivateAnimation )
|
||||
timeline.removeTime( time );
|
||||
if( mActivated && effects->activeFullScreenEffect() )
|
||||
timeline.removeTime( time );
|
||||
if( mActivated && !activateAnimation && !deactivateAnimation && !effects->activeFullScreenEffect() && timeline.value() != 1.0 )
|
||||
timeline.addTime( time );
|
||||
effects->prePaintScreen( data, time );
|
||||
}
|
||||
|
||||
void DimScreenEffect::paintScreen( int mask, QRegion region, ScreenPaintData& data )
|
||||
{
|
||||
effects->paintScreen( mask, region, data );
|
||||
if( mActivated || deactivate )
|
||||
{
|
||||
float opacity = 0.4;
|
||||
int height = Effect::displayHeight();
|
||||
if( animation )
|
||||
{
|
||||
int elapsed = animationTime.elapsed();
|
||||
float timeFactor = (float)((float)elapsed/(float)animationDuration);
|
||||
if( timeFactor > 1.0 )
|
||||
timeFactor = 1.0;
|
||||
if( deactivate )
|
||||
{
|
||||
opacity = opacity - opacity * timeFactor;
|
||||
}
|
||||
else
|
||||
{
|
||||
opacity = opacity * timeFactor;
|
||||
}
|
||||
}
|
||||
#ifdef KWIN_HAVE_OPENGL_COMPOSITING
|
||||
if( effects->compositingType() == OpenGLCompositing )
|
||||
{
|
||||
glPushAttrib( GL_CURRENT_BIT | GL_ENABLE_BIT );
|
||||
glEnable( GL_BLEND );
|
||||
glBlendFunc( GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA );
|
||||
glPolygonMode( GL_FRONT, GL_FILL );
|
||||
glColor4f( 0.0, 0.0, 0.0, opacity );
|
||||
float vertices[] = { 0.0, 0.0, 0.0, height, Effect::displayWidth(), height, Effect::displayWidth(), 0.0 };
|
||||
renderGLGeometry( 4, vertices );
|
||||
glDisable( GL_BLEND );
|
||||
glPopAttrib();
|
||||
}
|
||||
#endif
|
||||
#ifdef KWIN_HAVE_XRENDER_COMPOSITING
|
||||
if( effects->compositingType() == XRenderCompositing )
|
||||
{
|
||||
Pixmap pixmap = XCreatePixmap( display(), rootWindow(),
|
||||
Effect::displayWidth(), Effect::displayHeight(), 32 );
|
||||
Picture pic = XRenderCreatePicture( display(), pixmap, alphaFormat, 0, NULL );
|
||||
XFreePixmap( display(), pixmap );
|
||||
XRenderColor col;
|
||||
col.alpha = int( opacity * 0xffff );
|
||||
col.red = int( 0.0 * opacity * 0xffff );
|
||||
col.green = int( 0.0 * opacity * 0xffff );
|
||||
col.blue = int( 0.0 * opacity * 0xffff );
|
||||
XRenderFillRectangle( display(), PictOpSrc, pic, &col, 0, 0,
|
||||
Effect::displayWidth(), height );
|
||||
XRenderComposite( display(), PictOpOver,
|
||||
pic, None, effects->xrenderBufferPicture(),
|
||||
0, 0, 0, 0, 0, 0, Effect::displayWidth(), height );
|
||||
XRenderFreePicture( display(), pic );
|
||||
}
|
||||
#endif
|
||||
// re-paint active window
|
||||
EffectWindow* activeWindow = effects->activeWindow();
|
||||
if( activeWindow )
|
||||
{
|
||||
WindowPaintData data( activeWindow );
|
||||
effects->drawWindow( activeWindow, 0, activeWindow->geometry(), data );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void DimScreenEffect::postPaintScreen()
|
||||
{
|
||||
if( animation )
|
||||
if( mActivated )
|
||||
{
|
||||
if( animationTime.elapsed() >= animationDuration )
|
||||
if( activateAnimation && timeline.value() == 1.0 )
|
||||
{
|
||||
animation = false;
|
||||
deactivate = false;
|
||||
activateAnimation = false;
|
||||
effects->addRepaintFull();
|
||||
}
|
||||
effects->addRepaintFull();
|
||||
if( deactivateAnimation && timeline.value() == 0.0 )
|
||||
{
|
||||
deactivateAnimation = false;
|
||||
mActivated = false;
|
||||
effects->addRepaintFull();
|
||||
}
|
||||
// still animating
|
||||
if( timeline.value() > 0.0 && timeline.value() < 1.0 )
|
||||
effects->addRepaintFull();
|
||||
}
|
||||
effects->postPaintScreen();
|
||||
}
|
||||
|
||||
void DimScreenEffect::paintWindow( EffectWindow *w, int mask, QRegion region, WindowPaintData &data )
|
||||
{
|
||||
if( mActivated && ( w == effects->activeWindow() ) )
|
||||
if( mActivated && ( w != window ) &&
|
||||
!( w->isComboBox() || w->isDropdownMenu() || w->isTooltip() ) )
|
||||
{
|
||||
return;
|
||||
data.brightness *= (1.0 - 0.33 * timeline.value() );
|
||||
data.saturation *= (1.0 - 0.33 * timeline.value() );
|
||||
}
|
||||
effects->paintWindow( w, mask, region, data );
|
||||
}
|
||||
|
@ -151,24 +96,22 @@ void DimScreenEffect::windowActivated( EffectWindow *w )
|
|||
check << "kdesu kdesu";
|
||||
check << "kdesudo kdesudo";
|
||||
check << "polkit-kde-manager polkit-kde-manager";
|
||||
bool before = mActivated;
|
||||
if( check.contains( w->windowClass() ) )
|
||||
{
|
||||
mActivated = true;
|
||||
activateAnimation = true;
|
||||
deactivateAnimation = false;
|
||||
window = w;
|
||||
effects->addRepaintFull();
|
||||
}
|
||||
else
|
||||
{
|
||||
mActivated = false;
|
||||
}
|
||||
if( before != mActivated )
|
||||
{
|
||||
if( !mActivated )
|
||||
if( mActivated)
|
||||
{
|
||||
deactivate = true;
|
||||
activateAnimation = false;
|
||||
deactivateAnimation = true;
|
||||
effects->addRepaintFull();
|
||||
}
|
||||
animation = true;
|
||||
animationTime.restart();
|
||||
effects->addRepaintFull();
|
||||
}
|
||||
}
|
||||
} // namespace
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
KWin - the KDE window manager
|
||||
This file is part of the KDE project.
|
||||
|
||||
Copyright (C) 2008 Martin Gräßlin <ubuntu@martin-graesslin.com
|
||||
Copyright (C) 2008, 2009 Martin Gräßlin <kde@martin-graesslin.com>
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
|
@ -23,12 +23,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||
|
||||
#include <kwineffects.h>
|
||||
|
||||
#include <QTime>
|
||||
|
||||
#ifdef KWIN_HAVE_XRENDER_COMPOSITING
|
||||
#include <X11/extensions/Xrender.h>
|
||||
#endif
|
||||
|
||||
namespace KWin
|
||||
{
|
||||
|
||||
|
@ -41,21 +35,16 @@ class DimScreenEffect
|
|||
|
||||
virtual void reconfigure( ReconfigureFlags );
|
||||
virtual void prePaintScreen( ScreenPrePaintData& data, int time );
|
||||
virtual void paintScreen( int mask, QRegion region, ScreenPaintData& data );
|
||||
virtual void postPaintScreen();
|
||||
virtual void paintWindow( EffectWindow *w, int mask, QRegion region, WindowPaintData &data );
|
||||
virtual void windowActivated( EffectWindow *w );
|
||||
|
||||
private:
|
||||
bool mActivated;
|
||||
QTime animationTime;
|
||||
int animationDuration;
|
||||
bool animation;
|
||||
bool deactivate;
|
||||
|
||||
#ifdef KWIN_HAVE_XRENDER_COMPOSITING
|
||||
XRenderPictFormat* alphaFormat;
|
||||
#endif
|
||||
bool activateAnimation;
|
||||
bool deactivateAnimation;
|
||||
TimeLine timeline;
|
||||
EffectWindow* window;
|
||||
};
|
||||
|
||||
} // namespace
|
||||
|
|
Loading…
Reference in a new issue