diff --git a/effects/wobblywindows.cpp b/effects/wobblywindows.cpp index d53571b22a..2169eb02dd 100644 --- a/effects/wobblywindows.cpp +++ b/effects/wobblywindows.cpp @@ -38,23 +38,20 @@ License. See the file "COPYING" for the exact licensing terms. namespace KWin { -static const qreal STIFFNESS = 0.06; -static const qreal DRAG = 0.92; -static const qreal MOVEFACTOR = 0.1; +static const qreal STIFFNESS = 0.15; +static const qreal DRAG = 0.80; +static const qreal MOVEFACTOR = 0.10; static const int XTESSELATION = 20; static const int YTESSELATION = 20; static const qreal MINVELOCITY = 0.0; static const qreal MAXVELOCITY = 1000.0; -static const qreal STOPVELOCITY = 3.0; +static const qreal STOPVELOCITY = 0.5; static const qreal MINACCELERATION = 0.0; static const qreal MAXACCELERATION = 1000.0; static const qreal STOPACCELERATION = 5.0; -static const char* VELOCITYFILTER = "HeightRingLinearMean"; -static const char* ACCELERATIONFILTER = "HeightRingLinearMean"; - struct ParameterSet { qreal stiffness; @@ -64,9 +61,6 @@ struct ParameterSet qreal xTesselation; qreal yTesselation; - WobblyWindowsEffect::GridFilter velocityFilter; - WobblyWindowsEffect::GridFilter accelerationFilter; - qreal minVelocity; qreal maxVelocity; qreal stopVelocity; @@ -81,13 +75,11 @@ struct ParameterSet ParameterSet set_0 = { - 0.1, - 0.8, - 0.1, + 0.15, + 0.80, + 0.10, 20.0, 20.0, - WobblyWindowsEffect::FourRingLinearMean, - WobblyWindowsEffect::HeightRingLinearMean, 0.0, 1000.0, 0.5, @@ -101,13 +93,11 @@ ParameterSet set_0 = ParameterSet set_1 = { - 0.15, + 0.10, 0.85, - 0.1, + 0.10, 20.0, 20.0, - WobblyWindowsEffect::HeightRingLinearMean, - WobblyWindowsEffect::MeanWithMean, 0.0, 1000.0, 0.5, @@ -122,12 +112,10 @@ ParameterSet set_1 = ParameterSet set_2 = { 0.06, - 0.9, - 0.1, + 0.90, + 0.10, 20.0, 20.0, - WobblyWindowsEffect::HeightRingLinearMean, - WobblyWindowsEffect::NoFilter, 0.0, 1000.0, 0.5, @@ -143,11 +131,9 @@ ParameterSet set_3 = { 0.03, 0.92, - 0.2, + 0.20, 20.0, 20.0, - WobblyWindowsEffect::HeightRingLinearMean, - WobblyWindowsEffect::HeightRingLinearMean, 0.0, 1000.0, 0.5, @@ -166,8 +152,6 @@ ParameterSet set_4 = 0.25, 20.0, 20.0, - WobblyWindowsEffect::HeightRingLinearMean, - WobblyWindowsEffect::HeightRingLinearMean, 0.0, 1000.0, 0.5, @@ -191,7 +175,7 @@ WobblyWindowsEffect::WobblyWindowsEffect() QString settingsMode = conf.readEntry("Settings", "Auto"); if (settingsMode != "Custom") { - unsigned int wobblynessLevel = conf.readEntry("WobblynessLevel", 1); + unsigned int wobblynessLevel = conf.readEntry("WobblynessLevel", 0); if (wobblynessLevel > 4) { kDebug() << "Wrong value for \"WobblynessLevel\" : " << wobblynessLevel; @@ -204,9 +188,6 @@ WobblyWindowsEffect::WobblyWindowsEffect() m_stiffness = conf.readEntry("Stiffness", STIFFNESS * 100.0) / 100.0; m_drag = conf.readEntry("Drag", DRAG * 100.0) / 100.0; m_move_factor = conf.readEntry("MoveFactor", MOVEFACTOR * 100.0) / 100.0; - - m_velocityFilter = GridFilter(conf.readEntry("VelocityFilterEnum", int(HeightRingLinearMean))); - m_accelerationFilter = GridFilter(conf.readEntry("AccelerationFilterEnum", int(HeightRingLinearMean))); } } else // Custom method, read all values from config file. @@ -225,60 +206,6 @@ WobblyWindowsEffect::WobblyWindowsEffect() m_maxAcceleration = conf.readEntry("MaxAcceleration", MAXACCELERATION); m_stopAcceleration = conf.readEntry("StopAcceleration", STOPACCELERATION); - QString velFilter = conf.readEntry("VelocityFilter", VELOCITYFILTER); - if (velFilter == "NoFilter") - { - m_velocityFilter = NoFilter; - } - else if (velFilter == "FourRingLinearMean") - { - m_velocityFilter = FourRingLinearMean; - } - else if (velFilter == "HeightRingLinearMean") - { - m_velocityFilter = HeightRingLinearMean; - } - else if (velFilter == "MeanWithMean") - { - m_velocityFilter = MeanWithMean; - } - else if (velFilter == "MeanWithMedian") - { - m_velocityFilter = MeanWithMedian; - } - else - { - m_velocityFilter = FourRingLinearMean; - kDebug() << "Unknown config value for VelocityFilter : " << velFilter; - } - - QString accFilter = conf.readEntry("AccelerationFilter", ACCELERATIONFILTER); - if (accFilter == "NoFilter") - { - m_accelerationFilter = NoFilter; - } - else if (accFilter == "FourRingLinearMean") - { - m_accelerationFilter = FourRingLinearMean; - } - else if (accFilter == "HeightRingLinearMean") - { - m_accelerationFilter = HeightRingLinearMean; - } - else if (accFilter == "MeanWithMean") - { - m_accelerationFilter = MeanWithMean; - } - else if (accFilter == "MeanWithMedian") - { - m_accelerationFilter = MeanWithMedian; - } - else - { - m_accelerationFilter = NoFilter; - kDebug() << "Unknown config value for accelerationFilter : " << accFilter; - } - m_moveEffectEnabled = conf.readEntry("MoveEffect", true); m_openEffectEnabled = conf.readEntry("OpenEffect", false); // disable close effect by default for now as it doesn't do what I want. @@ -322,9 +249,6 @@ void WobblyWindowsEffect::setParameterSet(ParameterSet& pset) m_xTesselation = pset.xTesselation; m_yTesselation = pset.yTesselation; - m_velocityFilter = pset.velocityFilter ; - m_accelerationFilter = pset.accelerationFilter; - m_minVelocity = pset.minVelocity; m_maxVelocity = pset.maxVelocity; m_stopVelocity = pset.stopVelocity; @@ -352,26 +276,6 @@ void WobblyWindowsEffect::setStiffness(qreal stiffness) m_stiffness = stiffness; } -void WobblyWindowsEffect::setVelocityFilter(GridFilter filter) -{ - m_velocityFilter = filter; -} - -void WobblyWindowsEffect::setAccelerationFilter(GridFilter filter) -{ - m_accelerationFilter = filter; -} - -WobblyWindowsEffect::GridFilter WobblyWindowsEffect::velocityFilter() const -{ - return m_velocityFilter; -} - -WobblyWindowsEffect::GridFilter WobblyWindowsEffect::accelerationFilter() const -{ - return m_accelerationFilter; -} - void WobblyWindowsEffect::setDrag(qreal drag) { m_drag = drag; @@ -1078,30 +982,7 @@ bool WobblyWindowsEffect::updateWindowWobblyDatas(EffectWindow* w, qreal time) } } - switch (m_accelerationFilter) - { - case NoFilter: - break; - - case FourRingLinearMean: - fourRingLinearMean(&wwi.acceleration, wwi); - break; - - case HeightRingLinearMean: - heightRingLinearMean(&wwi.acceleration, wwi); - break; - - case MeanWithMean: - meanWithMean(&wwi.acceleration, wwi); - break; - - case MeanWithMedian: - meanWithMedian(&wwi.acceleration, wwi); - break; - - default: - ASSERT1(false); - } + heightRingLinearMean(&wwi.acceleration, wwi); #if defined COMPUTE_STATS Pair accBound = {m_maxAcceleration, m_minAcceleration}; @@ -1125,31 +1006,7 @@ bool WobblyWindowsEffect::updateWindowWobblyDatas(EffectWindow* w, qreal time) acc_sum += fabs(acc.x) + fabs(acc.y); } - - switch (m_velocityFilter) - { - case NoFilter: - break; - - case FourRingLinearMean: - fourRingLinearMean(&wwi.velocity, wwi); - break; - - case HeightRingLinearMean: - heightRingLinearMean(&wwi.velocity, wwi); - break; - - case MeanWithMean: - meanWithMean(&wwi.velocity, wwi); - break; - - case MeanWithMedian: - meanWithMedian(&wwi.velocity, wwi); - break; - - default: - ASSERT1(false); - } + heightRingLinearMean(&wwi.velocity, wwi); Pair topLeftCorner = {-10000.0, -10000.0}; Pair bottomRightCorner = {10000.0, 10000.0}; @@ -1228,204 +1085,6 @@ bool WobblyWindowsEffect::updateWindowWobblyDatas(EffectWindow* w, qreal time) return true; } -void WobblyWindowsEffect::fourRingLinearMean(Pair** datas_pointer, WindowWobblyInfos& wwi) -{ - Pair* datas = *datas_pointer; - Pair neibourgs[4]; - - // for corners - - // top-left - { - Pair& res = wwi.buffer[0]; - Pair vit = datas[0]; - neibourgs[0] = datas[1]; - neibourgs[1] = datas[wwi.width]; - - res.x = (neibourgs[0].x + neibourgs[1].x + 2.0*vit.x) / 4.0; - res.y = (neibourgs[0].y + neibourgs[1].y + 2.0*vit.y) / 4.0; - } - - - // top-right - { - Pair& res = wwi.buffer[wwi.width-1]; - Pair vit = datas[wwi.width-1]; - neibourgs[0] = datas[wwi.width-2]; - neibourgs[1] = datas[2*wwi.width-1]; - - res.x = (neibourgs[0].x + neibourgs[1].x + 2.0*vit.x) / 4.0; - res.y = (neibourgs[0].y + neibourgs[1].y + 2.0*vit.y) / 4.0; - } - - - // bottom-left - { - Pair& res = wwi.buffer[wwi.width*(wwi.height-1)]; - Pair vit = datas[wwi.width*(wwi.height-1)]; - neibourgs[0] = datas[wwi.width*(wwi.height-1)+1]; - neibourgs[1] = datas[wwi.width*(wwi.height-2)]; - - res.x = (neibourgs[0].x + neibourgs[1].x + 2.0*vit.x) / 4.0; - res.y = (neibourgs[0].y + neibourgs[1].y + 2.0*vit.y) / 4.0; - } - - - // bottom-right - { - Pair& res = wwi.buffer[wwi.count-1]; - Pair vit = datas[wwi.count-1]; - neibourgs[0] = datas[wwi.count-2]; - neibourgs[1] = datas[wwi.width*(wwi.height-1)-1]; - - res.x = (neibourgs[0].x + neibourgs[1].x + 2.0*vit.x) / 4.0; - res.y = (neibourgs[0].y + neibourgs[1].y + 2.0*vit.y) / 4.0; - } - - - // for borders - - // top border - for (unsigned int i=1; i xmax) - { - xmax = datas[i].x; - } - - if (datas[i].y < ymin) - { - ymin = datas[i].y; - } - if (datas[i].y > ymax) - { - ymax = datas[i].y; - } - } - - Pair median = {(xmin + xmax)/2.0, (ymin + ymax)/2.0}; - - for (unsigned int i = 0; i < wwi.count; ++i) - { - wwi.buffer[i].x = (datas[i].x + median.x) / 2.0; - wwi.buffer[i].y = (datas[i].y + median.y) / 2.0; - } - - Pair* tmp = datas; - *datas_pointer = wwi.buffer; - wwi.buffer = tmp; -} - void WobblyWindowsEffect::heightRingLinearMean(Pair** datas_pointer, WindowWobblyInfos& wwi) { Pair* datas = *datas_pointer; diff --git a/effects/wobblywindows.h b/effects/wobblywindows.h index d93a10775c..64eadb0151 100644 --- a/effects/wobblywindows.h +++ b/effects/wobblywindows.h @@ -26,16 +26,6 @@ class WobblyWindowsEffect : public Effect { public: - enum GridFilter - { - NoFilter, - FourRingLinearMean, - HeightRingLinearMean, - MeanWithMean, - MeanWithMedian - }; - - WobblyWindowsEffect(); virtual ~WobblyWindowsEffect(); @@ -53,11 +43,6 @@ class WobblyWindowsEffect : public Effect 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; @@ -118,9 +103,6 @@ class WobblyWindowsEffect : public Effect qreal m_xTesselation; qreal m_yTesselation; - GridFilter m_velocityFilter; - GridFilter m_accelerationFilter; - qreal m_minVelocity; qreal m_maxVelocity; qreal m_stopVelocity; @@ -142,10 +124,7 @@ class WobblyWindowsEffect : public Effect WobblyWindowsEffect::Pair computeBezierPoint(const WindowWobblyInfos& wwi, Pair point) const; - static void fourRingLinearMean(Pair** datas, WindowWobblyInfos& wwi); static void heightRingLinearMean(Pair** datas, WindowWobblyInfos& wwi); - static void meanWithMean(Pair** datas, WindowWobblyInfos& wwi); - static void meanWithMedian(Pair** datas, WindowWobblyInfos& wwi); void setParameterSet(ParameterSet& pset); }; diff --git a/effects/wobblywindows_config.cpp b/effects/wobblywindows_config.cpp index cd41cd39cf..c1341c1df4 100644 --- a/effects/wobblywindows_config.cpp +++ b/effects/wobblywindows_config.cpp @@ -43,54 +43,41 @@ struct ParameterSet int stiffness; int drag; int move_factor; - - WobblyWindowsEffect::GridFilter velocityFilter; - WobblyWindowsEffect::GridFilter accelerationFilter; }; ParameterSet set_0 = { - 10, + 15, 80, - 10, - WobblyWindowsEffect::FourRingLinearMean, - WobblyWindowsEffect::HeightRingLinearMean, + 10 }; ParameterSet set_1 = { - 15, - 85, 10, - WobblyWindowsEffect::HeightRingLinearMean, - WobblyWindowsEffect::MeanWithMean, + 85, + 10 }; ParameterSet set_2 = { 6, 90, - 10, - WobblyWindowsEffect::HeightRingLinearMean, - WobblyWindowsEffect::NoFilter, + 10 }; ParameterSet set_3 = { 3, 92, - 20, - WobblyWindowsEffect::HeightRingLinearMean, - WobblyWindowsEffect::HeightRingLinearMean, + 20 }; ParameterSet set_4 = { 1, 97, - 25, - WobblyWindowsEffect::HeightRingLinearMean, - WobblyWindowsEffect::HeightRingLinearMean, + 25 }; ParameterSet pset[5] = { set_0, set_1, set_2, set_3, set_4 }; @@ -111,8 +98,6 @@ KCModule(EffectFactory::componentData(), parent, args) connect(m_ui.stiffnessSpin, SIGNAL(valueChanged(int)), this, SLOT(changed())); connect(m_ui.dragSpin, SIGNAL(valueChanged(int)), this, SLOT(changed())); connect(m_ui.moveFactorSpin, SIGNAL(valueChanged(int)), this, SLOT(changed())); - connect(m_ui.velocityCombo, SIGNAL(currentIndexChanged(int)), this, SLOT(changed())); - connect(m_ui.accelerationCombo, SIGNAL(currentIndexChanged(int)), this, SLOT(changed())); load(); } @@ -128,11 +113,11 @@ void WobblyWindowsEffectConfig::load() KConfigGroup conf = EffectsHandler::effectConfig("Wobbly"); bool change = true; - unsigned int wobblynessLevel = 1; + unsigned int wobblynessLevel = 0; QString settingsMode = conf.readEntry("Settings", "Auto"); if (settingsMode != "Custom") { - wobblynessLevel = conf.readEntry("WobblynessLevel", 1); + wobblynessLevel = conf.readEntry("WobblynessLevel", 0); change = false; } if (wobblynessLevel > 4) @@ -146,12 +131,9 @@ void WobblyWindowsEffectConfig::load() m_ui.resizeBox->setChecked(conf.readEntry("ResizeWobble", true)); m_ui.advancedBox->setChecked(conf.readEntry("AdvancedMode", false)); - m_ui.stiffnessSlider->setValue(conf.readEntry("Stiffness", pset[1].stiffness)); - m_ui.dragSlider->setValue(conf.readEntry("Drag", pset[1].drag)); - m_ui.moveFactorSlider->setValue(conf.readEntry("MoveFactor", pset[1].move_factor)); - - m_ui.velocityCombo->setCurrentIndex(conf.readEntry("VelocityFilterEnum", int(WobblyWindowsEffect::HeightRingLinearMean))); - m_ui.accelerationCombo->setCurrentIndex(conf.readEntry("AccelerationFilterEnum", int(WobblyWindowsEffect::MeanWithMean))); + m_ui.stiffnessSlider->setValue(conf.readEntry("Stiffness", pset[0].stiffness)); + m_ui.dragSlider->setValue(conf.readEntry("Drag", pset[0].drag)); + m_ui.moveFactorSlider->setValue(conf.readEntry("MoveFactor", pset[0].move_factor)); advancedChanged(); @@ -173,27 +155,21 @@ void WobblyWindowsEffectConfig::save() conf.writeEntry("Drag", m_ui.dragSpin->value()); conf.writeEntry("MoveFactor", m_ui.moveFactorSpin->value()); - conf.writeEntry("VelocityFilterEnum", m_ui.velocityCombo->currentIndex()); - conf.writeEntry("AccelerationFilterEnum", m_ui.accelerationCombo->currentIndex()); - emit changed(false); EffectsHandler::sendReloadMessage("wobblywindows"); } void WobblyWindowsEffectConfig::defaults() { - m_ui.wobblinessSlider->setSliderPosition(1); + m_ui.wobblinessSlider->setSliderPosition(0); m_ui.moveBox->setChecked(true); m_ui.resizeBox->setChecked(true); m_ui.advancedBox->setChecked(false); - m_ui.stiffnessSlider->setValue(pset[1].stiffness); - m_ui.dragSlider->setValue(pset[1].drag); - m_ui.moveFactorSlider->setValue(pset[1].move_factor); - - m_ui.velocityCombo->setCurrentIndex(int(WobblyWindowsEffect::HeightRingLinearMean)); - m_ui.accelerationCombo->setCurrentIndex(int(WobblyWindowsEffect::MeanWithMean)); + m_ui.stiffnessSlider->setValue(pset[0].stiffness); + m_ui.dragSlider->setValue(pset[0].drag); + m_ui.moveFactorSlider->setValue(pset[0].move_factor); emit changed(true); } @@ -213,9 +189,6 @@ void WobblyWindowsEffectConfig::wobblinessChanged() m_ui.stiffnessSlider->setValue(preset.stiffness); m_ui.dragSlider->setValue(preset.drag); m_ui.moveFactorSlider->setValue(preset.move_factor); - - m_ui.velocityCombo->setCurrentIndex(preset.velocityFilter); - m_ui.accelerationCombo->setCurrentIndex(preset.accelerationFilter); } } // namespace diff --git a/effects/wobblywindows_config.ui b/effects/wobblywindows_config.ui index 30e49f31ec..cc524d3a91 100644 --- a/effects/wobblywindows_config.ui +++ b/effects/wobblywindows_config.ui @@ -6,7 +6,7 @@ 0 0 410 - 300 + 240 @@ -82,102 +82,6 @@ Advanced - - - - true - - - &Velocity filter: - - - false - - - Qt::LinksAccessibleByMouse - - - velocityCombo - - - - - - - - None - - - - - Four Ring Linear Mean - - - - - Height Ring Linear Mean - - - - - Mean With Mean - - - - - Mean With Median - - - - - - - - true - - - Acceleration &filter: - - - false - - - Qt::LinksAccessibleByMouse - - - velocityCombo - - - - - - - - None - - - - - Four Ring Linear Mean - - - - - Height Ring Linear Mean - - - - - Mean With Mean - - - - - Mean With Median - - - - @@ -349,8 +253,6 @@ dragSpin moveFactorSlider moveFactorSpin - velocityCombo - accelerationCombo diff --git a/effects/wobblywindows_constants.h b/effects/wobblywindows_constants.h deleted file mode 100644 index ee35e918b4..0000000000 --- a/effects/wobblywindows_constants.h +++ /dev/null @@ -1,37 +0,0 @@ -/******************************************************************** - KWin - the KDE window manager - This file is part of the KDE project. - - Copyright (C) 2008 Cédric 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 . -*********************************************************************/ - - -static const qreal STIFFNESS = 0.06; -static const qreal DRAG = 0.92; -static const qreal MOVEFACTOR = 0.1; - -static const int XTESSELATION = 20; -static const int YTESSELATION = 20; - -static const qreal MINVELOCITY = 0.0; -static const qreal MAXVELOCITY = 1000.0; -static const qreal STOPVELOCITY = 3.0; -static const qreal MINACCELERATION = 0.0; -static const qreal MAXACCELERATION = 1000.0; -static const qreal STOPACCELERATION = 5.0; - -static const char* VELOCITYFILTER = "FourRingLinearMean"; -static const char* ACCELERATIONFILTER = "FourRingLinearMean";