Split cube mode and animation of desktop switching in separate effects: say hello to CubeSlide effect.

svn path=/trunk/KDE/kdebase/workspace/; revision=922342
This commit is contained in:
Martin Gräßlin 2009-02-06 18:53:16 +00:00
parent 00a50d882f
commit f7f5bc8326
16 changed files with 726 additions and 427 deletions

View file

@ -36,6 +36,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#ifdef KWIN_HAVE_OPENGL_COMPOSITING
#include "coverswitch/coverswitch_config.h"
#include "cube/cube_config.h"
#include "cube/cubeslide_config.h"
#include "cube/cylinder_config.h"
#include "cube/sphere_config.h"
#include "flipswitch/flipswitch_config.h"
@ -71,6 +72,7 @@ KWIN_EFFECT_CONFIG_MULTIPLE( builtins,
#ifdef KWIN_HAVE_OPENGL_COMPOSITING
KWIN_EFFECT_CONFIG_SINGLE( coverswitch, CoverSwitchEffectConfig )
KWIN_EFFECT_CONFIG_SINGLE( cube, CubeEffectConfig )
KWIN_EFFECT_CONFIG_SINGLE( cubeslide, CubeSlideEffectConfig )
KWIN_EFFECT_CONFIG_SINGLE( cylinder, CylinderEffectConfig )
KWIN_EFFECT_CONFIG_SINGLE( sphere, SphereEffectConfig )
KWIN_EFFECT_CONFIG_SINGLE( flipswitch, FlipSwitchEffectConfig )

View file

@ -4,6 +4,7 @@
# Source files
set( kwin4_effect_builtins_sources ${kwin4_effect_builtins_sources}
cube/cube.cpp
cube/cubeslide.cpp
cube/cylinder.cpp
cube/sphere.cpp
)
@ -11,6 +12,7 @@ set( kwin4_effect_builtins_sources ${kwin4_effect_builtins_sources}
# .desktop files
install( FILES
cube/cube.desktop
cube/cubeslide.desktop
cube/cylinder.desktop
cube/sphere.desktop
DESTINATION ${SERVICES_INSTALL_DIR}/kwin )
@ -30,6 +32,8 @@ install( FILES
set( kwin4_effect_builtins_config_sources ${kwin4_effect_builtins_config_sources}
cube/cube_config.cpp
cube/cube_config.ui
cube/cubeslide_config.cpp
cube/cubeslide_config.ui
cube/cylinder_config.cpp
cube/cylinder_config.ui
cube/sphere_config.cpp
@ -39,6 +43,7 @@ set( kwin4_effect_builtins_config_sources ${kwin4_effect_builtins_config_sources
# .desktop files
install( FILES
cube/cube_config.desktop
cube/cubeslide_config.desktop
cube/cylinder_config.desktop
cube/sphere_config.desktop
DESTINATION ${SERVICES_INSTALL_DIR}/kwin )

View file

@ -70,10 +70,7 @@ CubeEffect::CubeEffect()
, start( false )
, stop( false )
, reflectionPainting( false )
, slide( false )
, oldDesktop( 0 )
, activeScreen( 0 )
, animateDesktopChange( false )
, bigCube( false )
, bottomCap( false )
, closeOnMouseRelease( false )
@ -112,17 +109,14 @@ void CubeEffect::loadConfig( QString config )
reflection = conf.readEntry( "Reflection", true );
rotationDuration = animationTime( conf, "RotationDuration", 500 );
backgroundColor = conf.readEntry( "BackgroundColor", QColor( Qt::black ) );
animateDesktopChange = conf.readEntry( "AnimateDesktopChange", false );
bigCube = conf.readEntry( "BigCube", false );
// different settings for cylinder and sphere
if( config == "Cylinder" )
{
animateDesktopChange = false;
bigCube = true;
}
if( config == "Sphere" )
{
animateDesktopChange = false;
bigCube = true;
reflection = false;
}
@ -136,8 +130,6 @@ void CubeEffect::loadConfig( QString config )
useForTabBox = conf.readEntry( "TabBox", false );
invertKeys = conf.readEntry( "InvertKeys", false );
invertMouse = conf.readEntry( "InvertMouse", false );
dontSlidePanels = conf.readEntry( "DontSlidePanels", true );
dontSlideStickyWindows = conf.readEntry( "DontSlideStickyWindows", true );
QString file = conf.readEntry( "Wallpaper", QString("") );
if( wallpaper )
wallpaper->discard();
@ -197,8 +189,6 @@ void CubeEffect::loadConfig( QString config )
verticalTimeLine.setCurveShape( TimeLine::EaseInOutCurve );
verticalTimeLine.setDuration( rotationDuration );
slideTimeLine.setCurveShape( TimeLine::EaseInOutCurve );
slideTimeLine.setDuration( rotationDuration );
// do not connect the shortcut if we use cylinder or sphere
KActionCollection* actionCollection = new KActionCollection( this );
@ -251,15 +241,6 @@ void CubeEffect::prePaintScreen( ScreenPrePaintData& data, int time )
verticalTimeLine.addTime( time );
recompileList = true;
}
if( slide && !slideRotations.empty() )
{
slideTimeLine.addTime( time );
recompileList = true;
if( dontSlidePanels )
panels.clear();
if( dontSlideStickyWindows )
stickyWindows.clear();
}
}
effects->prePaintScreen( data, time );
}
@ -273,8 +254,7 @@ void CubeEffect::paintScreen( int mask, QRegion region, ScreenPaintData& data )
recompileList = false;
glPushMatrix();
glNewList( glList, GL_COMPILE );
if( !slide )
rotateCube();
rotateCube();
glEndList();
glPopMatrix();
}
@ -282,15 +262,12 @@ void CubeEffect::paintScreen( int mask, QRegion region, ScreenPaintData& data )
// compile List for cube
glNewList( glList + 1, GL_COMPILE );
glPushMatrix();
if( slide )
paintSlideCube( mask, region, data );
else
paintCube( mask, region, data );
paintCube( mask, region, data );
glPopMatrix();
glEndList();
QRect rect = effects->clientArea( FullScreenArea, activeScreen, effects->currentDesktop());
if( effects->numScreens() > 1 && (slide || bigCube ) )
if( effects->numScreens() > 1 && bigCube )
rect = effects->clientArea( FullArea, activeScreen, effects->currentDesktop() );
QRect fullRect = effects->clientArea( FullArea, activeScreen, effects->currentDesktop() );
@ -302,8 +279,8 @@ void CubeEffect::paintScreen( int mask, QRegion region, ScreenPaintData& data )
glClearColor( clearColor[0], clearColor[1], clearColor[2], clearColor[3] );
// wallpaper
if( wallpaper && !slide )
{
if( wallpaper )
{
wallpaper->bind();
wallpaper->render( region, rect );
wallpaper->unbind();
@ -313,7 +290,7 @@ void CubeEffect::paintScreen( int mask, QRegion region, ScreenPaintData& data )
glEnable( GL_BLEND );
glBlendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA );
if( effects->numScreens() > 1 && !slide && !bigCube )
if( effects->numScreens() > 1 && !bigCube )
{
windowsOnOtherScreens.clear();
// unfortunatelly we have to change the projection matrix in dual screen mode
@ -377,7 +354,7 @@ void CubeEffect::paintScreen( int mask, QRegion region, ScreenPaintData& data )
if( stop )
zTranslate *= ( 1.0 - timeLine.value() );
// reflection
if( reflection && (!slide) )
if( reflection )
{
// restrict painting the reflections to the current screen
PaintClipper::push( QRegion( rect ));
@ -440,7 +417,7 @@ void CubeEffect::paintScreen( int mask, QRegion region, ScreenPaintData& data )
glPopMatrix();
glPushMatrix();
if( effects->numScreens() > 1 && rect.x() != fullRect.x() && !slide && !bigCube )
if( effects->numScreens() > 1 && rect.x() != fullRect.x() && !bigCube )
{
// have to change the reflection area in horizontal layout and right screen
glTranslatef( -rect.x(), 0.0, 0.0 );
@ -472,7 +449,7 @@ void CubeEffect::paintScreen( int mask, QRegion region, ScreenPaintData& data )
}
glEnable( GL_CULL_FACE );
// caps
if( paintCaps && ( effects->numberOfDesktops() >= 2 ) && !slide )
if( paintCaps && ( effects->numberOfDesktops() >= 2 ))
{
glPushMatrix();
glCallList( glList );
@ -500,7 +477,7 @@ void CubeEffect::paintScreen( int mask, QRegion region, ScreenPaintData& data )
glPopMatrix();
// cap
if( paintCaps && ( effects->numberOfDesktops() >= 2 ) && !slide )
if( paintCaps && ( effects->numberOfDesktops() >= 2 ))
{
glPushMatrix();
glCallList( glList );
@ -516,7 +493,7 @@ void CubeEffect::paintScreen( int mask, QRegion region, ScreenPaintData& data )
}
glDisable( GL_CULL_FACE );
if( effects->numScreens() > 1 && !slide && !bigCube )
if( effects->numScreens() > 1 && !bigCube )
{
glPopMatrix();
// revert change of projection matrix
@ -529,7 +506,7 @@ void CubeEffect::paintScreen( int mask, QRegion region, ScreenPaintData& data )
glPopAttrib();
// desktop name box - inspired from coverswitch
if( displayDesktopName && (!slide) )
if( displayDesktopName )
{
QColor color_frame;
QColor color_text;
@ -563,7 +540,7 @@ void CubeEffect::paintScreen( int mask, QRegion region, ScreenPaintData& data )
text_font );
glPopAttrib();
}
if( effects->numScreens() > 1 && !slide && !bigCube )
if( effects->numScreens() > 1 && !bigCube )
{
foreach( EffectWindow* w, windowsOnOtherScreens )
{
@ -575,22 +552,6 @@ void CubeEffect::paintScreen( int mask, QRegion region, ScreenPaintData& data )
effects->paintWindow( w, 0, QRegion( w->x(), w->y(), w->width(), w->height() ), wData );
}
}
if( slide && dontSlidePanels )
{
foreach( EffectWindow* w, panels )
{
WindowPaintData wData( w );
effects->paintWindow( w, 0, QRegion( w->x(), w->y(), w->width(), w->height() ), wData );
}
}
if( slide && dontSlideStickyWindows )
{
foreach( EffectWindow* w, stickyWindows )
{
WindowPaintData wData( w );
effects->paintWindow( w, 0, QRegion( w->x(), w->y(), w->width(), w->height() ), wData );
}
}
}
else
{
@ -796,75 +757,6 @@ void CubeEffect::paintCube( int mask, QRegion region, ScreenPaintData& data )
painting_desktop = effects->currentDesktop();
}
void CubeEffect::paintSlideCube(int mask, QRegion region, KWin::ScreenPaintData& data)
{
// slide cube only paints to desktops at a time
// first the horizontal rotations followed by vertical rotations
QRect rect = effects->clientArea( FullArea, activeScreen, effects->currentDesktop() );
float point = rect.width()/2*tan(45.0f*M_PI/180.0f);
cube_painting = true;
painting_desktop = frontDesktop;
ScreenPaintData firstFaceData = data;
ScreenPaintData secondFaceData = data;
RotationData firstFaceRot = RotationData();
RotationData secondFaceRot = RotationData();
RotationDirection direction = slideRotations.head();
int secondDesktop;
switch ( direction )
{
case Left:
firstFaceRot.axis = RotationData::YAxis;
secondFaceRot.axis = RotationData::YAxis;
secondDesktop = effects->desktopToLeft( frontDesktop, true );
firstFaceRot.angle = 90.0f*slideTimeLine.value();
secondFaceRot.angle = -90.0f*(1.0f - slideTimeLine.value());
break;
case Right:
firstFaceRot.axis = RotationData::YAxis;
secondFaceRot.axis = RotationData::YAxis;
secondDesktop = effects->desktopToRight( frontDesktop, true );
firstFaceRot.angle = -90.0f*slideTimeLine.value();
secondFaceRot.angle = 90.0f*(1.0f - slideTimeLine.value());
break;
case Upwards:
firstFaceRot.axis = RotationData::XAxis;
secondFaceRot.axis = RotationData::XAxis;
secondDesktop = effects->desktopUp( frontDesktop, true);
firstFaceRot.angle = -90.0f*slideTimeLine.value();
secondFaceRot.angle = 90.0f*(1.0f - slideTimeLine.value());
point = rect.height()/2*tan(45.0f*M_PI/180.0f);
break;
case Downwards:
firstFaceRot.axis = RotationData::XAxis;
secondFaceRot.axis = RotationData::XAxis;
secondDesktop = effects->desktopDown( frontDesktop, true );
firstFaceRot.angle = 90.0f*slideTimeLine.value();
secondFaceRot.angle = -90.0f*(1.0f - slideTimeLine.value());
point = rect.height()/2*tan(45.0f*M_PI/180.0f);
break;
default:
// totally impossible
return;
}
// front desktop
firstFaceRot.xRotationPoint = rect.width()/2;
firstFaceRot.yRotationPoint = rect.height()/2;
firstFaceRot.zRotationPoint = -point;
firstFaceData.rotation = &firstFaceRot;
effects->paintScreen( mask, region, firstFaceData );
// second desktop
painting_desktop = secondDesktop;
secondFaceRot.xRotationPoint = rect.width()/2;
secondFaceRot.yRotationPoint = rect.height()/2;
secondFaceRot.zRotationPoint = -point;
secondFaceData.rotation = &secondFaceRot;
effects->paintScreen( mask, region, secondFaceData );
cube_painting = false;
painting_desktop = effects->currentDesktop();
}
void CubeEffect::paintCap( float z, float zTexture )
{
QRect rect = effects->clientArea( FullArea, activeScreen, effects->currentDesktop());
@ -1072,8 +964,6 @@ void CubeEffect::postPaintScreen()
keyboard_grab = false;
effects->destroyInputWindow( input );
windowsOnOtherScreens.clear();
panels.clear();
stickyWindows.clear();
effects->setActiveFullScreenEffect( 0 );
@ -1159,52 +1049,10 @@ void CubeEffect::postPaintScreen()
effects->addRepaintFull();
return; // rotation has to end before cube is closed
}
if( slide )
{
if( slideTimeLine.value() == 1.0 )
{
RotationDirection direction = slideRotations.dequeue();
switch (direction)
{
case Left:
frontDesktop = effects->desktopToLeft( frontDesktop, true );
break;
case Right:
frontDesktop = effects->desktopToRight( frontDesktop, true );
break;
case Upwards:
frontDesktop = effects->desktopUp( frontDesktop, true );
break;
case Downwards:
frontDesktop = effects->desktopDown( frontDesktop, true );
break;
}
slideTimeLine.setProgress( 0.0 );
if( !slideRotations.empty() )
{
effects->addRepaintFull();
return;
}
}
else
{
effects->addRepaintFull();
return;
}
}
if( schedule_close )
{
schedule_close = false;
if( !slide )
{
stop = true;
}
else
{
activated = false;
slide = false;
effects->setActiveFullScreenEffect( 0 );
}
stop = true;
effects->addRepaintFull();
}
}
@ -1298,15 +1146,6 @@ void CubeEffect::prePaintWindow( EffectWindow* w, WindowPrePaintData& data, int
}
w->disablePainting( EffectWindow::PAINT_DISABLED_BY_DESKTOP );
}
if( slide && dontSlidePanels && w->isDock())
{
panels.insert( w );
}
if( slide && dontSlideStickyWindows && !w->isDock() &&
!w->isDesktop() && w->isOnAllDesktops())
{
stickyWindows.insert( w );
}
}
}
effects->prePaintWindow( w, data, time );
@ -1316,15 +1155,8 @@ void CubeEffect::paintWindow( EffectWindow* w, int mask, QRegion region, WindowP
{
if( activated && cube_painting )
{
if( slide && dontSlidePanels && w->isDock() )
return;
if( slide && dontSlideStickyWindows &&
w->isOnAllDesktops() && !w->isDock() && !w->isDesktop() )
return;
//kDebug(1212) << w->caption();
float opacity = cubeOpacity;
if( slide )
opacity = 1.0f;
if( start )
{
opacity = 1.0 - (1.0 - opacity)*timeLine.value();
@ -1343,19 +1175,6 @@ void CubeEffect::paintWindow( EffectWindow* w, int mask, QRegion region, WindowP
if( painting_desktop == effects->currentDesktop() && (!w->isOnDesktop( painting_desktop )) )
opacity = cubeOpacity * (1.0 - timeLine.value());
}
bool slideOpacity = false;
// fade in windows from different desktops in first slide step
if( slide && painting_desktop == oldDesktop && (!w->isOnDesktop( painting_desktop )) )
{
opacity = timeLine.value();
slideOpacity = true;
}
// fade out windows from different desktops in last slide step
if( slide && rotations.empty() && painting_desktop == effects->currentDesktop() && (!w->isOnDesktop( painting_desktop )) )
{
opacity = 1.0 - timeLine.value();
slideOpacity = true;
}
// check for windows belonging to the previous desktop
int prev_desktop = painting_desktop -1;
if( prev_desktop == 0 )
@ -1411,16 +1230,13 @@ void CubeEffect::paintWindow( EffectWindow* w, int mask, QRegion region, WindowP
opacity = cubeOpacity * (1.0 - timeLine.value());
}
}
if( !slide || (slide && !w->isDesktop()) || slideOpacity )
{
// HACK set opacity to 0.99 in case of fully opaque to ensure that windows are painted in correct sequence
// bug #173214
if( opacity > 0.99f )
opacity = 0.99f;
if( opacityDesktopOnly && !w->isDesktop() )
opacity = 0.99f;
data.opacity *= opacity;
}
// HACK set opacity to 0.99 in case of fully opaque to ensure that windows are painted in correct sequence
// bug #173214
if( opacity > 0.99f )
opacity = 0.99f;
if( opacityDesktopOnly && !w->isDesktop() )
opacity = 0.99f;
data.opacity *= opacity;
if( w->isOnDesktop(painting_desktop) && w->x() < rect.x() )
{
@ -1470,7 +1286,7 @@ void CubeEffect::paintWindow( EffectWindow* w, int mask, QRegion region, WindowP
}
data.quads = new_quads;
}
if( w->isDesktop() && effects->numScreens() > 1 && paintCaps && !slide )
if( w->isDesktop() && effects->numScreens() > 1 && paintCaps )
{
QRegion paint = QRegion( rect );
for( int i=0; i<effects->numScreens(); i++ )
@ -1802,22 +1618,19 @@ void CubeEffect::setActive( bool active )
effects->startMousePolling();
activated = true;
activeScreen = effects->activeScreen();
if( !slide )
{
keyboard_grab = effects->grabKeyboard( this );
input = effects->createInputWindow( this, 0, 0, displayWidth(), displayHeight(),
Qt::OpenHandCursor );
frontDesktop = effects->currentDesktop();
zoom = 0.0;
start = true;
}
keyboard_grab = effects->grabKeyboard( this );
input = effects->createInputWindow( this, 0, 0, displayWidth(), displayHeight(),
Qt::OpenHandCursor );
frontDesktop = effects->currentDesktop();
zoom = 0.0;
start = true;
effects->setActiveFullScreenEffect( this );
kDebug(1212) << "Cube is activated";
verticalPosition = Normal;
verticalRotating = false;
manualAngle = 0.0;
manualVerticalAngle = 0.0;
if( reflection && !slide )
if( reflection )
{
// clip parts above the reflection area
double eqn[4] = {0.0, 1.0, 0.0, 0.0};
@ -1834,10 +1647,10 @@ void CubeEffect::setActive( bool active )
capListCreated = false;
recompileList = true;
// create the capList
if( paintCaps && !slide )
if( paintCaps )
{
QRect rect = effects->clientArea( FullScreenArea, activeScreen, effects->currentDesktop());
if( effects->numScreens() > 1 && (slide || bigCube ) )
if( effects->numScreens() > 1 && bigCube )
rect = effects->clientArea( FullArea, activeScreen, effects->currentDesktop() );
float cubeAngle = (float)((float)(effects->numberOfDesktops() - 2 )/(float)effects->numberOfDesktops() * 180.0f);
float point = rect.width()/2*tan(cubeAngle*0.5f*M_PI/180.0f);
@ -1863,10 +1676,10 @@ void CubeEffect::mouseChanged( const QPoint& pos, const QPoint& oldpos, Qt::Mous
return;
if( tabBoxMode )
return;
if( stop || slide )
if( stop )
return;
QRect rect = effects->clientArea( FullScreenArea, activeScreen, effects->currentDesktop());
if( effects->numScreens() > 1 && (slide || bigCube ) )
if( effects->numScreens() > 1 && bigCube )
rect = effects->clientArea( FullArea, activeScreen, effects->currentDesktop() );
if( buttons.testFlag( Qt::LeftButton ) )
{
@ -1973,82 +1786,6 @@ void CubeEffect::windowInputMouseEvent( Window w, QEvent* e )
}
}
void CubeEffect::desktopChanged( int old )
{
if( effects->activeFullScreenEffect() && effects->activeFullScreenEffect() != this )
return;
if( activated && !slide )
return;
if( !animateDesktopChange )
return;
slide = true;
bool activate = true;
if( !slideRotations.empty() )
{
// last slide still in progress
activate = false;
old = frontDesktop;
RotationDirection direction = slideRotations.dequeue();
slideRotations.clear();
slideRotations.enqueue( direction );
}
oldDesktop = old;
// calculate distance in respect to pager
int x, y;
Qt::Orientation orientation;
effects->calcDesktopLayout( &x, &y, &orientation );
int x_distance = (( effects->currentDesktop() - 1 ) % x ) - (( old - 1 ) % x );
if( qAbs( x_distance ) > x/2 )
{
int sign = -1 * (x_distance/qAbs( x_distance ));
x_distance = sign * ( x - qAbs( x_distance ));
}
if( x_distance > 0 )
{
for( int i=0; i<x_distance; i++ )
{
slideRotations.enqueue( Right );
}
}
else if( x_distance < 0 )
{
x_distance *= -1;
for( int i=0; i<x_distance; i++ )
{
slideRotations.enqueue( Left );
}
}
int y_distance = (( effects->currentDesktop() -1 ) / x ) - (( old - 1 ) / x );
if( qAbs( y_distance ) > y/2 )
{
int sign = -1 * (y_distance/qAbs( y_distance ));
y_distance = sign * ( y - qAbs( y_distance ));
}
if( y_distance > 0 )
{
for( int i=0; i<y_distance; i++ )
{
slideRotations.enqueue( Downwards );
}
}
if( y_distance < 0 )
{
y_distance *= -1;
for( int i=0; i<y_distance; i++ )
{
slideRotations.enqueue( Upwards );
}
}
if( activate )
{
setActive( true );
slideTimeLine.setProgress( 0.0 );
frontDesktop = old;
setActive( false );
}
}
void CubeEffect::tabBoxAdded( int mode )
{
if( activated )

View file

@ -48,7 +48,6 @@ class CubeEffect
virtual void mouseChanged( const QPoint& pos, const QPoint& oldpos, Qt::MouseButtons buttons,
Qt::MouseButtons oldbuttons, Qt::KeyboardModifiers modifiers, Qt::KeyboardModifiers oldmodifiers );
virtual void windowInputMouseEvent( Window w, QEvent* e );
virtual void desktopChanged( int old );
virtual void tabBoxAdded( int mode );
virtual void tabBoxUpdated();
virtual void tabBoxClosed();
@ -71,7 +70,6 @@ class CubeEffect
Down
};
virtual void paintCube( int mask, QRegion region, ScreenPaintData& data );
void paintSlideCube( int mask, QRegion region, ScreenPaintData& data );
virtual void paintCap( float z, float zTexture );
virtual void paintCapStep( float z, float zTexture, bool texture );
void loadConfig( QString config );
@ -96,13 +94,11 @@ class CubeEffect
bool paintCaps;
TimeLine timeLine;
TimeLine verticalTimeLine;
TimeLine slideTimeLine;
RotationDirection rotationDirection;
RotationDirection verticalRotationDirection;
VerticalRotationPosition verticalPosition;
QQueue<RotationDirection> rotations;
QQueue<RotationDirection> verticalRotations;
QQueue<RotationDirection> slideRotations;
QColor backgroundColor;
QColor capColor;
GLTexture* wallpaper;
@ -114,14 +110,9 @@ class CubeEffect
bool start;
bool stop;
bool reflectionPainting;
bool slide;
int oldDesktop;
int rotationDuration;
QList<EffectWindow*> windowsOnOtherScreens;
QSet<EffectWindow*> panels;
QSet<EffectWindow*> stickyWindows;
int activeScreen;
bool animateDesktopChange;
bool bigCube;
bool bottomCap;
bool closeOnMouseRelease;
@ -131,8 +122,6 @@ class CubeEffect
bool invertKeys;
bool invertMouse;
bool tabBoxMode;
bool dontSlidePanels;
bool dontSlideStickyWindows;
bool shortcutsRegistered;
// GL lists

View file

@ -72,7 +72,6 @@ CubeEffectConfig::CubeEffectConfig(QWidget* parent, const QVariantList& args) :
connect(m_ui->displayDesktopNameBox, SIGNAL(stateChanged(int)), this, SLOT(changed()));
connect(m_ui->reflectionBox, SIGNAL(stateChanged(int)), this, SLOT(changed()));
connect(m_ui->backgroundColorButton, SIGNAL(changed(QColor)), this, SLOT(changed()));
connect(m_ui->animateDesktopChangeBox, SIGNAL(stateChanged(int)), this, SLOT(changed()));
connect(m_ui->bigCubeBox, SIGNAL(stateChanged(int)), this, SLOT(changed()));
connect(m_ui->cubeCapsBox, SIGNAL(stateChanged(int)), this, SLOT(changed()));
connect(m_ui->cubeCapsBox, SIGNAL(stateChanged(int)), this, SLOT(capsSelectionChanged()));
@ -84,8 +83,6 @@ CubeEffectConfig::CubeEffectConfig(QWidget* parent, const QVariantList& args) :
connect(m_ui->walkThroughDesktopBox, SIGNAL(stateChanged(int)), this, SLOT(changed()));
connect(m_ui->invertKeysBox, SIGNAL(stateChanged(int)), this, SLOT(changed()));
connect(m_ui->invertMouseBox, SIGNAL(stateChanged(int)), this, SLOT(changed()));
connect(m_ui->dontSlidePanelsBox, SIGNAL(stateChanged(int)), this, SLOT(changed()));
connect(m_ui->dontSlideStickyWindowsBox, SIGNAL(stateChanged(int)), this, SLOT(changed()));
load();
}
@ -105,7 +102,6 @@ void CubeEffectConfig::load()
QColor capColor = conf.readEntry( "CapColor", KColorScheme( QPalette::Active, KColorScheme::Window ).background().color() );
bool texturedCaps = conf.readEntry( "TexturedCaps", true );
bool caps = conf.readEntry( "Caps", true );
bool animateChange = conf.readEntry( "AnimateDesktopChange", false );
bool bigCube = conf.readEntry( "BigCube", false );
bool closeOnMouseRelease = conf.readEntry( "CloseOnMouseRelease", false );
bool walkThroughDesktop = conf.readEntry( "TabBox", false );
@ -113,8 +109,6 @@ void CubeEffectConfig::load()
m_ui->wallpaperRequester->setPath( conf.readEntry( "Wallpaper", "" ) );
bool invertKeys = conf.readEntry( "InvertKeys", false );
bool invertMouse = conf.readEntry( "InvertMouse", false );
bool dontSlidePanels = conf.readEntry( "DontSlidePanels", true );
bool dontSlideStickyWindows = conf.readEntry( "DontSlideStickyWindows", true );
m_ui->rotationDurationSpin->setValue( duration );
m_ui->cubeOpacitySlider->setValue( opacity );
@ -152,14 +146,6 @@ void CubeEffectConfig::load()
{
m_ui->capsImageBox->setCheckState( Qt::Unchecked );
}
if( animateChange )
{
m_ui->animateDesktopChangeBox->setCheckState( Qt::Checked );
}
else
{
m_ui->animateDesktopChangeBox->setCheckState( Qt::Unchecked );
}
if( bigCube )
{
m_ui->bigCubeBox->setCheckState( Qt::Checked );
@ -188,8 +174,6 @@ void CubeEffectConfig::load()
m_ui->capColorButton->setColor( capColor );
m_ui->invertKeysBox->setChecked( invertKeys );
m_ui->invertMouseBox->setChecked( invertMouse );
m_ui->dontSlidePanelsBox->setChecked( dontSlidePanels );
m_ui->dontSlideStickyWindowsBox->setChecked( dontSlideStickyWindows );
capsSelectionChanged();
emit changed(false);
@ -208,7 +192,6 @@ void CubeEffectConfig::save()
conf.writeEntry( "Caps", m_ui->cubeCapsBox->checkState() == Qt::Checked ? true : false );
conf.writeEntry( "CapColor", m_ui->capColorButton->color() );
conf.writeEntry( "TexturedCaps", m_ui->capsImageBox->checkState() == Qt::Checked ? true : false );
conf.writeEntry( "AnimateDesktopChange", m_ui->animateDesktopChangeBox->checkState() == Qt::Checked ? true : false );
conf.writeEntry( "BigCube", m_ui->bigCubeBox->checkState() == Qt::Checked ? true : false );
conf.writeEntry( "CloseOnMouseRelease", m_ui->closeOnMouseReleaseBox->checkState() == Qt::Checked ? true : false );
conf.writeEntry( "Wallpaper", m_ui->wallpaperRequester->url().path() );
@ -216,8 +199,6 @@ void CubeEffectConfig::save()
conf.writeEntry( "TabBox", m_ui->walkThroughDesktopBox->checkState() == Qt::Checked ? true : false );
conf.writeEntry( "InvertKeys", m_ui->invertKeysBox->isChecked() );
conf.writeEntry( "InvertMouse", m_ui->invertMouseBox->isChecked() );
conf.writeEntry( "DontSlidePanels", m_ui->dontSlidePanelsBox->isChecked() );
conf.writeEntry( "DontSlideStickyWindows", m_ui->dontSlideStickyWindowsBox->isChecked() );
m_ui->editor->save();
@ -239,7 +220,6 @@ void CubeEffectConfig::defaults()
m_ui->cubeCapsBox->setCheckState( Qt::Checked );
m_ui->capColorButton->setColor( KColorScheme( QPalette::Active, KColorScheme::Window ).background().color() );
m_ui->capsImageBox->setCheckState( Qt::Checked );
m_ui->animateDesktopChangeBox->setCheckState( Qt::Unchecked );
m_ui->bigCubeBox->setCheckState( Qt::Unchecked );
m_ui->closeOnMouseReleaseBox->setCheckState( Qt::Unchecked );
m_ui->wallpaperRequester->setPath( "" );
@ -247,8 +227,6 @@ void CubeEffectConfig::defaults()
m_ui->walkThroughDesktopBox->setCheckState( Qt::Unchecked );
m_ui->invertKeysBox->setChecked( false );
m_ui->invertMouseBox->setChecked( false );
m_ui->dontSlidePanelsBox->setChecked( true );
m_ui->dontSlideStickyWindowsBox->setChecked( true );
m_ui->editor->allDefault();
emit changed(true);
}

View file

@ -271,7 +271,7 @@
<string>Tab 2</string>
</attribute>
<layout class="QGridLayout" name="gridLayout_7" >
<item row="0" column="0" >
<item rowspan="2" row="0" column="0" >
<widget class="QGroupBox" name="groupBox_3" >
<property name="title" >
<string>Caps</string>
@ -314,6 +314,19 @@
</property>
</widget>
</item>
<item row="3" column="0" >
<spacer name="verticalSpacer_4" >
<property name="orientation" >
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0" >
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
</item>
@ -430,58 +443,6 @@ otherwise it will remain active</string>
</property>
</widget>
</item>
<item>
<spacer name="verticalSpacer_4" >
<property name="orientation" >
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0" >
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
</item>
<item row="1" column="0" >
<widget class="QGroupBox" name="groupBox" >
<property name="title" >
<string>Animate Desktop Change</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_2" >
<item>
<widget class="QCheckBox" name="animateDesktopChangeBox" >
<property name="toolTip" >
<string/>
</property>
<property name="text" >
<string>Display the cube when switching desktops</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="dontSlidePanelsBox" >
<property name="enabled" >
<bool>false</bool>
</property>
<property name="text" >
<string>Do not animate panels</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="dontSlideStickyWindowsBox" >
<property name="enabled" >
<bool>false</bool>
</property>
<property name="text" >
<string>Do not animate windows on all desktops</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
@ -528,9 +489,6 @@ otherwise it will remain active</string>
<tabstop>walkThroughDesktopBox</tabstop>
<tabstop>invertKeysBox</tabstop>
<tabstop>invertMouseBox</tabstop>
<tabstop>animateDesktopChangeBox</tabstop>
<tabstop>dontSlidePanelsBox</tabstop>
<tabstop>dontSlideStickyWindowsBox</tabstop>
<tabstop>zPositionSlider</tabstop>
</tabstops>
<resources/>
@ -567,37 +525,5 @@ otherwise it will remain active</string>
</hint>
</hints>
</connection>
<connection>
<sender>animateDesktopChangeBox</sender>
<signal>toggled(bool)</signal>
<receiver>dontSlidePanelsBox</receiver>
<slot>setEnabled(bool)</slot>
<hints>
<hint type="sourcelabel" >
<x>147</x>
<y>209</y>
</hint>
<hint type="destinationlabel" >
<x>147</x>
<y>232</y>
</hint>
</hints>
</connection>
<connection>
<sender>animateDesktopChangeBox</sender>
<signal>toggled(bool)</signal>
<receiver>dontSlideStickyWindowsBox</receiver>
<slot>setEnabled(bool)</slot>
<hints>
<hint type="sourcelabel" >
<x>53</x>
<y>209</y>
</hint>
<hint type="destinationlabel" >
<x>27</x>
<y>261</y>
</hint>
</hints>
</connection>
</connections>
</ui>

323
effects/cube/cubeslide.cpp Normal file
View file

@ -0,0 +1,323 @@
/********************************************************************
KWin - the KDE window manager
This file is part of the KDE project.
Copyright (C) 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
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*********************************************************************/
#include "cubeslide.h"
#include <kwinconfig.h>
#include <kconfiggroup.h>
#include <math.h>
#include <GL/gl.h>
namespace KWin
{
KWIN_EFFECT( cubeslide, CubeSlideEffect )
KWIN_EFFECT_SUPPORTED( cubeslide, CubeSlideEffect::supported() )
CubeSlideEffect::CubeSlideEffect()
{
reconfigure( ReconfigureAll );
}
CubeSlideEffect::~CubeSlideEffect()
{
}
bool CubeSlideEffect::supported()
{
return effects->compositingType() == OpenGLCompositing;
}
void CubeSlideEffect::reconfigure( ReconfigureFlags )
{
KConfigGroup conf = effects->effectConfig( "CubeSlide" );
int rotationDuration = animationTime( conf, "RotationDuration", 500 );
timeLine.setCurveShape( TimeLine::EaseInOutCurve );
timeLine.setDuration( rotationDuration );
dontSlidePanels = conf.readEntry( "DontSlidePanels", true );
dontSlideStickyWindows = conf.readEntry( "DontSlideStickyWindows", true );
}
void CubeSlideEffect::prePaintScreen( ScreenPrePaintData& data, int time)
{
if( !slideRotations.empty() )
{
data.mask |= PAINT_SCREEN_TRANSFORMED | Effect::PAINT_SCREEN_WITH_TRANSFORMED_WINDOWS | PAINT_SCREEN_BACKGROUND_FIRST;
timeLine.addTime( time );
if( dontSlidePanels )
panels.clear();
if( dontSlideStickyWindows )
stickyWindows.clear();
}
effects->prePaintScreen( data, time );
}
void CubeSlideEffect::paintScreen( int mask, QRegion region, ScreenPaintData& data)
{
if( !slideRotations.empty() )
{
glPushMatrix();
glNewList( glList, GL_COMPILE );
paintSlideCube( mask, region, data );
glEndList();
glPopMatrix();
glPushAttrib( GL_CURRENT_BIT | GL_ENABLE_BIT );
glEnable( GL_CULL_FACE );
glCullFace( GL_BACK );
glPushMatrix();
glCallList( glList );
glPopMatrix();
glCullFace( GL_FRONT );
glPushMatrix();
glCallList( glList );
glPopMatrix();
glDisable( GL_CULL_FACE );
glPopAttrib();
if( dontSlidePanels )
{
foreach( EffectWindow* w, panels )
{
WindowPaintData wData( w );
effects->paintWindow( w, 0, QRegion( w->x(), w->y(), w->width(), w->height() ), wData );
}
}
if( dontSlideStickyWindows )
{
foreach( EffectWindow* w, stickyWindows )
{
WindowPaintData wData( w );
effects->paintWindow( w, 0, QRegion( w->x(), w->y(), w->width(), w->height() ), wData );
}
}
}
else
effects->paintScreen( mask, region, data );
}
void CubeSlideEffect::paintSlideCube(int mask, QRegion region, ScreenPaintData& data)
{
// slide cube only paints to desktops at a time
// first the horizontal rotations followed by vertical rotations
QRect rect = effects->clientArea( FullArea, effects->activeScreen(), effects->currentDesktop() );
float point = rect.width()/2*tan(45.0f*M_PI/180.0f);
cube_painting = true;
painting_desktop = front_desktop;
ScreenPaintData firstFaceData = data;
ScreenPaintData secondFaceData = data;
RotationData firstFaceRot = RotationData();
RotationData secondFaceRot = RotationData();
RotationDirection direction = slideRotations.head();
int secondDesktop;
switch ( direction )
{
case Left:
firstFaceRot.axis = RotationData::YAxis;
secondFaceRot.axis = RotationData::YAxis;
secondDesktop = effects->desktopToLeft( front_desktop, true );
firstFaceRot.angle = 90.0f*timeLine.value();
secondFaceRot.angle = -90.0f*(1.0f - timeLine.value());
break;
case Right:
firstFaceRot.axis = RotationData::YAxis;
secondFaceRot.axis = RotationData::YAxis;
secondDesktop = effects->desktopToRight( front_desktop, true );
firstFaceRot.angle = -90.0f*timeLine.value();
secondFaceRot.angle = 90.0f*(1.0f - timeLine.value());
break;
case Upwards:
firstFaceRot.axis = RotationData::XAxis;
secondFaceRot.axis = RotationData::XAxis;
secondDesktop = effects->desktopUp( front_desktop, true);
firstFaceRot.angle = -90.0f*timeLine.value();
secondFaceRot.angle = 90.0f*(1.0f - timeLine.value());
point = rect.height()/2*tan(45.0f*M_PI/180.0f);
break;
case Downwards:
firstFaceRot.axis = RotationData::XAxis;
secondFaceRot.axis = RotationData::XAxis;
secondDesktop = effects->desktopDown( front_desktop, true );
firstFaceRot.angle = 90.0f*timeLine.value();
secondFaceRot.angle = -90.0f*(1.0f - timeLine.value());
point = rect.height()/2*tan(45.0f*M_PI/180.0f);
break;
default:
// totally impossible
return;
}
// front desktop
firstFaceRot.xRotationPoint = rect.width()/2;
firstFaceRot.yRotationPoint = rect.height()/2;
firstFaceRot.zRotationPoint = -point;
firstFaceData.rotation = &firstFaceRot;
effects->paintScreen( mask, region, firstFaceData );
// second desktop
painting_desktop = secondDesktop;
secondFaceRot.xRotationPoint = rect.width()/2;
secondFaceRot.yRotationPoint = rect.height()/2;
secondFaceRot.zRotationPoint = -point;
secondFaceData.rotation = &secondFaceRot;
effects->paintScreen( mask, region, secondFaceData );
cube_painting = false;
painting_desktop = effects->currentDesktop();
}
void CubeSlideEffect::prePaintWindow( EffectWindow* w, WindowPrePaintData& data, int time)
{
if( !slideRotations.empty() && cube_painting )
{
if( dontSlidePanels && w->isDock())
{
panels.insert( w );
}
if( dontSlideStickyWindows && !w->isDock() &&
!w->isDesktop() && w->isOnAllDesktops())
{
stickyWindows.insert( w );
}
if( w->isOnDesktop( painting_desktop ) )
w->enablePainting( EffectWindow::PAINT_DISABLED_BY_DESKTOP );
else
w->disablePainting( EffectWindow::PAINT_DISABLED_BY_DESKTOP );
}
effects->prePaintWindow( w, data, time );
}
void CubeSlideEffect::paintWindow( EffectWindow* w, int mask, QRegion region, WindowPaintData& data)
{
if( !slideRotations.empty() && cube_painting )
{
if( dontSlidePanels && w->isDock() )
return;
if( dontSlideStickyWindows &&
w->isOnAllDesktops() && !w->isDock() && !w->isDesktop() )
return;
}
effects->paintWindow( w, mask, region, data );
}
void CubeSlideEffect::postPaintScreen()
{
effects->postPaintScreen();
if( !slideRotations.empty() )
{
if( timeLine.value() == 1.0 )
{
RotationDirection direction = slideRotations.dequeue();
switch (direction)
{
case Left:
front_desktop = effects->desktopToLeft( front_desktop, true );
break;
case Right:
front_desktop = effects->desktopToRight( front_desktop, true );
break;
case Upwards:
front_desktop = effects->desktopUp( front_desktop, true );
break;
case Downwards:
front_desktop = effects->desktopDown( front_desktop, true );
break;
}
timeLine.setProgress( 0.0 );
if( slideRotations.empty() )
{
effects->setActiveFullScreenEffect( 0 );
glDeleteLists( glList, 1 );
}
}
effects->addRepaintFull();
}
}
void CubeSlideEffect::desktopChanged( int old )
{
if( effects->activeFullScreenEffect() && effects->activeFullScreenEffect() != this )
return;
bool activate = true;
if( !slideRotations.empty() )
{
// last slide still in progress
activate = false;
old = front_desktop;
RotationDirection direction = slideRotations.dequeue();
slideRotations.clear();
slideRotations.enqueue( direction );
}
// calculate distance in respect to pager
int x, y;
Qt::Orientation orientation;
effects->calcDesktopLayout( &x, &y, &orientation );
int x_distance = (( effects->currentDesktop() - 1 ) % x ) - (( old - 1 ) % x );
if( qAbs( x_distance ) > x/2 )
{
int sign = -1 * (x_distance/qAbs( x_distance ));
x_distance = sign * ( x - qAbs( x_distance ));
}
if( x_distance > 0 )
{
for( int i=0; i<x_distance; i++ )
{
slideRotations.enqueue( Right );
}
}
else if( x_distance < 0 )
{
x_distance *= -1;
for( int i=0; i<x_distance; i++ )
{
slideRotations.enqueue( Left );
}
}
int y_distance = (( effects->currentDesktop() -1 ) / x ) - (( old - 1 ) / x );
if( qAbs( y_distance ) > y/2 )
{
int sign = -1 * (y_distance/qAbs( y_distance ));
y_distance = sign * ( y - qAbs( y_distance ));
}
if( y_distance > 0 )
{
for( int i=0; i<y_distance; i++ )
{
slideRotations.enqueue( Downwards );
}
}
if( y_distance < 0 )
{
y_distance *= -1;
for( int i=0; i<y_distance; i++ )
{
slideRotations.enqueue( Upwards );
}
}
if( activate )
{
effects->setActiveFullScreenEffect( this );
glList = glGenLists( 1 );
timeLine.setProgress( 0.0 );
front_desktop = old;
effects->addRepaintFull();
}
}
} // namespace

View file

@ -0,0 +1,17 @@
[Desktop Entry]
Name=Desktop Cube Animation
Icon=preferences-system-windows-effect-cube
Comment=Animate desktop switching with a cube
Type=Service
X-KDE-ServiceTypes=KWin/Effect
X-KDE-PluginInfo-Author=Martin Gräßlin
X-KDE-PluginInfo-Email=kde@martin-graesslin.com
X-KDE-PluginInfo-Name=kwin4_effect_cubeslide
X-KDE-PluginInfo-Version=0.1.0
X-KDE-PluginInfo-Category=Window Management
X-KDE-PluginInfo-Depends=
X-KDE-PluginInfo-License=GPL
X-KDE-PluginInfo-EnabledByDefault=false
X-KDE-Library=kwin4_effect_builtins
X-KDE-Ordering=50

68
effects/cube/cubeslide.h Normal file
View file

@ -0,0 +1,68 @@
/********************************************************************
KWin - the KDE window manager
This file is part of the KDE project.
Copyright (C) 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
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*********************************************************************/
#ifndef KWIN_CUBESLIDE_H
#define KWIN_CUBESLIDE_H
#include <kwineffects.h>
#include <kwinglutils.h>
#include <QQueue>
#include <QSet>
namespace KWin
{
class CubeSlideEffect
: public Effect
{
public:
CubeSlideEffect();
~CubeSlideEffect();
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 prePaintWindow( EffectWindow* w, WindowPrePaintData& data, int time );
virtual void paintWindow( EffectWindow* w, int mask, QRegion region, WindowPaintData& data );
virtual void desktopChanged( int old );
static bool supported();
private:
enum RotationDirection
{
Left,
Right,
Upwards,
Downwards
};
void paintSlideCube( int mask, QRegion region, ScreenPaintData& data );
bool cube_painting;
int front_desktop;
int painting_desktop;
TimeLine timeLine;
QQueue<RotationDirection> slideRotations;
QSet<EffectWindow*> panels;
QSet<EffectWindow*> stickyWindows;
bool dontSlidePanels;
bool dontSlideStickyWindows;
GLuint glList;
};
}
#endif

View file

@ -0,0 +1,94 @@
/********************************************************************
KWin - the KDE window manager
This file is part of the KDE project.
Copyright (C) 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
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*********************************************************************/
#include "cubeslide_config.h"
#include <kwineffects.h>
#include <kconfiggroup.h>
#include <QVBoxLayout>
#include <QColor>
namespace KWin
{
KWIN_EFFECT_CONFIG_FACTORY
CubeSlideEffectConfigForm::CubeSlideEffectConfigForm(QWidget* parent) : QWidget(parent)
{
setupUi(this);
}
CubeSlideEffectConfig::CubeSlideEffectConfig(QWidget* parent, const QVariantList& args) :
KCModule(EffectFactory::componentData(), parent, args)
{
m_ui = new CubeSlideEffectConfigForm(this);
QVBoxLayout* layout = new QVBoxLayout(this);
layout->addWidget(m_ui);
connect(m_ui->rotationDurationSpin, SIGNAL(valueChanged(int)), this, SLOT(changed()));
connect(m_ui->dontSlidePanelsBox, SIGNAL(stateChanged(int)), this, SLOT(changed()));
connect(m_ui->dontSlideStickyWindowsBox, SIGNAL(stateChanged(int)), this, SLOT(changed()));
load();
}
void CubeSlideEffectConfig::load()
{
KCModule::load();
KConfigGroup conf = EffectsHandler::effectConfig( "CubeSlide" );
int duration = conf.readEntry( "RotationDuration", 0 );
bool dontSlidePanels = conf.readEntry( "DontSlidePanels", true );
bool dontSlideStickyWindows = conf.readEntry( "DontSlideStickyWindows", true );
m_ui->rotationDurationSpin->setValue( duration );
m_ui->dontSlidePanelsBox->setChecked( dontSlidePanels );
m_ui->dontSlideStickyWindowsBox->setChecked( dontSlideStickyWindows );
emit changed(false);
}
void CubeSlideEffectConfig::save()
{
KConfigGroup conf = EffectsHandler::effectConfig( "CubeSlide" );
conf.writeEntry( "RotationDuration", m_ui->rotationDurationSpin->value() );
conf.writeEntry( "DontSlidePanels", m_ui->dontSlidePanelsBox->isChecked() );
conf.writeEntry( "DontSlideStickyWindows", m_ui->dontSlideStickyWindowsBox->isChecked() );
conf.sync();
emit changed(false);
EffectsHandler::sendReloadMessage( "cubeslide" );
}
void CubeSlideEffectConfig::defaults()
{
m_ui->rotationDurationSpin->setValue( 0 );
m_ui->dontSlidePanelsBox->setChecked( true );
m_ui->dontSlideStickyWindowsBox->setChecked( true );
emit changed(true);
}
} // namespace
#include "cubeslide_config.moc"

View file

@ -0,0 +1,9 @@
[Desktop Entry]
Type=Service
X-KDE-ServiceTypes=KCModule
X-KDE-Library=kcm_kwin4_effect_builtins
X-KDE-ParentComponents=kwin4_effect_cubeslide
X-KDE-PluginKeyword=cubeslide
Name=Desktop Cube Animation

View file

@ -0,0 +1,56 @@
/********************************************************************
KWin - the KDE window manager
This file is part of the KDE project.
Copyright (C) 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
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*********************************************************************/
#ifndef KWIN_CUBESLIDE_CONFIG_H
#define KWIN_CUBESLIDE_CONFIG_H
#include <kcmodule.h>
#include "ui_cubeslide_config.h"
class KFileDialog;
namespace KWin
{
class CubeSlideEffectConfigForm : public QWidget, public Ui::CubeSlideEffectConfigForm
{
Q_OBJECT
public:
explicit CubeSlideEffectConfigForm(QWidget* parent);
};
class CubeSlideEffectConfig : public KCModule
{
Q_OBJECT
public:
explicit CubeSlideEffectConfig(QWidget* parent = 0, const QVariantList& args = QVariantList());
public slots:
virtual void save();
virtual void load();
virtual void defaults();
private:
CubeSlideEffectConfigForm* m_ui;
};
} // namespace
#endif

View file

@ -0,0 +1,97 @@
<ui version="4.0" >
<class>KWin::CubeSlideEffectConfigForm</class>
<widget class="QWidget" name="KWin::CubeSlideEffectConfigForm" >
<property name="geometry" >
<rect>
<x>0</x>
<y>0</y>
<width>342</width>
<height>126</height>
</rect>
</property>
<layout class="QGridLayout" name="gridLayout" >
<item row="0" column="1" >
<widget class="QSpinBox" name="rotationDurationSpin" >
<property name="sizePolicy" >
<sizepolicy vsizetype="Fixed" hsizetype="Expanding" >
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize" >
<size>
<width>100</width>
<height>0</height>
</size>
</property>
<property name="specialValueText" >
<string comment="Duration of rotation" >Default</string>
</property>
<property name="suffix" >
<string> msec</string>
</property>
<property name="maximum" >
<number>5000</number>
</property>
<property name="singleStep" >
<number>10</number>
</property>
</widget>
</item>
<item row="1" column="0" colspan="2" >
<widget class="QCheckBox" name="dontSlidePanelsBox" >
<property name="text" >
<string>Do not animate panels</string>
</property>
</widget>
</item>
<item row="2" column="0" colspan="2" >
<widget class="QCheckBox" name="dontSlideStickyWindowsBox" >
<property name="text" >
<string>Do not animate windows on all desktops</string>
</property>
</widget>
</item>
<item row="3" column="0" >
<spacer name="verticalSpacer" >
<property name="orientation" >
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0" >
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
<item row="0" column="0" >
<widget class="QLabel" name="label" >
<property name="text" >
<string>Rotation duration:</string>
</property>
<property name="alignment" >
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
<property name="buddy" >
<cstring>rotationDurationSpin</cstring>
</property>
</widget>
</item>
</layout>
<zorder>tabWidget</zorder>
<zorder>groupBox</zorder>
<zorder>dontSlideStickyWindowsBox</zorder>
<zorder>verticalSpacer</zorder>
<zorder>rotationDurationSpin</zorder>
<zorder>dontSlidePanelsBox</zorder>
<zorder>label</zorder>
</widget>
<tabstops>
<tabstop>rotationDurationSpin</tabstop>
<tabstop>dontSlidePanelsBox</tabstop>
<tabstop>dontSlideStickyWindowsBox</tabstop>
</tabstops>
<resources/>
<connections/>
</ui>

View file

@ -82,7 +82,7 @@ bool CylinderEffect::loadData()
mShader->setUniform( "winTexture", 0 );
mShader->setUniform( "opacity", cubeOpacity );
QRect rect = effects->clientArea( FullScreenArea, activeScreen, effects->currentDesktop());
if( effects->numScreens() > 1 && (slide || bigCube ) )
if( effects->numScreens() > 1 && bigCube )
rect = effects->clientArea( FullArea, activeScreen, effects->currentDesktop() );
mShader->setUniform( "width", (float)rect.width() );
mShader->unbind();

View file

@ -82,7 +82,7 @@ bool SphereEffect::loadData()
mShader->setUniform( "winTexture", 0 );
mShader->setUniform( "opacity", cubeOpacity );
QRect rect = effects->clientArea( FullScreenArea, activeScreen, effects->currentDesktop());
if( effects->numScreens() > 1 && (slide || bigCube ) )
if( effects->numScreens() > 1 && bigCube )
rect = effects->clientArea( FullArea, activeScreen, effects->currentDesktop() );
mShader->setUniform( "width", (float)rect.width() );
mShader->setUniform( "height", (float)rect.height() );

View file

@ -181,7 +181,7 @@ KWinCompositingConfig::KWinCompositingConfig(QWidget *parent, const QVariantList
services = trader->query("KWin/Effect", "[X-KDE-PluginInfo-Name] == 'kwin4_effect_slide'");
if( !services.isEmpty() )
slide = services.first()->name();
services = trader->query("KWin/Effect", "[X-KDE-PluginInfo-Name] == 'kwin4_effect_cube'");
services = trader->query("KWin/Effect", "[X-KDE-PluginInfo-Name] == 'kwin4_effect_cubeslide'");
if( !services.isEmpty() )
cube = services.first()->name();
services = trader->query("KWin/Effect", "[X-KDE-PluginInfo-Name] == 'kwin4_effect_fadedesktop'");
@ -339,8 +339,7 @@ void KWinCompositingConfig::loadGeneralTab()
ui.desktopSwitchingCombo->setCurrentIndex( 0 );
if( effectEnabled( "slide", effectconfig ))
ui.desktopSwitchingCombo->setCurrentIndex( 1 );
KConfigGroup cubeconfig(mKWinConfig, "Effect-Cube");
if( effectEnabled( "cube", effectconfig ) && cubeconfig.readEntry("AnimateDesktopChange", false))
if( effectEnabled( "cubeslide", effectconfig ))
ui.desktopSwitchingCombo->setCurrentIndex( 2 );
if( effectEnabled( "fadedesktop", effectconfig ))
ui.desktopSwitchingCombo->setCurrentIndex( 3 );
@ -472,34 +471,33 @@ void KWinCompositingConfig::saveGeneralTab()
presentwindowsconfig.writeEntry("TabBox", presentWindowSwitching);
int desktopSwitcher = ui.desktopSwitchingCombo->currentIndex();
bool cubeDesktopSwitching = false;
switch( desktopSwitcher )
{
case 0:
// no effect
effectconfig.writeEntry("kwin4_effect_slideEnabled", false);
effectconfig.writeEntry("kwin4_effect_cubeslideEnabled", false);
effectconfig.writeEntry("kwin4_effect_fadedesktopEnabled", false);
break;
case 1:
// slide
effectconfig.writeEntry("kwin4_effect_slideEnabled", true);
effectconfig.writeEntry("kwin4_effect_cubeslideEnabled", false);
effectconfig.writeEntry("kwin4_effect_fadedesktopEnabled", false);
break;
case 2:
// cube
cubeDesktopSwitching = true;
effectconfig.writeEntry("kwin4_effect_slideEnabled", false);
effectconfig.writeEntry("kwin4_effect_cubeEnabled", true);
effectconfig.writeEntry("kwin4_effect_cubeslideEnabled", true);
effectconfig.writeEntry("kwin4_effect_fadedesktopEnabled", false);
break;
case 3:
// fadedesktop
effectconfig.writeEntry("kwin4_effect_slideEnabled", false);
effectconfig.writeEntry("kwin4_effect_cubeslideEnabled", false);
effectconfig.writeEntry("kwin4_effect_fadedesktopEnabled", true);
break;
}
KConfigGroup cubeconfig(mKWinConfig, "Effect-Cube");
cubeconfig.writeEntry("AnimateDesktopChange", cubeDesktopSwitching);
}
void KWinCompositingConfig::saveEffectsTab()