Removing Snow Effect.

The usefulness of the snow effect is doubtable and it is rather
difficult to port the effect to the new rendering architecture
introduced with GLES. It is probably easier to rewrite the complete
effect from scratch, therefore it is removed for now.

I might consider readding it for 4.7.

This kind of "fixes" snow related bug reports.
BUG: 259362
BUG: 254498
FIXED-IN: 4.7.0
This commit is contained in:
Martin Gräßlin 2011-01-29 14:57:05 +01:00
parent 19f6b9667b
commit 65e6a1b03b
13 changed files with 0 additions and 1333 deletions

View file

@ -106,9 +106,6 @@ if( KWIN_HAVE_OPENGL_COMPOSITING )
include( trackmouse/CMakeLists.txt )
include( wobblywindows/CMakeLists.txt )
endif( KWIN_HAVE_OPENGL_COMPOSITING )
if( KWIN_HAVE_OPENGL_COMPOSITING AND NOT KWIN_HAVE_OPENGLES_COMPOSITING )
include( snow/CMakeLists.txt )
endif( KWIN_HAVE_OPENGL_COMPOSITING AND NOT KWIN_HAVE_OPENGLES_COMPOSITING )
###############################################################################

View file

@ -51,9 +51,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include "mousemark/mousemark_config.h"
#include "trackmouse/trackmouse_config.h"
#include "wobblywindows/wobblywindows_config.h"
#ifndef KWIN_HAVE_OPENGLES
#include "snow/snow_config.h"
#endif
#endif
#include <kwineffects.h>
@ -92,9 +89,6 @@ KWIN_EFFECT_CONFIG_MULTIPLE( builtins,
KWIN_EFFECT_CONFIG_SINGLE( mousemark, MouseMarkEffectConfig )
KWIN_EFFECT_CONFIG_SINGLE( trackmouse, TrackMouseEffectConfig )
KWIN_EFFECT_CONFIG_SINGLE( wobblywindows, WobblyWindowsEffectConfig )
#ifndef KWIN_HAVE_OPENGLES
KWIN_EFFECT_CONFIG_SINGLE( snow, SnowEffectConfig )
#endif
#endif
)

View file

@ -1,33 +0,0 @@
#######################################
# Effect
# Source files
set( kwin4_effect_builtins_sources ${kwin4_effect_builtins_sources}
snow/snow.cpp
)
# .desktop files
install( FILES
snow/snow.desktop
DESTINATION ${SERVICES_INSTALL_DIR}/kwin )
# Data files
install( FILES
snow/data/snow.frag
snow/data/snow.vert
snow/data/snowflake.png
DESTINATION ${DATA_INSTALL_DIR}/kwin )
#######################################
# Config
# Source files
set( kwin4_effect_builtins_config_sources ${kwin4_effect_builtins_config_sources}
snow/snow_config.cpp
snow/snow_config.ui
)
# .desktop files
install( FILES
snow/snow_config.desktop
DESTINATION ${SERVICES_INSTALL_DIR}/kwin )

View file

@ -1,33 +0,0 @@
/********************************************************************
KWin - the KDE window manager
This file is part of the KDE project.
Copyright (C) 2008 Martin Gräßlin <ubuntu@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/>.
*********************************************************************/
uniform sampler2D snowTexture;
uniform int left;
uniform int right;
uniform int top;
uniform int bottom;
void main()
{
gl_FragColor = texture2D( snowTexture, gl_TexCoord[0].st );
// manual clipping
if( gl_FragCoord.x < float( left ) || gl_FragCoord.x > float( right )
|| gl_FragCoord.y < float( top ) || gl_FragCoord.y > float( bottom ) )
discard;
}

View file

