--Boundary-00=_vXD3Hfxc37IDYHW Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Content-Disposition: inline I attach a new patch for the wobbly effect, the changelog is : - source moved to effet/ directory and files are renamed ("demo_" prefix was removed from the file names) - no more the annoying bug when the effect finishes - no more bugs when resizing the window (yes, it was buggy) what is missing to get a functionnal first version of the effect : - someting the effect doesn't finish and stale in a bad state (the window is deformed) - do a "real" config dialog with config options that mean something for the user (sliders that control the "wobblyness" or "inetia" of the moved window) what will be nice to have but not mandatory : - maximise effect, I take a look in the Effect class, it has a (un)minimise virtual function but not a (un)maximise one. - interaction with edge attraction. - slip out the bezier part of the code in another file to use it with other effects. I can add it to svn now if you think it is usefull enough, but I don't feel it should be enabled by default at least until I fixed the 2 main points. --Boundary-00=_vXD3Hfxc37IDYHW Content-Type: text/x-diff; charset="utf-8"; name="wobbly.diff" Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename="wobbly.diff" Index: effects/wobblywindows.h =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D =2D-- effects/wobblywindows.h (r=C3=A9vision 0) +++ effects/wobblywindows.h (r=C3=A9vision 0) @@ -0,0 +1,128 @@ +/***************************************************************** + KWin - the KDE window manager + This file is part of the KDE project. + +Copyright (C) 2008 C=C3=A9dric Borgese + +You can Freely distribute this program under the GNU General Public +License. See the file "COPYING" for the exact licensing terms. +******************************************************************/ + +#ifndef WOBBLYWINDOWS_H +#define WOBBLYWINDOWS_H + +// Include with base class for effects. +#include + +namespace KWin +{ + +/** + * Effect which wobble windows + **/ +class WobblyWindowsEffect : public Effect +{ + public: + + enum GridFilter + { + NoFilter, + FourRingLinearMean, + MeanWithMean, + MeanWithMedian + }; + + + WobblyWindowsEffect(); + virtual ~WobblyWindowsEffect(); + + virtual void prePaintScreen( ScreenPrePaintData& data, int time ); + virtual void prePaintWindow( EffectWindow* w, WindowPrePaintData& = data, int time ); + virtual void paintWindow( EffectWindow* w, int mask, QRegion regio= n, WindowPaintData& data ); + virtual void postPaintScreen(); + virtual void windowUserMovedResized( EffectWindow* c, bool first, = bool last ); + virtual void windowClosed( EffectWindow* c ); + + // Wobbly model parameters + void setRaideur(qreal raideur); + void setAmortissement(qreal amortissement); + void setVelocityThreshold(qreal velocityThreshold); + void setMoveFactor(qreal factor); + + void setVelocityFilter(GridFilter filter); + void setAccelerationFilter(GridFilter filter); + GridFilter velocityFilter() const; + GridFilter accelerationFilter() const; + + struct Pair + { + qreal x; + qreal y; + }; + + private: + + bool updateWindowWobblyDatas(EffectWindow* w, qreal time); + + struct WindowWobblyInfos + { + Pair* origin; + Pair* position; + Pair* velocity; + Pair* acceleration; + Pair* buffer; + + // if true, the point is constraint to its "normal" destination + // given by the window position. + // if false, the point is free (i.e. use the physics system to= move it) + bool* constraint; + + unsigned int width; + unsigned int height; + unsigned int count; + + Pair* bezierSurface; + unsigned int bezierWidth; + unsigned int bezierHeight; + unsigned int bezierCount; + + bool onConstrain; + }; + + QHash< const EffectWindow*, WindowWobblyInfos > windows; + + QRect m_updateRegion; + + qreal m_raideur; + qreal m_amortissement; + qreal m_move_factor; + + // the default tesselation for windows + // use qreal instead of int as I really often need + // these values as real to do divisions. + qreal m_xTesselation; + qreal m_yTesselation; + + GridFilter m_velocityFilter; + GridFilter m_accelerationFilter; + + qreal m_minVelocity; + qreal m_maxVelocity; + qreal m_stopVelocity; + qreal m_minAcceleration; + qreal m_maxAcceleration; + qreal m_stopAcceleration; + + void initWobblyInfo(WindowWobblyInfos& wwi, QRect geometry) const; + void freeWobblyInfo(WindowWobblyInfos& wwi) const; + + WobblyWindowsEffect::Pair computeBezierPoint(const WindowWobblyInf= os& wwi, Pair point) const; + + static void fourRingLinearMean(Pair** datas, WindowWobblyInfos& ww= i); + static void meanWithMean(Pair** datas, WindowWobblyInfos& wwi); + static void meanWithMedian(Pair** datas, WindowWobblyInfos& wwi); +}; + +} // namespace KWin + +#endif // WOBBLYWINDOWS_H Index: effects/wobblywindows_config.ui =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D =2D-- effects/wobblywindows_config.ui (r=C3=A9vision 0) +++ effects/wobblywindows_config.ui (r=C3=A9vision 0) @@ -0,0 +1,642 @@ + + KWin::WobblyWindowsEffectConfigForm + + + + 0 + 0 + 553 + 383 + + + + WobblyWindows + + + + + + 0 + + + + Grid Parameters + + + + + + + 0 + 0 + + + + Grid Minimal Tesselation + + + + + + Horizontal Nodes : + + + + + + + 2 + + + 20 + + + + + + + Vertical Nodes : + + + + + + + 2 + + + 20 + + + + + + + + + + + 0 + 0 + + + + Grid Parameters + + + + + + Raideur : + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + 2.000000000000000 + + + 0.020000000000000 + + + 0.500000000000000 + + + + + + + 100 + + + 25 + + + Qt::Horizontal + + + + + + + Qt::Horizontal + + + + + + + Amortissement : + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + 1.000000000000000 + + + 0.010000000000000 + + + 0.940000000000000 + + + + + + + 100 + + + 94 + + + Qt::Horizontal + + + + + + + Qt::Horizontal + + + + + + + Move Factor : + + + + + + + Qt::Horizontal + + + + 16 + 20 + + + + + + + + 1.000000000000000 + + + 0.010000000000000 + + + 0.010000000000000 + + + + + + + 100 + + + 1 + + + Qt::Horizontal + + + + + + + + + + + 0 + 0 + + + + Grid Filter + + + + + + + Velocity + + + + + Acceleration + + + + + + + + None + + + true + + + + + + + Ring Mean + + + false + + + + + + + Mean With Mean + + + + + + + Mean With Median + + + + + + + + + + + Thresholds + + + + + + Velocity + + + + + + Min Velocity + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + 1.000000000000000 + + + 0.010000000000000 + + + 0.500000000000000 + + + + + + + 100 + + + 50 + + + Qt::Horizontal + + + + + + + Qt::Horizontal + + + + + + + Max Velocity + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + 1000.000000000000000 + + + 10.000000000000000 + + + 500.000000000000000 + + + + + + + 100 + + + 50 + + + Qt::Horizontal + + + + + + + Qt::Horizontal + + + + + + + Velocity Stop + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + 10.000000000000000 + + + 0.100000000000000 + + + 3.000000000000000 + + + + + + + 100 + + + 30 + + + Qt::Horizontal + + + + + + + + + + Acceleration + + + + + + Min Acceleration + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + 1.000000000000000 + + + 0.010000000000000 + + + 0.100000000000000 + + + + + + + 100 + + + 10 + + + Qt::Horizontal + + + + + + + Qt::Horizontal + + + + + + + Max Acceleration + + + + + + + Qt::Horizontal + + + + 21 + 20 + + + + + + + + 1000.000000000000000 + + + 10.000000000000000 + + + 500.000000000000000 + + + + + + + 100 + + + 50 + + + Qt::Horizontal + + + + + + + Qt::Horizontal + + + + + + + Acceleration Stop + + + + + + + Qt::Horizontal + + + + 21 + 20 + + + + + + + + 10.000000000000000 + + + 0.100000000000000 + + + 8.000000000000000 + + + + + + + 100 + + + 80 + + + Qt::Horizontal + + + + + + + + + + + + + + + Index: effects/wobblywindows_config.cpp =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D =2D-- effects/wobblywindows_config.cpp (r=C3=A9vision 0) +++ effects/wobblywindows_config.cpp (r=C3=A9vision 0) @@ -0,0 +1,503 @@ +/******************************************************************** + KWin - the KDE window manager + This file is part of the KDE project. + + Copyright (C) 2008 C=C3=A9dric Borgese + +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 . +*********************************************************************/ + +#include "wobblywindows_config.h" +#include "wobblywindows_constants.h" + +#include + +#include +#include +#include +#include +#include +#include + +#include +#ifndef KDE_USE_FINAL +KWIN_EFFECT_CONFIG_FACTORY +#endif + +namespace KWin +{ + +WobblyWindowsEffectConfig::WobblyWindowsEffectConfig(QWidget* parent, cons= t QVariantList& args) : +KCModule(EffectFactory::componentData(), parent, args) +{ + m_ui.setupUi(this); + + connect(m_ui.spRaideur, SIGNAL(valueChanged(double)), this, SLOT(slotS= pRaideur(double))); + connect(m_ui.slRaideur, SIGNAL(sliderMoved(int)), this, SLOT(slotSlRai= deur(int))); + connect(m_ui.spAmortissement, SIGNAL(valueChanged(double)), this, SLOT= (slotSpAmortissement(double))); + connect(m_ui.slAmortissement, SIGNAL(sliderMoved(int)), this, SLOT(slo= tSlAmortissement(int))); + connect(m_ui.spMovFactor, SIGNAL(valueChanged(double)), this, SLOT(slo= tSpMovFactor(double))); + connect(m_ui.slMovFactor, SIGNAL(sliderMoved(int)), this, SLOT(slotSlM= ovFactor(int))); + + connect(m_ui.cbGridFilter, SIGNAL(activated(int)), this, SLOT(slotGrid= ParameterSelected(int))); + + connect(m_ui.rbNone, SIGNAL(toggled(bool)), this, SLOT(slotRbNone(bool= ))); + connect(m_ui.rbRingMean, SIGNAL(toggled(bool)), this, SLOT(slotRbRingM= ean(bool))); + connect(m_ui.rbMeanMean, SIGNAL(toggled(bool)), this, SLOT(slotRbMeanM= ean(bool))); + connect(m_ui.rbMeanMedian, SIGNAL(toggled(bool)), this, SLOT(slotRbMea= nMedian(bool))); + + connect(m_ui.spMinVel, SIGNAL(valueChanged(double)), this, SLOT(slotSp= MinVel(double))); + connect(m_ui.slMinVel, SIGNAL(sliderMoved(int)), this, SLOT(slotSlMinV= el(int))); + connect(m_ui.spMaxVel, SIGNAL(valueChanged(double)), this, SLOT(slotSp= MaxVel(double))); + connect(m_ui.slMaxVel, SIGNAL(sliderMoved(int)), this, SLOT(slotSlMaxV= el(int))); + connect(m_ui.spStopVel, SIGNAL(valueChanged(double)), this, SLOT(slotS= pStopVel(double))); + connect(m_ui.slStopVel, SIGNAL(sliderMoved(int)), this, SLOT(slotSlSto= pVel(int))); + connect(m_ui.spMinAcc, SIGNAL(valueChanged(double)), this, SLOT(slotSp= MinAcc(double))); + connect(m_ui.slMinAcc, SIGNAL(sliderMoved(int)), this, SLOT(slotSlMinA= cc(int))); + connect(m_ui.spMaxAcc, SIGNAL(valueChanged(double)), this, SLOT(slotSp= MaxAcc(double))); + connect(m_ui.slMaxAcc, SIGNAL(sliderMoved(int)), this, SLOT(slotSlMaxA= cc(int))); + connect(m_ui.spStopAcc, SIGNAL(valueChanged(double)), this, SLOT(slotS= pStopAcc(double))); + connect(m_ui.slStopAcc, SIGNAL(sliderMoved(int)), this, SLOT(slotSlSto= pAcc(int))); + + load(); +} + +WobblyWindowsEffectConfig::~WobblyWindowsEffectConfig() +{ +} + +void WobblyWindowsEffectConfig::load() +{ + KCModule::load(); + + KConfigGroup conf =3D EffectsHandler::effectConfig("Wobbly"); + qreal raideur =3D conf.readEntry("Raideur", RAIDEUR); + qreal amortissement =3D conf.readEntry("Amortissement", AMORTISSEMENT); + qreal move_factor =3D conf.readEntry("MoveFactor", MOVEFACTOR); + + m_ui.spRaideur->setValue(raideur); + m_ui.slRaideur->setSliderPosition(raideur*50); =20 + + m_ui.spAmortissement->setValue(amortissement); + m_ui.slAmortissement->setSliderPosition(amortissement*100); + + m_ui.spMovFactor->setValue(move_factor); + m_ui.slMovFactor->setValue(move_factor*100); + + int xTesselation =3D conf.readEntry("XTesselation", XTESSELATION); + int yTesselation =3D conf.readEntry("YTesselation", YTESSELATION); + + m_ui.spHNodes->setValue(xTesselation); + m_ui.spVNodes->setValue(yTesselation); + + //squareRootMasterAcceleration =3D conf.readEntry("SquareRootMasterAcc= eleration", false); + + QString velFilter =3D conf.readEntry("VelocityFilter", VELOCITYFILTER); + if (velFilter =3D=3D "NoFilter") + { + velocityFilter =3D NoFilter; + } + else if (velFilter =3D=3D "FourRingLinearMean") + { + velocityFilter =3D FourRingLinearMean; + } + else if (velFilter =3D=3D "MeanWithMean") + { + velocityFilter =3D MeanWithMean; + } + else if (velFilter =3D=3D "MeanWithMedian") + { + velocityFilter =3D MeanWithMedian; + } + else + { + velocityFilter =3D FourRingLinearMean; + kDebug() << "Unknown config value for VelocityFilter : " << velFil= ter; + } + + + QString accFilter =3D conf.readEntry("AccelerationFilter", ACCELERATIO= NFILTER); + if (accFilter =3D=3D "NoFilter") + { + accelerationFilter =3D NoFilter; + } + else if (accFilter =3D=3D "FourRingLinearMean") + { + accelerationFilter =3D FourRingLinearMean; + } + else if (accFilter =3D=3D "MeanWithMean") + { + accelerationFilter =3D MeanWithMean; + } + else if (accFilter =3D=3D "MeanWithMedian") + { + accelerationFilter =3D MeanWithMedian; + } + else + { + accelerationFilter =3D NoFilter; + kDebug() << "Unknown config value for accelerationFilter : " << ac= cFilter; + } + + qreal minVel =3D conf.readEntry("MinVelocity", MINVELOCITY); + qreal maxVel =3D conf.readEntry("MaxVelocity", MAXVELOCITY); + qreal stopVel =3D conf.readEntry("StopVelocity", STOPVELOCITY); + qreal minAcc =3D conf.readEntry("MinAcceleration", MINACCELERATION); + qreal maxAcc =3D conf.readEntry("MaxAcceleration", MAXACCELERATION); + qreal stopAcc =3D conf.readEntry("StopAcceleration", STOPACCELERATION); + + m_ui.spMinVel->setValue(minVel); + m_ui.slMinVel->setSliderPosition(minVel*100); + m_ui.spMaxVel->setValue(maxVel); + m_ui.slMaxVel->setSliderPosition(maxVel/10); + m_ui.spStopVel->setValue(stopVel); + m_ui.slStopVel->setSliderPosition(stopVel*10); + m_ui.spMinAcc->setValue(minAcc); + m_ui.slMinAcc->setSliderPosition(minAcc*100); + m_ui.spMaxAcc->setValue(maxAcc); + m_ui.slMaxAcc->setSliderPosition(maxAcc/10); + m_ui.spStopAcc->setValue(stopAcc); + m_ui.slStopAcc->setSliderPosition(stopAcc*10); + + emit changed(false); +} + +void WobblyWindowsEffectConfig::save() +{ + KConfigGroup conf =3D EffectsHandler::effectConfig("Wobbly"); + + conf.writeEntry("Raideur", m_ui.spRaideur->value()); + conf.writeEntry("Amortissement", m_ui.spAmortissement->value()); + conf.writeEntry("MoveFactor", m_ui.spMovFactor->value()); + + conf.writeEntry("XTesselation", m_ui.spHNodes->value()); + conf.writeEntry("YTesselation", m_ui.spVNodes->value()); + + switch (velocityFilter) + { + case NoFilter: + conf.writeEntry("VelocityFilter", "NoFilter"); + break; + + case FourRingLinearMean: + conf.writeEntry("VelocityFilter", "FourRingLinearMean"); + break; + + case MeanWithMean: + conf.writeEntry("VelocityFilter", "MeanWithMean"); + break; + + case MeanWithMedian: + conf.writeEntry("VelocityFilter", "MeanWithMedian"); + break; + } + + switch (accelerationFilter) + { + case NoFilter: + conf.writeEntry("AccelerationFilter", "NoFilter"); + break; + + case FourRingLinearMean: + conf.writeEntry("AccelerationFilter", "FourRingLinearMean"); + break; + + case MeanWithMean: + conf.writeEntry("AccelerationFilter", "MeanWithMean"); + break; + + case MeanWithMedian: + conf.writeEntry("AccelerationFilter", "MeanWithMedian"); + break; + } + + conf.writeEntry("MinVelocity", m_ui.spMinVel->value()); + conf.writeEntry("MaxVelocity", m_ui.spMaxVel->value()); + conf.writeEntry("StopVelocity", m_ui.spStopVel->value()); + conf.writeEntry("MinAcceleration", m_ui.spMinAcc->value()); + conf.writeEntry("MaxAcceleration", m_ui.spMaxAcc->value()); + conf.writeEntry("StopAcceleration", m_ui.spStopAcc->value()); + + conf.sync(); + + emit changed(false); + EffectsHandler::sendReloadMessage("wobblywindows"); +} + +void WobblyWindowsEffectConfig::defaults() +{ + m_ui.spRaideur->setValue(RAIDEUR); + m_ui.slRaideur->setSliderPosition(RAIDEUR*50); =20 + + m_ui.spAmortissement->setValue(AMORTISSEMENT); + m_ui.slAmortissement->setSliderPosition(AMORTISSEMENT*100); + + m_ui.spMovFactor->setValue(MOVEFACTOR); + m_ui.slMovFactor->setValue(MOVEFACTOR*100); + + m_ui.spHNodes->setValue(XTESSELATION); + m_ui.spVNodes->setValue(YTESSELATION); + + velocityFilter =3D FourRingLinearMean; + accelerationFilter =3D NoFilter; + slotGridParameterSelected(m_ui.cbGridFilter->currentIndex()); + + m_ui.spMinVel->setValue(MINVELOCITY); + m_ui.slMinVel->setSliderPosition(MINVELOCITY*100); + + m_ui.spMaxVel->setValue(MAXVELOCITY); + m_ui.slMaxVel->setSliderPosition(MAXVELOCITY/10); + + m_ui.spStopVel->setValue(STOPVELOCITY); + m_ui.slStopVel->setSliderPosition(STOPVELOCITY*10); + + m_ui.spMinAcc->setValue(MINACCELERATION); + m_ui.slMinAcc->setSliderPosition(MINACCELERATION*100); + + m_ui.spMaxAcc->setValue(MAXACCELERATION); + m_ui.slMaxAcc->setSliderPosition(MAXACCELERATION/10); + + m_ui.spStopAcc->setValue(STOPACCELERATION); + m_ui.slStopAcc->setSliderPosition(STOPACCELERATION*10); + + emit changed(true); +} + +void WobblyWindowsEffectConfig::slotSpRaideur(double value) +{ + m_ui.slRaideur->setSliderPosition(value*50); + emit changed(true); +} + +void WobblyWindowsEffectConfig::slotSlRaideur(int value) +{ + m_ui.spRaideur->setValue(value/50.0); + emit changed(true); +} + +void WobblyWindowsEffectConfig::slotSpAmortissement(double value) +{ + m_ui.slAmortissement->setSliderPosition(value*100); + emit changed(true); +} + +void WobblyWindowsEffectConfig::slotSlAmortissement(int value) +{ + m_ui.spAmortissement->setValue(qreal(value)/100.0); + emit changed(true); +} + +void WobblyWindowsEffectConfig::slotSpMovFactor(double value) +{ + m_ui.slMovFactor->setValue(value*100); + emit changed(true); +} + +void WobblyWindowsEffectConfig::slotSlMovFactor(int value) +{ + m_ui.spMovFactor->setValue(qreal(value)/100.0); + emit changed(true); +} + +// filters + +void WobblyWindowsEffectConfig::slotRbNone(bool toggled) +{ + if (toggled) + { + if (m_ui.cbGridFilter->currentIndex() =3D=3D 0) // velocity + { + velocityFilter =3D NoFilter; + } + else if (m_ui.cbGridFilter->currentIndex() =3D=3D 1) // accelerati= on + { + accelerationFilter =3D NoFilter; + } + } + emit changed(true); +} + +void WobblyWindowsEffectConfig::slotRbRingMean(bool toggled) +{ + if (toggled) + { + if (m_ui.cbGridFilter->currentIndex() =3D=3D 0) // velocity + { + velocityFilter =3D FourRingLinearMean; + } + else if (m_ui.cbGridFilter->currentIndex() =3D=3D 1) // accelerati= on + { + accelerationFilter =3D FourRingLinearMean; + } + } + emit changed(true); +} + +void WobblyWindowsEffectConfig::slotRbMeanMean(bool toggled) +{ + if (toggled) + { + if (m_ui.cbGridFilter->currentIndex() =3D=3D 0) // velocity + { + velocityFilter =3D MeanWithMean; + } + else if (m_ui.cbGridFilter->currentIndex() =3D=3D 1) // accelerati= on + { + accelerationFilter =3D MeanWithMean; + } + } + emit changed(true); +} + +void WobblyWindowsEffectConfig::slotRbMeanMedian(bool toggled) +{ + if (toggled) + { + if (m_ui.cbGridFilter->currentIndex() =3D=3D 0) // velocity + { + velocityFilter =3D MeanWithMedian; + } + else if (m_ui.cbGridFilter->currentIndex() =3D=3D 1) // accelerati= on + { + accelerationFilter =3D MeanWithMedian; + } + } + emit changed(true); +} + +void WobblyWindowsEffectConfig::slotGridParameterSelected(int index) +{ + if (index =3D=3D 0) // velocity + { + switch (velocityFilter) + { + case NoFilter: + m_ui.rbNone->setChecked(true); + break; + + case FourRingLinearMean: + m_ui.rbRingMean->setChecked(true); + break; + + case MeanWithMean: + m_ui.rbMeanMean->setChecked(true); + break; + + case MeanWithMedian: + m_ui.rbMeanMedian->setChecked(true); + break; + } + } + else if (index =3D=3D 1) // acceleration + { + switch (accelerationFilter) + { + case NoFilter: + m_ui.rbNone->setChecked(true); + break; + + case FourRingLinearMean: + m_ui.rbRingMean->setChecked(true); + break; + + case MeanWithMean: + m_ui.rbMeanMean->setChecked(true); + break; + + case MeanWithMedian: + m_ui.rbMeanMedian->setChecked(true); + break; + } + } + emit changed(true); +} + +// thresholds + +void WobblyWindowsEffectConfig::slotSpMinVel(double value) +{ + m_ui.slMinVel->setSliderPosition(value*100); + emit changed(true); +} + +void WobblyWindowsEffectConfig::slotSlMinVel(int value) +{ + m_ui.spMinVel->setValue(qreal(value)/100.0); + emit changed(true); +} + +void WobblyWindowsEffectConfig::slotSpMaxVel(double value) +{ + m_ui.slMaxVel->setSliderPosition(value/10); + emit changed(true); +} + +void WobblyWindowsEffectConfig::slotSlMaxVel(int value) +{ + m_ui.spMaxVel->setValue(value*10.0); + emit changed(true); +} + +void WobblyWindowsEffectConfig::slotSpStopVel(double value) +{ + m_ui.slStopVel->setSliderPosition(value*10); + emit changed(true); +} + +void WobblyWindowsEffectConfig::slotSlStopVel(int value) +{ + m_ui.spStopVel->setValue(value/10.0); + emit changed(true); +} + +void WobblyWindowsEffectConfig::slotSpMinAcc(double value) +{ + m_ui.slMinAcc->setSliderPosition(value*100); + emit changed(true); +} + +void WobblyWindowsEffectConfig::slotSlMinAcc(int value) +{ + m_ui.spMinAcc->setValue(value/100.0); + emit changed(true); +} + +void WobblyWindowsEffectConfig::slotSpMaxAcc(double value) +{ + m_ui.slMaxAcc->setSliderPosition(value/10); + emit changed(true); +} + +void WobblyWindowsEffectConfig::slotSlMaxAcc(int value) +{ + m_ui.spMaxAcc->setValue(value*10.0); + emit changed(true); +} + +void WobblyWindowsEffectConfig::slotSpStopAcc(double value) +{ + m_ui.slStopAcc->setSliderPosition(value*10); + emit changed(true); +} + +void WobblyWindowsEffectConfig::slotSlStopAcc(int value) +{ + m_ui.spStopAcc->setValue(value/10.0); + emit changed(true); +} + + +} // namespace + +#include "wobblywindows_config.moc" Index: effects/wobblywindows.desktop =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D =2D-- effects/wobblywindows.desktop (r=C3=A9vision 0) +++ effects/wobblywindows.desktop (r=C3=A9vision 0) @@ -0,0 +1,17 @@ +[Desktop Entry] +Encoding=3DUTF-8 +Name=3DWobbly Windows +Icon=3Dkwin-effect-wavywindows + +Type=3DService +ServiceTypes=3DKWin/Effect +X-KDE-PluginInfo-Author=3DC=C3=A9dric Borgese +X-KDE-PluginInfo-Email=3Dcedric.borgese@gmail.com +X-KDE-PluginInfo-Name=3Dkwin4_effect_wobblywindows +X-KDE-PluginInfo-Version=3D0.0.1 +X-KDE-PluginInfo-Category=3DAppearance +X-KDE-PluginInfo-Depends=3D +X-KDE-PluginInfo-License=3DGPL +X-KDE-PluginInfo-EnabledByDefault=3Dfalse +X-KDE-Library=3Dkwin4_effect_builtins +X-KDE-Ordering=3D80 \ No newline at end of file Index: effects/wobblywindows_config.desktop =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D =2D-- effects/wobblywindows_config.desktop (r=C3=A9vision 0) +++ effects/wobblywindows_config.desktop (r=C3=A9vision 0) @@ -0,0 +1,10 @@ +[Desktop Entry] +Type=3DService +X-KDE-ServiceTypes=3DKCModule + +X-KDE-Library=3Dkcm_kwin4_effect_tests +X-KDE-ParentComponents=3Dkwin4_effect_wobblywindows +X-KDE-PluginKeyword=3Dwobblywindows + +Name=3DWobbly Windows + Index: effects/wobblywindows_config.h =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D =2D-- effects/wobblywindows_config.h (r=C3=A9vision 0) +++ effects/wobblywindows_config.h (r=C3=A9vision 0) @@ -0,0 +1,93 @@ +/******************************************************************** + KWin - the KDE window manager + This file is part of the KDE project. + + Copyright (C) 2008 C=C3=A9dric Borgese + +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 . +*********************************************************************/ + +#ifndef KWIN_WOBBLY_CONFIG_H +#define KWIN_WOBBLY_CONFIG_H + +#define KDE3_SUPPORT +#include +#undef KDE3_SUPPORT + +#include "ui_wobblywindows_config.h" + +class KActionCollection; + +namespace KWin +{ + +class WobblyWindowsEffectConfig : public KCModule +{ + Q_OBJECT +public: + explicit WobblyWindowsEffectConfig(QWidget* parent =3D 0, const QVaria= ntList& args =3D QVariantList()); + ~WobblyWindowsEffectConfig(); + +public slots: + virtual void save(); + virtual void load(); + virtual void defaults(); + +private: + enum GridFilter + { + NoFilter, + FourRingLinearMean, + MeanWithMean, + MeanWithMedian + }; + +private slots: + + void slotSpRaideur(double); + void slotSlRaideur(int); + void slotSpAmortissement(double); + void slotSlAmortissement(int); + void slotSpMovFactor(double); + void slotSlMovFactor(int); + + void slotGridParameterSelected(int); + void slotRbNone(bool); + void slotRbRingMean(bool); + void slotRbMeanMean(bool); + void slotRbMeanMedian(bool); + + void slotSpMinVel(double); + void slotSlMinVel(int); + void slotSpMaxVel(double); + void slotSlMaxVel(int); + void slotSpStopVel(double); + void slotSlStopVel(int); + void slotSpMinAcc(double); + void slotSlMinAcc(int); + void slotSpMaxAcc(double); + void slotSlMaxAcc(int); + void slotSpStopAcc(double); + void slotSlStopAcc(int); + +private: + Ui::WobblyWindowsEffectConfigForm m_ui; + + GridFilter velocityFilter; + GridFilter accelerationFilter; +}; + +} // namespace + +#endif Index: effects/wobblywindows_constants.h =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D =2D-- effects/wobblywindows_constants.h (r=C3=A9vision 0) +++ effects/wobblywindows_constants.h (r=C3=A9vision 0) @@ -0,0 +1,38 @@ +/******************************************************************** + KWin - the KDE window manager + This file is part of the KDE project. + + Copyright (C) 2008 C=C3=A9dric Borgese + +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 . +*********************************************************************/ + +#include + +static const qreal RAIDEUR =3D 0.5; +static const qreal AMORTISSEMENT =3D 0.93; +static const qreal MOVEFACTOR =3D 0.01; + +static const int XTESSELATION =3D 20; +static const int YTESSELATION =3D 20; + +static const qreal MINVELOCITY =3D 0.8; +static const qreal MAXVELOCITY =3D 1000.0; +static const qreal STOPVELOCITY =3D 8.0; +static const qreal MINACCELERATION =3D 0.2; +static const qreal MAXACCELERATION =3D 1000.0; +static const qreal STOPACCELERATION =3D 15.0; + +static const char* VELOCITYFILTER =3D "FourRingLinearMean"; +static const char* ACCELERATIONFILTER =3D "NoFilter"; Index: effects/wobblywindows.cpp =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D =2D-- effects/wobblywindows.cpp (r=C3=A9vision 0) +++ effects/wobblywindows.cpp (r=C3=A9vision 0) @@ -0,0 +1,1130 @@ +/***************************************************************** + KWin - the KDE window manager + This file is part of the KDE project. + +Copyright (C) 2008 C=C3=A9dric Borgese + +You can Freely distribute this program under the GNU General Public +License. See the file "COPYING" for the exact licensing terms. +******************************************************************/ + + +#include "wobblywindows.h" +#include "wobblywindows_constants.h" + +#include +#include +#include + +#define USE_ASSERT +#ifdef USE_ASSERT +#define ASSERT1 assert +#else +#define ASSERT1 +#endif + +//#define COMPUTE_STATS + +// if you enable it and run kwin in a terminal from the session it manages, +// be sure to redirect the output of kwin in a file or +// you'll propably get deadlocks. +//#define VERBOSE_MODE + +#if defined COMPUTE_STATS and not defined VERBOSE_MODE +# warning "You enable COMPUTE_STATS without VERBOSE_MODE, computed stats= will not be printed." +#endif + +namespace KWin +{ + +KWIN_EFFECT(wobblywindows, WobblyWindowsEffect) + +WobblyWindowsEffect::WobblyWindowsEffect() +{ + KConfigGroup conf =3D effects->effectConfig("Wobbly"); + + m_raideur =3D conf.readEntry("Raideur", RAIDEUR); + m_amortissement =3D conf.readEntry("Amortissement", AMORTISSEMENT); + m_move_factor =3D conf.readEntry("MoveFactor", MOVEFACTOR); + + m_xTesselation =3D conf.readEntry("XTesselation", XTESSELATION); + m_yTesselation =3D conf.readEntry("YTesselation", YTESSELATION); + + m_minVelocity =3D conf.readEntry("MinVelocity", MINVELOCITY); + m_maxVelocity =3D conf.readEntry("MaxVelocity", MAXVELOCITY); + m_stopVelocity =3D conf.readEntry("StopVelocity", STOPVELOCITY); + m_minAcceleration =3D conf.readEntry("MinAcceleration", MINACCELERATIO= N); + m_maxAcceleration =3D conf.readEntry("MaxAcceleration", MAXACCELERATIO= N); + m_stopAcceleration =3D conf.readEntry("StopAcceleration", STOPACCELERA= TION); + + QString velFilter =3D conf.readEntry("VelocityFilter", VELOCITYFILTER); + if (velFilter =3D=3D "NoFilter") + { + m_velocityFilter =3D NoFilter; + } + else if (velFilter =3D=3D "FourRingLinearMean") + { + m_velocityFilter =3D FourRingLinearMean; + } + else if (velFilter =3D=3D "MeanWithMean") + { + m_velocityFilter =3D MeanWithMean; + } + else if (velFilter =3D=3D "MeanWithMedian") + { + m_velocityFilter =3D MeanWithMedian; + } + else + { + m_velocityFilter =3D FourRingLinearMean; + kDebug() << "Unknown config value for VelocityFilter : " << velFil= ter; + } + + + QString accFilter =3D conf.readEntry("AccelerationFilter", ACCELERATIO= NFILTER); + if (accFilter =3D=3D "NoFilter") + { + m_accelerationFilter =3D NoFilter; + } + else if (accFilter =3D=3D "FourRingLinearMean") + { + m_accelerationFilter =3D FourRingLinearMean; + } + else if (accFilter =3D=3D "MeanWithMean") + { + m_accelerationFilter =3D MeanWithMean; + } + else if (accFilter =3D=3D "MeanWithMedian") + { + m_accelerationFilter =3D MeanWithMedian; + } + else + { + m_accelerationFilter =3D NoFilter; + kDebug() << "Unknown config value for accelerationFilter : " << ac= cFilter; + } + +#if defined VERBOSE_MODE + kDebug() << "Parameters :\n" << + "grid(" << m_raideur << ", " << m_amortissement << ", " << m_move_= factor << ")\n" << + "velocity(" << m_minVelocity << ", " << m_maxVelocity << ", " << m= _stopVelocity << ")\n" << + "acceleration(" << m_minAcceleration << ", " << m_maxAcceleration = << ", " << m_stopAcceleration << ")\n" << + "tesselation(" << m_xTesselation << ", " << m_yTesselation << ")"; +#endif +} + +WobblyWindowsEffect::~WobblyWindowsEffect() +{ + if (windows.empty()) + { + // we should be empty at this point... + // emit a warning and clean the list. + kDebug() << "Windows list not empty. Left items : " << windows.cou= nt(); + QHash< const EffectWindow*, WindowWobblyInfos >::iterator i; + for (i =3D windows.begin(); i !=3D windows.end(); ++i) + { + freeWobblyInfo(i.value()); + } + } +} +void WobblyWindowsEffect::setVelocityThreshold(qreal m_minVelocity) +{ + this->m_minVelocity =3D m_minVelocity; +} + +void WobblyWindowsEffect::setMoveFactor(qreal factor) +{ + m_move_factor =3D factor; +} + +void WobblyWindowsEffect::setRaideur(qreal m_raideur) +{ + this->m_raideur =3D m_raideur; +} + +void WobblyWindowsEffect::setVelocityFilter(GridFilter filter) +{ + m_velocityFilter =3D filter; +} + +void WobblyWindowsEffect::setAccelerationFilter(GridFilter filter) +{ + m_accelerationFilter =3D filter; +} + +WobblyWindowsEffect::GridFilter WobblyWindowsEffect::velocityFilter() const +{ + return m_velocityFilter; +} + +WobblyWindowsEffect::GridFilter WobblyWindowsEffect::accelerationFilter() = const +{ + return m_accelerationFilter; +} + +void WobblyWindowsEffect::setAmortissement(qreal m_amortissement) +{ + this->m_amortissement =3D m_amortissement; +} + +void WobblyWindowsEffect::prePaintScreen(ScreenPrePaintData& data, int tim= e) +{ + // We need to mark the screen windows as transformed. Otherwise the wh= ole + // screen won't be repainted, resulting in artefacts. + // Could we just set a subset of the screen to be repainted ? + if (windows.count() !=3D 0) + { + data.mask |=3D PAINT_SCREEN_WITH_TRANSFORMED_WINDOWS; + } + + // this set the QRect invalid. + m_updateRegion.setWidth(0); + + effects->prePaintScreen(data, time); +} +const qreal maxTime =3D 10.0; +void WobblyWindowsEffect::prePaintWindow(EffectWindow* w, WindowPrePaintDa= ta& data, int time) +{ + if (windows.contains(w)) + { + data.setTransformed(); + data.quads =3D data.quads.makeRegularGrid(m_xTesselation, m_yTesse= lation); + bool stop =3D false; + qreal updateTime =3D time; + + while (!stop && (updateTime > maxTime)) + { +#if defined VERBOSE_MODE + kDebug() << "loop time " << updateTime << " / " << time; +#endif + stop =3D !updateWindowWobblyDatas(w, maxTime); + updateTime -=3D maxTime; + } + if (!stop && updateTime > 0) + { + updateWindowWobblyDatas(w, updateTime); + } + } + + effects->prePaintWindow(w, data, time); +} + +void WobblyWindowsEffect::paintWindow(EffectWindow* w, int mask, QRegion r= egion, WindowPaintData& data) +{ + if(windows.contains(w)) + { + WindowWobblyInfos& wwi =3D windows[w]; + int tx =3D w->geometry().x(); + int ty =3D w->geometry().y(); + for (int i =3D 0; i < data.quads.count(); ++i) + { + for(int j =3D 0; j < 4; ++j) + { + WindowVertex& v =3D data.quads[i][j]; + Pair oldPos =3D {tx + v.x(), ty + v.y()}; + Pair newPos =3D computeBezierPoint(wwi, oldPos); + v.move(newPos.x - tx, newPos.y - ty); + } + } + } + + // Call the next effect. + effects->paintWindow(w, mask, region, data); +} + +void WobblyWindowsEffect::postPaintScreen() +{ + if (!windows.isEmpty()) + { + effects->addRepaint(m_updateRegion); + } + + // Call the next effect. + effects->postPaintScreen(); +} + +void WobblyWindowsEffect::windowUserMovedResized(EffectWindow* w, bool fir= st, bool last) +{ + if (first && !w->isSpecialWindow()) + { + if (!windows.contains(w)) + { + WindowWobblyInfos new_wwi; + initWobblyInfo(new_wwi, w->geometry()); + windows[w] =3D new_wwi; + } + + WindowWobblyInfos& wwi =3D windows[w]; + wwi.onConstrain =3D true; + const QRectF& rect =3D w->geometry(); + + qreal x_increment =3D rect.width() / (wwi.width-1.0); + qreal y_increment =3D rect.height() / (wwi.height-1.0); + + Pair picked =3D {cursorPos().x(), cursorPos().y()}; +// wwi.mDestination.x =3D rect.x(); +// wwi.mDestination.y =3D rect.y(); + int indx =3D (picked.x - rect.x()) / x_increment; + int indy =3D (picked.y - rect.y()) / y_increment; + int pickedPointIndex =3D indy*wwi.width + indx; + if (pickedPointIndex < 0) + { + kDebug() << "Picked index =3D=3D " << pickedPointIndex << " wi= th (" << cursorPos().x() << "," << cursorPos().y() << ")"; + pickedPointIndex =3D 0; + } + else if (static_cast(pickedPointIndex) > wwi.count -= 1) + { + kDebug() << "Picked index =3D=3D " << pickedPointIndex << " wi= th (" << cursorPos().x() << "," << cursorPos().y() << ")"; + pickedPointIndex =3D wwi.count - 1; + } +#if defined VERBOSE_MODE + kDebug() << "Original Picked point -- x : " << picked.x << " - y := " << picked.y; +#endif + wwi.constraint[pickedPointIndex] =3D true; + } + else if (last) + { + if (windows.contains(w)) + { + WindowWobblyInfos& wwi =3D windows[w]; + wwi.onConstrain =3D false; + } + } +} + +void WobblyWindowsEffect::windowClosed(EffectWindow* w) +{ + if(windows.contains(w)) + { + WindowWobblyInfos& wwi =3D windows[w]; + freeWobblyInfo(wwi); + windows.remove(w); + } +} + +void WobblyWindowsEffect::initWobblyInfo(WindowWobblyInfos& wwi, QRect geo= metry) const +{ + wwi.count =3D 4*4; + wwi.width =3D 4; + wwi.height =3D 4; + + wwi.bezierWidth =3D m_xTesselation; + wwi.bezierHeight =3D m_yTesselation; + wwi.bezierCount =3D m_xTesselation * m_yTesselation; + + wwi.origin =3D new Pair[wwi.count]; + wwi.position =3D new Pair[wwi.count]; + wwi.velocity =3D new Pair[wwi.count]; + wwi.acceleration =3D new Pair[wwi.count]; + wwi.buffer =3D new Pair[wwi.count]; + wwi.constraint =3D new bool[wwi.count]; + + wwi.bezierSurface =3D new Pair[wwi.bezierCount]; + + wwi.onConstrain =3D true; + + qreal x =3D geometry.x(), y =3D geometry.y(); + qreal width =3D geometry.width(), height =3D geometry.height(); + + Pair initValue =3D {x, y}; + static const Pair nullPair =3D {0.0, 0.0}; + + qreal x_increment =3D width / (wwi.width-1.0); + qreal y_increment =3D height / (wwi.height-1.0); + + for (unsigned int j=3D0; j<4; ++j) + { + for (unsigned int i=3D0; i<4; ++i) + { + unsigned int idx =3D j*4 + i; + wwi.origin[idx] =3D initValue; + wwi.position[idx] =3D initValue; + wwi.velocity[idx] =3D nullPair; + wwi.constraint[idx] =3D false; + if (i !=3D 4-2) // x grid count - 2, i.e. not the last point + { + initValue.x +=3D x_increment; + } + else + { + initValue.x =3D width + x; + } + initValue.x =3D initValue.x; + } + initValue.x =3D x; + initValue.x =3D initValue.x; + if (j !=3D 4-2) // y grid count - 2, i.e. not the last point + { + initValue.y +=3D y_increment; + } + else + { + initValue.y =3D height + y; + } + initValue.y =3D initValue.y; + } +} + +void WobblyWindowsEffect::freeWobblyInfo(WindowWobblyInfos& wwi) const +{ + delete wwi.origin; + delete wwi.position; + delete wwi.velocity; + delete wwi.acceleration; + delete wwi.buffer; + delete wwi.constraint; + + delete wwi.bezierSurface; +} + +WobblyWindowsEffect::Pair WobblyWindowsEffect::computeBezierPoint(const Wi= ndowWobblyInfos& wwi, Pair point) const +{ + // compute the input value + Pair topleft =3D wwi.origin[0]; + Pair bottomright =3D wwi.origin[wwi.count-1]; + + ASSERT1(point.x >=3D topleft.x); + ASSERT1(point.y >=3D topleft.y); + ASSERT1(point.x <=3D bottomright.x); + ASSERT1(point.y <=3D bottomright.y); + + qreal tx =3D (point.x - topleft.x) / (bottomright.x - topleft.x); + qreal ty =3D (point.y - topleft.y) / (bottomright.y - topleft.y); + + ASSERT1(tx >=3D 0); + ASSERT1(tx <=3D 1); + ASSERT1(ty >=3D 0); + ASSERT1(ty <=3D 1); + + // compute polinomial coeff + + qreal px[4]; + px[0] =3D (1-tx)*(1-tx)*(1-tx); + px[1] =3D 3*(1-tx)*(1-tx)*tx; + px[2] =3D 3*(1-tx)*tx*tx; + px[3] =3D tx*tx*tx; + + qreal py[4]; + py[0] =3D (1-ty)*(1-ty)*(1-ty); + py[1] =3D 3*(1-ty)*(1-ty)*ty; + py[2] =3D 3*(1-ty)*ty*ty; + py[3] =3D ty*ty*ty; + + Pair res =3D {0.0, 0.0}; + + for (unsigned int j =3D 0; j < 4; ++j) + { + for (unsigned int i =3D 0; i < 4; ++i) + { + // this assume the grid is 4*4 + res.x +=3D px[i] * py[j] * wwi.position[i + j * wwi.width].x; + res.y +=3D px[i] * py[j] * wwi.position[i + j * wwi.width].y; + } + } + + return res; +} +namespace +{ + +static inline void fixVectorBounds(WobblyWindowsEffect::Pair& vec, qreal m= in, qreal max) +{ + if (fabs(vec.x) < min) + { + vec.x =3D 0.0; + } + else if (fabs(vec.x) > max) + { + if (vec.x > 0.0) + { + vec.x =3D max; + } + else + { + vec.x =3D -max; + } + } + + if (fabs(vec.y) < min) + { + vec.y =3D 0.0; + } + else if (fabs(vec.y) > max) + { + if (vec.y > 0.0) + { + vec.y =3D max; + } + else + { + vec.y =3D -max; + } + } +} + +static inline void computeVectorBounds(WobblyWindowsEffect::Pair& vec, Wob= blyWindowsEffect::Pair& bound) +{ + if (fabs(vec.x) < bound.x) + { + bound.x =3D fabs(vec.x); + } + else if (fabs(vec.x) > bound.y) + { + bound.y =3D fabs(vec.x); + } + if (fabs(vec.y) < bound.x) + { + bound.x =3D fabs(vec.y); + } + else if (fabs(vec.y) > bound.y) + { + bound.y =3D fabs(vec.y); + } +} + +} // close the anonymous namespace + +bool WobblyWindowsEffect::updateWindowWobblyDatas(EffectWindow* w, qreal t= ime) +{ + const QRectF& rect =3D w->geometry(); + WindowWobblyInfos& wwi =3D windows[w]; + + qreal x_length =3D rect.width() / (wwi.width-1.0); + qreal y_length =3D rect.height() / (wwi.height-1.0); + +#if defined VERBOSE_MODE + kDebug() << "time " << time; + kDebug() << "increment x " << x_length << " // y" << y_length; +#endif + + Pair origine =3D {rect.x(), rect.y()}; + + for (unsigned int j=3D0; j bottomRightCorner.x) + { + bottomRightCorner.x =3D pos.x; + } + if (pos.y < topLeftCorner.y) + { + topLeftCorner.y =3D pos.y; + } + if (pos.y > bottomRightCorner.y) + { + bottomRightCorner.y =3D pos.y; + } + + vel_sum +=3D fabs(vel.x) + fabs(vel.y); + +#if defined VERBOSE_MODE + if (fixedIndex =3D=3D i) + { + kDebug() << "Fixed item ** vel : " << vel.x << "," << vel.y <<= " ** move : " << vel.x*time << "," << vel.y*time; + } +#endif + } + +#if defined VERBOSE_MODE +# if defined COMPUTE_STATS + kDebug() << "Acceleration bounds (" << accBound.x << ", " << accBo= und.y << ")"; + kDebug() << "Velocity bounds (" << velBound.x << ", " << velBound.= y << ")"; +# endif + kDebug() << "sum_acc : " << acc_sum << " *** sum_vel :" << vel_sum; +#endif + + if (!wwi.onConstrain && acc_sum < m_stopAcceleration && vel_sum < m_st= opVelocity) + { + freeWobblyInfo(wwi); + windows.remove(w); + return false; + } + + QRect windowRect(topLeftCorner.x, topLeftCorner.y, + bottomRightCorner.x - topLeftCorner.x, bottomRightCorner.y - topLe= ftCorner.y); + if (m_updateRegion.isValid()) + { + m_updateRegion =3D m_updateRegion.united(windowRect); + } + else + { + m_updateRegion =3D windowRect; + } + + return true; +} + +void WobblyWindowsEffect::fourRingLinearMean(Pair** datas_pointer, WindowW= obblyInfos& wwi) +{ + Pair* datas =3D *datas_pointer; + Pair neibourgs[4]; + + // for corners + + // top-left + { + Pair& res =3D wwi.buffer[0]; + Pair vit =3D datas[0]; + neibourgs[0] =3D datas[1]; + neibourgs[1] =3D datas[wwi.width]; + + res.x =3D (neibourgs[0].x + neibourgs[1].x + 2.0*vit.x) / 4.0; + res.y =3D (neibourgs[0].y + neibourgs[1].y + 2.0*vit.y) / 4.0; + } + + + // top-right + { + Pair& res =3D wwi.buffer[wwi.width-1]; + Pair vit =3D datas[wwi.width-1]; + neibourgs[0] =3D datas[wwi.width-2]; + neibourgs[1] =3D datas[2*wwi.width-1]; + + res.x =3D (neibourgs[0].x + neibourgs[1].x + 2.0*vit.x) / 4.0; + res.y =3D (neibourgs[0].y + neibourgs[1].y + 2.0*vit.y) / 4.0; + } + + + // bottom-left + { + Pair& res =3D wwi.buffer[wwi.width*(wwi.height-1)]; + Pair vit =3D datas[wwi.width*(wwi.height-1)]; + neibourgs[0] =3D datas[wwi.width*(wwi.height-1)+1]; + neibourgs[1] =3D datas[wwi.width*(wwi.height-2)]; + + res.x =3D (neibourgs[0].x + neibourgs[1].x + 2.0*vit.x) / 4.0; + res.y =3D (neibourgs[0].y + neibourgs[1].y + 2.0*vit.y) / 4.0; + } + + + // bottom-right + { + Pair& res =3D wwi.buffer[wwi.count-1]; + Pair vit =3D datas[wwi.count-1]; + neibourgs[0] =3D datas[wwi.count-2]; + neibourgs[1] =3D datas[wwi.width*(wwi.height-1)-1]; + + res.x =3D (neibourgs[0].x + neibourgs[1].x + 2.0*vit.x) / 4.0; + res.y =3D (neibourgs[0].y + neibourgs[1].y + 2.0*vit.y) / 4.0; + } + + + // for borders + + // top border + for (unsigned int i=3D1; i xmax) + { + xmax =3D datas[i].x; + } + + if (datas[i].y < ymin) + { + ymin =3D datas[i].y; + } + if (datas[i].y > ymax) + { + ymax =3D datas[i].y; + } + } + + Pair median =3D {(xmin + xmax)/2.0, (ymin + ymax)/2.0}; + + for (unsigned int i =3D 0; i < wwi.count; ++i) + { + wwi.buffer[i].x =3D (datas[i].x + median.x) / 2.0; + wwi.buffer[i].y =3D (datas[i].y + median.y) / 2.0; + } + + Pair* tmp =3D datas; + *datas_pointer =3D wwi.buffer; + wwi.buffer =3D tmp; +} + + +} // namespace KWin + Index: effects/CMakeLists.txt =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D =2D-- effects/CMakeLists.txt (r=C3=A9vision 785951) +++ effects/CMakeLists.txt (copie de travail) @@ -108,6 +108,7 @@ sharpen.cpp snow.cpp trackmouse.cpp + wobblywindows.cpp ) install( FILES blur.desktop @@ -122,6 +123,7 @@ sharpen.desktop snow.desktop trackmouse.desktop + wobblywindows.desktop DESTINATION ${SERVICES_INSTALL_DIR}/kwin ) install( FILES data/trackmouse.png @@ -160,6 +162,8 @@ snow_config.cpp snow_config.ui trackmouse_config.cpp + wobblywindows_config.cpp + wobblywindows_config.ui ) install( FILES coverswitch_config.desktop @@ -172,6 +176,7 @@ showfps_config.desktop snow_config.desktop trackmouse_config.desktop + wobblywindows_config.desktop DESTINATION ${SERVICES_INSTALL_DIR}/kwin ) endif(KWIN_HAVE_OPENGL_COMPOSITING) =20 Index: effects/configs_builtins.cpp =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D =2D-- effects/configs_builtins.cpp (r=C3=A9vision 785951) +++ effects/configs_builtins.cpp (copie de travail) @@ -39,6 +39,7 @@ #include "sharpen_config.h" #include "snow_config.h" #include "trackmouse_config.h" +#include "wobblywindows_config.h" #ifdef KWIN_HAVE_XRENDER_COMPOSITING #include "showfps_config.h" #endif @@ -71,6 +72,7 @@ registerPlugin("snow"); \ registerPlugin("trackmouse"); \ registerPlugin ("showfps"); \ + registerPlugin ("wobblywindows"); \ =20 #ifdef KWIN_HAVE_OPENGL_COMPOSITING K_PLUGIN_FACTORY_DEFINITION(EffectFactory, --Boundary-00=_vXD3Hfxc37IDYHW Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ Kwin mailing list Kwin@kde.org https://mail.kde.org/mailman/listinfo/kwin --Boundary-00=_vXD3Hfxc37IDYHW--