@ -1,47 +0,0 @@
/********************************************************************
KWin - the KDE window manager
This file is part of the KDE project.
Copyright (C) 2008 Martin Gräßlin <ubuntu@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/>.
*********************************************************************/
uniform float angle;
uniform int x;
uniform int width;
uniform int height;
varying float discarding;
uniform int hSpeed;
uniform int vSpeed;
uniform int frames;
void main()
{
gl_TexCoord[0] = gl_MultiTexCoord0;
float radian = radians( angle*float(frames) );
mat2 rotation = mat2( cos(radian), sin(radian), -sin(radian), cos(radian) );
float xCoord;
float yCoord;
if( gl_MultiTexCoord0.s == 0.0 )
xCoord = -float(width)*0.5;
else
xCoord = float(width)*0.5;
if( gl_MultiTexCoord0.t == 0.0 )
yCoord = -float(height)*0.5;
else
yCoord = float(height)*0.5;
vec2 vertex = vec2( xCoord, yCoord );
vertex = (vertex)*rotation + vec2( float(x), float(-height) ) + vec2(hSpeed, vSpeed)*float(frames);
gl_Position = gl_ModelViewProjectionMatrix * vec4(vertex, gl_Vertex.zw);
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.7 KiB

View file

@ -1,450 +0,0 @@
/********************************************************************
KWin - the KDE window manager
This file is part of the KDE project.
Copyright (C) 2007 Martin Gräßlin <ubuntu@martin-graesslin.com>
Copyright (C) 2008 Torgny Johansson <torgny.johansson@gmail.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 "snow.h"
#include <kwinconfig.h>
#include <kaction.h>
#include <kactioncollection.h>
#include <kconfiggroup.h>
#include <kglobal.h>
#include <klocale.h>
#include <kstandarddirs.h>
#include <kdebug.h>
#include <ctime>
#ifdef KWIN_HAVE_OPENGL_COMPOSITING
#include <GL/gl.h>
#endif
namespace KWin
{
KWIN_EFFECT( snow, SnowEffect )
KWIN_EFFECT_SUPPORTED( snow, SnowEffect::supported() )
SnowEffect::SnowEffect()
: texture( NULL )
, active( false)
, snowBehindWindows( false )
, mShader( 0 )
, mInited( false )
, mUseShader( true )
, hasSnown( false )
{
srandom( std::time( NULL ) );
nextFlakeMillis = 0;
KActionCollection* actionCollection = new KActionCollection( this );
KAction* a = static_cast< KAction* >( actionCollection->addAction( "Snow" ));
a->setText( i18n("Snow" ));
a->setGlobalShortcut( KShortcut( Qt::CTRL + Qt::META + Qt::Key_F12 ));
connect( a, SIGNAL( triggered( bool )), this, SLOT( toggle()));
reconfigure( ReconfigureAll );
}
SnowEffect::~SnowEffect()
{
delete texture;
if( active )
delete mShader;
}
bool SnowEffect::supported()
{
return effects->compositingType() == OpenGLCompositing;
}
void SnowEffect::reconfigure( ReconfigureFlags )
{
KConfigGroup conf = effects->effectConfig("Snow");
mNumberFlakes = conf.readEntry("Number", 200);
mMinFlakeSize = conf.readEntry("MinFlakes", 10);
mMaxFlakeSize = conf.readEntry("MaxFlakes", 50);
mMaxVSpeed = conf.readEntry("MaxVSpeed", 2);
mMaxHSpeed = conf.readEntry("MaxHSpeed", 1);
snowBehindWindows = conf.readEntry("BehindWindows", true);
}
void SnowEffect::prePaintScreen( ScreenPrePaintData& data, int time )
{
if ( active )
{
// if number of active snowflakes is smaller than maximum number
// create a random new snowflake
nextFlakeMillis -= time;
if ( ( nextFlakeMillis <= 0 ) && flakes.count() < mNumberFlakes)
{
int size = 0;
while ( size < mMinFlakeSize )
size = random() % mMaxFlakeSize;
SnowFlake flake = SnowFlake( random() % (displayWidth() - size), -size, size, size, mMaxVSpeed, mMaxHSpeed );
flakes.append( flake );
// calculation of next time of snowflake
// depends on the time the flow needs to get to the bottom (screen size)
// and the fps
long next = ((500/(time+5))*(Effect::displayHeight()/flake.getVSpeed()))/mNumberFlakes;
nextFlakeMillis = next;
}
data.mask |= PAINT_SCREEN_TRANSFORMED;
hasSnown = false;
}
effects->prePaintScreen( data, time );
}
void SnowEffect::paintScreen( int mask, QRegion region, ScreenPaintData& data )
{
if( active && snowBehindWindows )
repaintRegion = QRegion( 0, 0, displayWidth(), displayHeight() );
effects->paintScreen( mask, region, data ); // paint normal screen
if( active && !snowBehindWindows )
snowing( region );
}
void SnowEffect::snowing( QRegion& region )
{
if(! texture ) loadTexture();
if( texture )
{
glActiveTexture(GL_TEXTURE0);
texture->bind();
if( mUseShader && !mInited )
mUseShader = loadShader();
glPushAttrib( GL_CURRENT_BIT | GL_ENABLE_BIT );
glEnable( GL_BLEND );
glBlendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA );
if( mUseShader )
{
mShader->bind();
QRect rect = region.boundingRect();
mShader->setUniform( "left", rect.x() );
mShader->setUniform( "right", rect.x() + rect.width() );
mShader->setUniform( "top", rect.y() );
mShader->setUniform( "bottom", rect.y() + rect.height() );
}
for (int i=0; i<flakes.count(); i++)
{
SnowFlake& flake = flakes[i];
if( !hasSnown )
{
// only update during first paint in one frame
if( flake.addFrame() == 0 )
{
flakes.removeAt( i-- );
continue;
}
}
if( mUseShader )
{
// use shader
mShader->setUniform( "angle", flake.getRotationSpeed() );
mShader->setUniform( "x", flake.getX() );
mShader->setUniform( "hSpeed", flake.getHSpeed() );
mShader->setUniform( "vSpeed", flake.getVSpeed() );
mShader->setUniform( "frames", flake.getFrames() );
mShader->setUniform( "width", flake.getWidth() );
mShader->setUniform( "height", flake.getHeight() );
glCallList( list );
}
else
{
if( !hasSnown )
{
// only update during first paint in one frame
flake.updateSpeedAndRotation();
}
// no shader
// save the matrix
glPushMatrix();
// translate to the center of the flake
glTranslatef(flake.getWidth()/2 + flake.getX(), flake.getHeight()/2 + flake.getY(), 0);
// rotate around the Z-axis
glRotatef(flake.getRotationAngle(), 0.0, 0.0, 1.0);
// translate back to the starting point
glTranslatef(-flake.getWidth()/2 - flake.getX(), -flake.getHeight()/2 - flake.getY(), 0);
// paint the snowflake
texture->render( region, flake.getRect());
// restore the matrix
glPopMatrix();
}
}
if( mUseShader )
{
mShader->unbind();
}
glDisable( GL_BLEND );
texture->unbind();
glPopAttrib();
hasSnown = true;
}
}
void SnowEffect::postPaintScreen()
{
if( active )
{
if( snowBehindWindows )
effects->addRepaint( repaintRegion );
else
effects->addRepaintFull();
}
effects->postPaintScreen();
}
void SnowEffect::paintWindow( EffectWindow* w, int mask, QRegion region, WindowPaintData& data )
{
if( active && snowBehindWindows && !w->isDesktop() && !w->isDock() && !w->hasAlpha() && data.opacity == 1.0 )
{
repaintRegion -= QRegion( w->geometry() );
}
effects->paintWindow( w, mask, region, data );
if( active && w->isDesktop() && snowBehindWindows )
{
QRect rect = effects->clientArea( FullScreenArea, w->screen(), effects->currentDesktop());
QRegion snowRegion( rect.x() + data.xTranslate, rect.y() + data.yTranslate,
(double)rect.width()*data.xScale, (double)rect.height()*data.yScale);
if( mUseShader )
{
// have to adjust the y values to fit OpenGL
// in OpenGL y==0 is at bottom, in Qt at top
int y = 0;
if( effects->numScreens() > 1 )
{
QRect fullArea = effects->clientArea( FullArea, 0, 1 );
if( fullArea.height() != rect.height() )
{
if( rect.y() == 0 )
y = fullArea.height() - rect.height();
else
y = fullArea.height() - rect.y() - rect.height();
}
}
snowRegion = QRegion( rect.x() + data.xTranslate,
y + rect.height() - data.yTranslate - (double)rect.height()*data.yScale,
(double)rect.width()*data.xScale, (double)rect.height()*data.yScale);
}
glPushMatrix();
glTranslatef( rect.x() + data.xTranslate, rect.y() + data.yTranslate, 0.0 );
glScalef( data.xScale, data.yScale, 1.0 );
snowing( snowRegion );
glPopMatrix();
}
}
void SnowEffect::toggle()
{
#ifdef KWIN_HAVE_OPENGL_COMPOSITING
active = !active;
if( active )
{
list = glGenLists(1);
}
else
{
glDeleteLists( list, 1 );
flakes.clear();
if( mUseShader )
{
delete mShader;
mShader = NULL;
mInited = false;
mUseShader = true;
}
}
effects->addRepaintFull();
#endif
}
bool SnowEffect::loadShader()
{
mInited = true;
if( !(GLShader::fragmentShaderSupported() &&
(effects->compositingType() == OpenGLCompositing)) )
{
kDebug(1212) << "Shaders not supported - waisting CPU cycles" << endl;
return false;
}
QString fragmentshader = KGlobal::dirs()->findResource("data", "kwin/snow.frag");
QString vertexshader = KGlobal::dirs()->findResource("data", "kwin/snow.vert");
if(fragmentshader.isEmpty() || vertexshader.isEmpty())
{
kDebug(1212) << "Couldn't locate shader files" << endl;
return false;
}
mShader = new GLShader(vertexshader, fragmentshader);
if(!mShader->isValid())
{
kDebug(1212) << "The shader failed to load!" << endl;
return false;
}
else
{
mShader->bind();
mShader->setUniform( "snowTexture", 0 );
mShader->unbind();
}
kDebug(1212) << "using shader";
glNewList( list, GL_COMPILE );
glBegin( GL_QUADS );
glTexCoord2f( 0.0f, 0.0f );
glVertex2i( 0, 0 );
glTexCoord2f( 1.0f, 0.0f );
glVertex2i( 0, 0 );
glTexCoord2f( 1.0f, 1.0f );
glVertex2i( 0, 0 );
glTexCoord2f( 0.0f, 1.0f );
glVertex2i( 0, 0 );
glEnd();
glEndList();
return true;
}
void SnowEffect::loadTexture()
{
QString file = KGlobal::dirs()->findResource( "appdata", "snowflake.png" );
if( file.isEmpty())
return;
texture = new GLTexture( file );
}
// the snowflake class
SnowFlake::SnowFlake(int x, int y, int width, int height, int maxVSpeed, int maxHSpeed)
{
int minVSpeed = maxVSpeed - 8; // 8 gives a nice difference in speed
if(minVSpeed < 1) minVSpeed = 1;
vSpeed = random()%maxVSpeed + minVSpeed;
hSpeed = random()%(maxHSpeed+1);
if(random()%2 < 1) hSpeed = -hSpeed; // to create negative hSpeeds at random
rotationAngle = 0;
rotationSpeed = random()%4 - 2;
if(rotationSpeed == 0) rotationSpeed = 0.5;
rect = QRect(x, y, width, height);
frameCounter = 0;
maxFrames = (displayHeight() + 2*height) / vSpeed;
if( hSpeed > 0 )
maxFrames = qMin( maxFrames, (displayWidth() + width - x)/hSpeed );
else if( hSpeed < 0 )
maxFrames = qMin( maxFrames, (x + width)/(-hSpeed) );
}
SnowFlake::~SnowFlake()
{
}
int SnowFlake::getHSpeed()
{
return hSpeed;
}
QRect SnowFlake::getRect()
{
return rect;
}
void SnowFlake::updateSpeedAndRotation()
{
rotationAngle = rotationAngle+rotationSpeed;
rect.translate(hSpeed, vSpeed);
}
float SnowFlake::getRotationAngle()
{
return rotationAngle;
}
float SnowFlake::getRotationSpeed()
{
return rotationSpeed;
}
int SnowFlake::getVSpeed()
{
return vSpeed;
}
int SnowFlake::getHeight()
{
return rect.height();
}
int SnowFlake::getWidth()
{
return rect.width();
}
int SnowFlake::getX()
{
return rect.x();
}
int SnowFlake::getY()
{
return rect.y();
}
void SnowFlake::setHeight(int height)
{
rect.setHeight(height);
}
void SnowFlake::setWidth(int width)
{
rect.setWidth(width);
}
void SnowFlake::setX(int x)
{
rect.setX(x);
}
void SnowFlake::setY(int y)
{
rect.setY(y);
}
int SnowFlake::addFrame()
{
return ( maxFrames - (++frameCounter) );
}
int SnowFlake::getFrames()
{
return frameCounter;
}
} // namespace

View file

@ -1,171 +0,0 @@
[Desktop Entry]
# Name of the effect
Name=Snow
Name[af]=Sneeu
Name[ar]=الثلج
Name[ast]=Ñeve
Name[be@latin]=Śnieh
Name[bg]=Сняг
Name[bn]=
Name[bn_IN]=Snow ()
Name[ca]=Neu
Name[ca@valencia]=Neu
Name[cs]=Sníh
Name[csb]=Sniég
Name[da]=Sne
Name[de]=Schnee
Name[el]=Χιόνι
Name[en_GB]=Snow
Name[eo]=Neĝo
Name[es]=Nieve
Name[et]=Lumi
Name[eu]=Elurra
Name[fi]=Lumisade
Name[fr]=Neige
Name[fy]=Snie
Name[ga]=Sneachta
Name[gl]=Neve
Name[gu]=
Name[he]=שלג
Name[hi]=
Name[hne]=
Name[hr]=Snijeg
Name[hu]=Hóesés
Name[ia]=Nive
Name[id]=Salju
Name[is]=Snjór
Name[it]=Neve
Name[ja]=
Name[kk]=Қар
Name[km]=
Name[kn]=
Name[ko]=
Name[ku]=Berf
Name[lt]=Sniegas
Name[lv]=Sniegs
Name[mai]=
Name[mk]=Снег
Name[ml]=
Name[mr]=ि
Name[nb]=Snø
Name[nds]=Snee
Name[nl]=Sneeuw
Name[nn]=Snø
Name[oc]=Nèu
Name[pa]=
Name[pl]=Śnieg
Name[pt]=Neve
Name[pt_BR]=Neve
Name[ro]=Zăpadă
Name[ru]=Снег
Name[si]=
Name[sk]=Sneh
Name[sl]=Sneg
Name[sr]=Снег
Name[sr@ijekavian]=Снијег
Name[sr@ijekavianlatin]=Snijeg
Name[sr@latin]=Sneg
Name[sv]=Snö
Name[ta]=ி
Name[te]=
Name[tg]=Барф
Name[th]=
Name[tr]=Kar
Name[uk]=Сніг
Name[uz]=Qor
Name[uz@cyrillic]=Қор
Name[wa]=Nive
Name[x-test]=xxSnowxx
Name[zh_CN]=
Name[zh_TW]=
Comment=Simulate snow falling over the desktop
Comment[ar]=يحاكي سقوط الثلج على سطح المكتب
Comment[ast]=Simula una nevada nel escritoriu
Comment[be@latin]=Uklučaje śniehapad na rabočym stale.
Comment[bg]=Сняг върху работния плот
Comment[bn_IN]=
Comment[ca]=Simula que cau neu sobre l'escriptori
Comment[ca@valencia]=Simula que cau neu sobre l'escriptori
Comment[cs]=Simuluje sněžení na ploše
Comment[csb]=Symùlëjë padający sniég na pùlce
Comment[da]=Simulér snefald over skrivebordet
Comment[de]=Lässt Schnee auf Ihre Arbeitsfläche fallen.
Comment[el]=Εξομοίωση χιονιού στην επιφάνεια εργασίας
Comment[en_GB]=Simulate snow falling over the desktop
Comment[eo]=Neĝu sur la labortablo
Comment[es]=Simula una nevada en el escritorio
Comment[et]=Lumesadu töölaual
Comment[eu]=Egin mahaigainean elurra ari balu bezala
Comment[fi]=Näyttää lumisadetta työpöydällä
Comment[fr]=Simule de la neige qui tombe sur votre bureau
Comment[fy]=Lit it snije op it buroblêd
Comment[ga]=Insamhail sneachta ag titim ar an deasc
Comment[gl]=Simula unha nevarada no escritorio
Comment[gu]=
Comment[he]=מדמה נפילת שלג על שולחן העבודה
Comment[hi]= ि
Comment[hne]= ि
Comment[hr]=Simulira padanje snijega po radnoj površini
Comment[hu]=Hull a hó az asztalon
Comment[ia]=Il simula nive cadente su le scriptorio
Comment[id]=Simulasikan turunnya salju di atas desktop
Comment[is]=Líkja eftir snjókomu á skjáborð
Comment[it]=Simula una nevicata sul desktop
Comment[ja]=
Comment[kk]=Үстелде қар жабуын көрсету
Comment[km]=
Comment[kn]=ಿ ಿ
Comment[ko]=
Comment[lt]=Imituoja snigimą jūsų darbastalyje
Comment[lv]=Imitē sniegu uz darbvirsmas
Comment[mk]=Симулира паѓање снег на работната површина
Comment[ml]=ിിി
Comment[nb]=Vis snø som faller på skrivebordet
Comment[nds]=Op'n Schriefdisch dat Fallen vun Snee simuleren
Comment[nl]=Laat het op uw bureaublad sneeuwen
Comment[nn]=La det snø på skrivebordet
Comment[pa]= ਿ
Comment[pl]=Śnieg na pulpicie
Comment[pt]=Simular a queda de neve no ecrã
Comment[pt_BR]=Simula a queda de neve na área de trabalho
Comment[ro]=Simulează zăpada căzînd pe birou
Comment[ru]=Показывать падающий снег
Comment[si]=
Comment[sk]=Simuluje sneh padajúci na plochu
Comment[sl]=Simulira sneženje na zaslonu
Comment[sr]=Симулира падање снега на површи
Comment[sr@ijekavian]=Симулира падање снијега на површи
Comment[sr@ijekavianlatin]=Simulira padanje snijega na površi
Comment[sr@latin]=Simulira padanje snega na površi
Comment[sv]=Simulera snö som faller över skrivbordet
Comment[ta]=ி ி ி
Comment[th]=
Comment[tr]=Masaüstüne kar yağdır
Comment[uk]=Імітація завірюх на стільниці
Comment[x-test]=xxSimulate snow falling over the desktopxx
Comment[zh_CN]=
Comment[zh_TW]=
Icon=preferences-system-windows-effect-snow
# This is KWin effect
Type=Service
X-KDE-ServiceTypes=KWin/Effect
# Author and email of the author
X-KDE-PluginInfo-Author=Martin Gräßlin
X-KDE-PluginInfo-Email=ubuntu@martin-graesslin.com
# Internal name of the effect
X-KDE-PluginInfo-Name=kwin4_effect_snow
# Category of the effect, for config dialog
X-KDE-PluginInfo-Category=Candy
# Version and license
X-KDE-PluginInfo-Version=0.1.2
X-KDE-PluginInfo-License=GPL
# If the effect depends on any other effect(s) to be active, then internal
# names of those effects can be given here
X-KDE-PluginInfo-Depends=
# Whether this effect should be enabled by default
X-KDE-PluginInfo-EnabledByDefault=false
# The plugin (library) which contains the effect. One library may contain more effects.
X-KDE-Library=kwin4_effect_builtins
# The order in which this effect is loaded. Lower numbers are loaded first.
X-KDE-Ordering=90

View file

@ -1,107 +0,0 @@
/********************************************************************
KWin - the KDE window manager
This file is part of the KDE project.
Copyright (C) 2007 Martin Gräßlin <ubuntu@martin-graesslin.com>
Copyright (C) 2008 Torgny Johansson <torgny.johansson@gmail.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_SNOW_H
#define KWIN_SNOW_H
#include <kwineffects.h>
#include <kwinglutils.h>
#include <qobject.h>
#include <QList>
namespace KWin
{
class SnowFlake
{
public:
SnowFlake(int x, int y, int width, int height, int maxVSpeed, int maxHSpeed);
virtual ~SnowFlake();
int getHSpeed();
int getVSpeed();
float getRotationAngle();
float getRotationSpeed();
void updateSpeedAndRotation();
int addFrame();
int getHeight();
int getWidth();
int getX();
int getY();
int getFrames();
QRect getRect();
void setHeight(int height);
void setWidth(int width);
void setX(int x);
void setY(int y);
private:
QRect rect;
int vSpeed;
int hSpeed;
int frameCounter;
int maxFrames;
float rotationAngle;
float rotationSpeed;
};
class SnowEffect
: public QObject, public Effect
{
Q_OBJECT
public:
SnowEffect();
virtual ~SnowEffect();
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 );
static bool supported();
private slots:
void toggle();
private:
void loadTexture();
void snowing( QRegion& region );
bool loadShader();
GLTexture* texture;
QList<SnowFlake> flakes;
long nextFlakeMillis;
int mNumberFlakes;
int mMinFlakeSize;
int mMaxFlakeSize;
int mMaxVSpeed;
int mMaxHSpeed;
bool active;
GLuint list;
bool snowBehindWindows;
GLShader* mShader;
bool mInited;
bool mUseShader;
QRegion repaintRegion;
bool hasSnown;
};
} // namespace
#endif

View file

@ -1,138 +0,0 @@
/********************************************************************
KWin - the KDE window manager
This file is part of the KDE project.
Copyright (C) 2007 Martin Gräßlin <ubuntu@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 "snow_config.h"
#include <kwineffects.h>
#include <klocale.h>
#include <kdebug.h>
#include <KActionCollection>
#include <kaction.h>
#include <kconfiggroup.h>
#include <QVBoxLayout>
namespace KWin
{
KWIN_EFFECT_CONFIG_FACTORY
SnowEffectConfigForm::SnowEffectConfigForm(QWidget* parent) : QWidget(parent)
{
setupUi(this);
}
SnowEffectConfig::SnowEffectConfig(QWidget* parent, const QVariantList& args) :
KCModule(EffectFactory::componentData(), parent, args)
{
m_ui = new SnowEffectConfigForm(this);
QVBoxLayout* layout = new QVBoxLayout(this);
layout->addWidget(m_ui);
connect(m_ui->editor, SIGNAL(keyChange()), this, SLOT(changed()));
connect(m_ui->numberFlakes, SIGNAL(valueChanged(int)), this, SLOT(changed()));
connect(m_ui->minSizeFlake, SIGNAL(valueChanged(int)), this, SLOT(changed()));
connect(m_ui->maxSizeFlake, SIGNAL(valueChanged(int)), this, SLOT(changed()));
connect(m_ui->maxVSpeed, SIGNAL(valueChanged(int)), this, SLOT(changed()));
connect(m_ui->maxHSpeed, SIGNAL(valueChanged(int)), this, SLOT(changed()));
connect(m_ui->snowBehindWindows, SIGNAL(stateChanged(int)), this, SLOT(changed()));
// Shortcut config. The shortcut belongs to the component "kwin"!
m_actionCollection = new KActionCollection( this, KComponentData("kwin") );
m_actionCollection->setConfigGroup("Snow");
m_actionCollection->setConfigGlobal(true);
KAction* a = (KAction*)m_actionCollection->addAction( "Snow" );
a->setText( i18n("Toggle Snow on Desktop" ));
a->setProperty("isConfigurationAction", true);
a->setGlobalShortcut( KShortcut( Qt::CTRL + Qt::META + Qt::Key_F12 ));
m_ui->editor->addCollection(m_actionCollection);
}
SnowEffectConfig::~SnowEffectConfig()
{
// Undo (only) unsaved changes to global key shortcuts
m_ui->editor->undoChanges();
}
void SnowEffectConfig::load()
{
KCModule::load();
KConfigGroup conf = EffectsHandler::effectConfig("Snow");
int number = conf.readEntry("Number", 200);
int minFlake = conf.readEntry("MinFlakes", 10);
int maxFlake = conf.readEntry("MaxFlakes", 50);
int maxVSpeed = conf.readEntry("MaxVSpeed", 2);
int maxHSpeed = conf.readEntry("MaxHSpeed", 1);
m_ui->snowBehindWindows->setChecked( conf.readEntry("BehindWindows", true));
m_ui->numberFlakes->setValue( number );
m_ui->minSizeFlake->setValue( minFlake );
m_ui->minSizeFlake->setSuffix( ki18np(" pixel", " pixels") );
m_ui->maxSizeFlake->setValue( maxFlake );
m_ui->maxSizeFlake->setSuffix( ki18np(" pixel", " pixels") );
m_ui->maxVSpeed->setValue( maxVSpeed );
m_ui->maxVSpeed->setSuffix( ki18np(" pixel/frame", " pixels/frame") );
m_ui->maxHSpeed->setValue( maxHSpeed );
m_ui->maxHSpeed->setSuffix( ki18np(" pixel/frame", " pixels/frame") );
emit changed(false);
}
void SnowEffectConfig::save()
{
KConfigGroup conf = EffectsHandler::effectConfig("Snow");
conf.writeEntry("Number", m_ui->numberFlakes->value());
conf.writeEntry("MinFlakes", m_ui->minSizeFlake->value());
conf.writeEntry("MaxFlakes", m_ui->maxSizeFlake->value());
conf.writeEntry("MaxVSpeed", m_ui->maxVSpeed->value());
conf.writeEntry("MaxHSpeed", m_ui->maxHSpeed->value());
conf.writeEntry("BehindWindows", m_ui->snowBehindWindows->isChecked());
m_ui->editor->save(); // undo() will restore to this state from now on
conf.sync();
emit changed(false);
EffectsHandler::sendReloadMessage( "snow" );
}
void SnowEffectConfig::defaults()
{
m_ui->numberFlakes->setValue( 200 );
m_ui->minSizeFlake->setValue( 10 );
m_ui->maxSizeFlake->setValue( 50 );
m_ui->maxVSpeed->setValue( 2 );
m_ui->maxHSpeed->setValue( 1 );
m_ui->snowBehindWindows->setChecked( true );
m_ui->editor->allDefault();
emit changed(true);
}
} // namespace
#include "snow_config.moc"

View file

@ -1,86 +0,0 @@
[Desktop Entry]
Type=Service
X-KDE-ServiceTypes=KCModule
X-KDE-Library=kcm_kwin4_effect_builtins
X-KDE-ParentComponents=kwin4_effect_snow
X-KDE-PluginKeyword=snow
Name=Snow
Name[af]=Sneeu
Name[ar]=الثلج
Name[ast]=Ñeve
Name[be@latin]=Śnieh
Name[bg]=Сняг
Name[bn]=
Name[bn_IN]=Snow ()
Name[ca]=Neu
Name[ca@valencia]=Neu
Name[cs]=Sníh
Name[csb]=Sniég
Name[da]=Sne
Name[de]=Schnee
Name[el]=Χιόνι
Name[en_GB]=Snow
Name[eo]=Neĝo
Name[es]=Nieve
Name[et]=Lumi
Name[eu]=Elurra
Name[fi]=Lumisade
Name[fr]=Neige
Name[fy]=Snie
Name[ga]=Sneachta
Name[gl]=Neve
Name[gu]=
Name[he]=שלג
Name[hi]=
Name[hne]=
Name[hr]=Snijeg
Name[hu]=Hóesés
Name[ia]=Nive
Name[id]=Salju
Name[is]=Snjór
Name[it]=Neve
Name[ja]=
Name[kk]=Қар
Name[km]=
Name[kn]=
Name[ko]=
Name[ku]=Berf
Name[lt]=Sniegas
Name[lv]=Sniegs
Name[mai]=
Name[mk]=Снег
Name[ml]=
Name[mr]=ि
Name[nb]=Snø
Name[nds]=Snee
Name[nl]=Sneeuw
Name[nn]=Snø
Name[oc]=Nèu
Name[pa]=
Name[pl]=Śnieg
Name[pt]=Neve
Name[pt_BR]=Neve
Name[ro]=Zăpadă
Name[ru]=Снег
Name[si]=
Name[sk]=Sneh
Name[sl]=Sneg
Name[sr]=Снег
Name[sr@ijekavian]=Снијег
Name[sr@ijekavianlatin]=Snijeg
Name[sr@latin]=Sneg
Name[sv]=Snö
Name[ta]=ி
Name[te]=
Name[tg]=Барф
Name[th]=
Name[tr]=Kar
Name[uk]=Сніг
Name[uz]=Qor
Name[uz@cyrillic]=Қор
Name[wa]=Nive
Name[x-test]=xxSnowxx
Name[zh_CN]=
Name[zh_TW]=

View file

@ -1,59 +0,0 @@
/********************************************************************
KWin - the KDE window manager
This file is part of the KDE project.
Copyright (C) 2007 Martin Gräßlin <ubuntu@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_SNOW_CONFIG_H
#define KWIN_SNOW_CONFIG_H
#include <kcmodule.h>
#include "ui_snow_config.h"
class KActionCollection;
namespace KWin
{
class SnowEffectConfigForm : public QWidget, public Ui::SnowEffectConfigForm
{
Q_OBJECT
public:
explicit SnowEffectConfigForm(QWidget* parent);
};
class SnowEffectConfig : public KCModule
{
Q_OBJECT
public:
explicit SnowEffectConfig(QWidget* parent = 0, const QVariantList& args = QVariantList());
~SnowEffectConfig();
public slots:
virtual void save();
virtual void load();
virtual void defaults();
private:
SnowEffectConfigForm* m_ui;
KActionCollection* m_actionCollection;
};
} // namespace
#endif

View file

@ -1,200 +0,0 @@
<ui version="4.0" >
<class>KWin::SnowEffectConfigForm</class>
<widget class="QWidget" name="KWin::SnowEffectConfigForm" >
<property name="geometry" >
<rect>
<x>0</x>
<y>0</y>
<width>400</width>
<height>300</height>
</rect>
</property>
<layout class="QVBoxLayout" >
<item>
<widget class="QGroupBox" name="groupBox" >
<property name="title" >
<string>Appearance</string>
</property>
<layout class="QGridLayout" name="gridLayout" >
<item row="0" column="0" >
<widget class="QLabel" name="label" >
<property name="text" >
<string>&amp;Number of snowflakes:</string>
</property>
<property name="alignment" >
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
<property name="buddy" >
<cstring>numberFlakes</cstring>
</property>
</widget>
</item>
<item row="0" column="1" >
<widget class="KIntSpinBox" name="numberFlakes" >
<property name="sizePolicy" >
<sizepolicy vsizetype="Fixed" hsizetype="Expanding" >
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="maximum" >
<number>1000</number>
</property>
<property name="value" >
<number>200</number>
</property>
</widget>
</item>
<item row="1" column="0" >
<widget class="QLabel" name="label_2" >
<property name="text" >
<string>M&amp;inimum size of snowflake:</string>
</property>
<property name="alignment" >
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
<property name="buddy" >
<cstring>minSizeFlake</cstring>
</property>
</widget>
</item>
<item row="1" column="1" >
<widget class="KIntSpinBox" name="minSizeFlake" >
<property name="sizePolicy" >
<sizepolicy vsizetype="Fixed" hsizetype="Expanding" >
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="maximum" >
<number>30</number>
</property>
<property name="value" >
<number>10</number>
</property>
</widget>
</item>
<item row="2" column="0" >
<widget class="QLabel" name="label_3" >
<property name="text" >
<string>M&amp;aximum size of snowflake:</string>
</property>
<property name="alignment" >
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
<property name="buddy" >
<cstring>maxSizeFlake</cstring>
</property>
</widget>
</item>
<item row="2" column="1" >
<widget class="KIntSpinBox" name="maxSizeFlake" >
<property name="sizePolicy" >
<sizepolicy vsizetype="Fixed" hsizetype="Expanding" >
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="maximum" >
<number>1000</number>
</property>
<property name="value" >
<number>200</number>
</property>
</widget>
</item>
<item row="3" column="0" >
<widget class="QLabel" name="label_4" >
<property name="text" >
<string>Maximum &amp;vertical speed:</string>
</property>
<property name="alignment" >
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
<property name="buddy" >
<cstring>maxVSpeed</cstring>
</property>
</widget>
</item>
<item row="3" column="1" >
<widget class="KIntSpinBox" name="maxVSpeed" >
<property name="sizePolicy" >
<sizepolicy vsizetype="Fixed" hsizetype="Expanding" >
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimum" >
<number>1</number>
</property>
<property name="maximum" >
<number>30</number>
</property>
<property name="value" >
<number>2</number>
</property>
</widget>
</item>
<item row="4" column="0" >
<widget class="QLabel" name="label_5" >
<property name="text" >
<string>Maximum &amp;horizontal speed:</string>
</property>
<property name="alignment" >
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
<property name="buddy" >
<cstring>maxHSpeed</cstring>
</property>
</widget>
</item>
<item row="4" column="1" >
<widget class="KIntSpinBox" name="maxHSpeed" >
<property name="sizePolicy" >
<sizepolicy vsizetype="Fixed" hsizetype="Expanding" >
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimum" >
<number>0</number>
</property>
<property name="maximum" >
<number>30</number>
</property>
<property name="value" >
<number>1</number>
</property>
</widget>
</item>
<item row="5" column="0" >
<widget class="QCheckBox" name="snowBehindWindows" >
<property name="text" >
<string>Snow &amp;behind windows</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<widget class="KWin::GlobalShortcutsEditor" native="1" name="editor" />
</item>
</layout>
</widget>
<customwidgets>
<customwidget>
<class>KIntSpinBox</class>
<extends>QSpinBox</extends>
<header>knuminput.h</header>
</customwidget>
<customwidget>
<class>KWin::GlobalShortcutsEditor</class>
<extends>QWidget</extends>
<header location="global" >kwineffects.h</header>
<container>1</container>
</customwidget>
</customwidgets>
<resources/>
<connections/>
</ui>