From 2cf35aa21ab103b6ce0a06852c674a08954323b4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Gr=C3=A4=C3=9Flin?= Date: Wed, 5 Sep 2012 21:35:36 +0200 Subject: [PATCH] Remove animations from Translucency effect The effect should have had two animations: * on move resize * on active/inactive change But the timeline was adjusted in the prePaintWindow call and the timeline is effect global and not per window. Which means that for each window the same time is added. So instead of adding time t each frame t*n with n being the number of windows got added. So in most cases the animation ended in the first or second frame which means its not visible. Through git blame I was able to track down that this incorrect behavior was introduced in 2008. An animation broken for more than four years without anybody noticing is probably not required. Because of that it's dropped from the effect. As this includes quite some code and performance improvements it goes into the release branch. A better solution could be implemented, but that should be for 4.10. BUG: 306263 FIXED-IN: 4.9.2 REVIEW: 106335 --- effects/translucency/translucency.cpp | 56 +- effects/translucency/translucency.h | 14 - effects/translucency/translucency_config.cpp | 5 - effects/translucency/translucency_config.ui | 595 +++++++++---------- 4 files changed, 284 insertions(+), 386 deletions(-) diff --git a/effects/translucency/translucency.cpp b/effects/translucency/translucency.cpp index c33672a607..a725bbb09e 100644 --- a/effects/translucency/translucency.cpp +++ b/effects/translucency/translucency.cpp @@ -28,10 +28,7 @@ namespace KWin KWIN_EFFECT(translucency, TranslucencyEffect) TranslucencyEffect::TranslucencyEffect() - : fadeout(NULL) - , current(NULL) - , previous(NULL) - , m_activeDecorations(false) + : m_activeDecorations(false) , m_activeMoveResize(false) , m_activeDialogs(false) , m_activeInactive(false) @@ -67,10 +64,6 @@ void TranslucencyEffect::reconfigure(ReconfigureFlags) popupmenus = menus; tornoffmenus = menus; } - moveresize_timeline.setCurveShape(QTimeLine::EaseInOutCurve); - moveresize_timeline.setDuration(animationTime(conf, "Duration", 800)); - activeinactive_timeline.setCurveShape(QTimeLine::EaseInOutCurve); - activeinactive_timeline.setDuration(animationTime(conf, "Duration", 800)); m_activeDecorations = !qFuzzyCompare(decoration, 1.0); m_activeMoveResize = !qFuzzyCompare(moveresize, 1.0); @@ -156,24 +149,14 @@ void TranslucencyEffect::checkIsActive() void TranslucencyEffect::prePaintWindow(EffectWindow* w, WindowPrePaintData& data, int time) { - // We keep track of the windows that was last active so we know - // which one to fade out and which ones to paint as fully inactive - if (w == active && w != current) { - previous = current; - current = w; - } - - moveresize_timeline.setCurrentTime(moveresize_timeline.currentTime() + time); - activeinactive_timeline.setCurrentTime(activeinactive_timeline.currentTime() + time); - if (m_activeDecorations && w->hasDecoration()) { data.mask |= PAINT_WINDOW_TRANSLUCENT; // don't clear PAINT_WINDOW_OPAQUE, contents are not affected data.clip &= w->contentsRect().translated(w->pos()); // decoration cannot clip } - if (m_activeInactive && (isInactive(w) || activeinactive_timeline.currentValue() < 1.0)) + if (m_activeInactive && isInactive(w)) data.setTranslucent(); - else if (m_activeMoveResize && (w->isUserMove() || w->isUserResize() || w == fadeout)) { + else if (m_activeMoveResize && (w->isUserMove() || w->isUserResize())) { data.setTranslucent(); } else if (m_activeDialogs && w->isDialog()) { @@ -198,20 +181,10 @@ void TranslucencyEffect::paintWindow(EffectWindow* w, int mask, QRegion region, // Handling active and inactive windows if (m_activeInactive && isInactive(w)) { data.opacity *= inactive; - - if (w == previous) { - data.opacity *= (inactive + ((1.0 - inactive) * (1.0 - activeinactive_timeline.currentValue()))); - if (activeinactive_timeline.currentValue() < 1.0) - w->addRepaintFull(); - else - previous = NULL; - } } else { // Fading in if (!isInactive(w)) { - data.opacity *= (inactive + ((1.0 - inactive) * activeinactive_timeline.currentValue())); - if (activeinactive_timeline.currentValue() < 1.0) - w->addRepaintFull(); + data.opacity *= inactive; } // decoration and dialogs if (m_activeDecorations && w->hasDecoration()) @@ -220,23 +193,8 @@ void TranslucencyEffect::paintWindow(EffectWindow* w, int mask, QRegion region, data.opacity *= dialogs; // Handling moving and resizing - if (m_activeMoveResize) { - double progress = moveresize_timeline.currentValue(); - if (w->isUserMove() || w->isUserResize()) { - // Fading to translucent - data.opacity *= (moveresize + ((1.0 - moveresize) * (1.0 - progress))); - if (progress < 1.0 && progress > 0.0) { - w->addRepaintFull(); - fadeout = w; - } - } else if (w == fadeout && !w->isUserMove() && !w->isUserResize()) { - // Fading back to more opaque - data.opacity *= (moveresize + ((1.0 - moveresize) * (progress))); - if (progress == 1.0 || progress == 0.0) - fadeout = NULL; - else - w->addRepaintFull(); - } + if (m_activeMoveResize && (w->isUserMove() || w->isUserResize())) { + data.opacity *= moveresize; } // Menus and combos @@ -271,7 +229,6 @@ void TranslucencyEffect::slotWindowStartStopUserMovedResized(EffectWindow* w) { if (m_activeMoveResize) { checkIsActive(); - moveresize_timeline.setCurrentTime(0); w->addRepaintFull(); } } @@ -279,7 +236,6 @@ void TranslucencyEffect::slotWindowStartStopUserMovedResized(EffectWindow* w) void TranslucencyEffect::slotWindowActivated(EffectWindow* w) { if (m_activeInactive) { - activeinactive_timeline.setCurrentTime(0); if (NULL != active && active != w) { if ((NULL == w || w->group() != active->group()) && NULL != active->group()) { diff --git a/effects/translucency/translucency.h b/effects/translucency/translucency.h index 24e528de18..c23d44c594 100644 --- a/effects/translucency/translucency.h +++ b/effects/translucency/translucency.h @@ -41,8 +41,6 @@ class TranslucencyEffect Q_PROPERTY(qreal dropDownMenus READ configuredDropDownMenus) Q_PROPERTY(qreal popupMenus READ configuredPopupMenus) Q_PROPERTY(qreal tornOffMenus READ configuredTornOffMenus) - Q_PROPERTY(int moveResizeDuration READ configuredMoveResizeDuration) - Q_PROPERTY(int activeInactiveDuration READ configuredActiveInactiveDuration) public: TranslucencyEffect(); virtual void reconfigure(ReconfigureFlags); @@ -81,12 +79,6 @@ public: qreal configuredTornOffMenus() const { return tornoffmenus; } - int configuredMoveResizeDuration() const { - return moveresize_timeline.duration(); - } - int configuredActiveInactiveDuration() const { - return activeinactive_timeline.duration(); - } public Q_SLOTS: void slotWindowActivated(KWin::EffectWindow* w); void slotWindowStartStopUserMovedResized(KWin::EffectWindow *w); @@ -108,14 +100,8 @@ private: double popupmenus; double tornoffmenus; - EffectWindow* fadeout; - EffectWindow* current; - EffectWindow* previous; EffectWindow* active; - QTimeLine moveresize_timeline; - QTimeLine activeinactive_timeline; - bool m_activeDecorations; bool m_activeMoveResize; bool m_activeDialogs; diff --git a/effects/translucency/translucency_config.cpp b/effects/translucency/translucency_config.cpp index ba711d7e59..378146097b 100644 --- a/effects/translucency/translucency_config.cpp +++ b/effects/translucency/translucency_config.cpp @@ -56,7 +56,6 @@ TranslucencyEffectConfig::TranslucencyEffectConfig(QWidget* parent, const QVaria connect(m_ui->dropdownmenus, SIGNAL(valueChanged(int)), this, SLOT(changed())); connect(m_ui->popupmenus, SIGNAL(valueChanged(int)), this, SLOT(changed())); connect(m_ui->tornoffmenus, SIGNAL(valueChanged(int)), this, SLOT(changed())); - connect(m_ui->duration, SIGNAL(valueChanged(int)), this, SLOT(changed())); load(); } @@ -76,8 +75,6 @@ void TranslucencyEffectConfig::load() m_ui->dropdownmenus->setValue((int)(conf.readEntry("DropdownMenus", 1.0) * 100)); m_ui->popupmenus->setValue((int)(conf.readEntry("PopupMenus", 1.0) * 100)); m_ui->tornoffmenus->setValue((int)(conf.readEntry("TornOffMenus", 1.0) * 100)); - m_ui->duration->setValue(conf.readEntry("Duration", 0)); - m_ui->duration->setSuffix(ki18np(" millisecond", " milliseconds")); emit changed(false); } @@ -97,7 +94,6 @@ void TranslucencyEffectConfig::save() conf.writeEntry("DropdownMenus", m_ui->dropdownmenus->value() / 100.0); conf.writeEntry("PopupMenus", m_ui->popupmenus->value() / 100.0); conf.writeEntry("TornOffMenus", m_ui->tornoffmenus->value() / 100.0); - conf.writeEntry("Duration", m_ui->duration->value()); conf.sync(); emit changed(false); @@ -116,7 +112,6 @@ void TranslucencyEffectConfig::defaults() m_ui->dropdownmenus->setValue(100); m_ui->popupmenus->setValue(100); m_ui->tornoffmenus->setValue(100); - m_ui->duration->setValue(0); emit changed(true); } diff --git a/effects/translucency/translucency_config.ui b/effects/translucency/translucency_config.ui index fd59c63b34..3c64fba9bd 100644 --- a/effects/translucency/translucency_config.ui +++ b/effects/translucency/translucency_config.ui @@ -1,296 +1,202 @@ - + + KWin::TranslucencyEffectConfigForm - - + + 0 0 - 616 - 295 + 643 + 269 - + Translucency - + - - + + General Translucency Settings - - - - - - 0 - 0 - - - - Decorations: - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - decorations - - - - - - - - 170 - 0 - - - + + + + 10 - + 100 - + Qt::Horizontal - + QSlider::TicksBelow - + 10 - - - - + + + + 0 0 - - Inactive windows: - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - inactive - - - - - - - 10 - - - 100 - - - Qt::Horizontal - - - QSlider::TicksBelow - - - 10 - - - - - - - - 0 - 0 - - - - Moving windows: - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - moveresize - - - - - - - 10 - - - 100 - - - Qt::Horizontal - - - QSlider::TicksBelow - - - 10 - - - - - - - - 0 - 0 - - - + Dialogs: - + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - + dialogs - - - - 10 - - - 100 - - - Qt::Horizontal - - - QSlider::TicksBelow - - - 10 - - - - - - - + + + + 0 0 - - Combobox popups: + + Decorations: - + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - + + decorations + + + + + + + 10 + + + 100 + + + Qt::Horizontal + + + QSlider::TicksBelow + + + 10 + + + + + + + 10 + + + 100 + + + Qt::Horizontal + + + QSlider::TicksBelow + + + 10 + + + + + + + + 0 + 0 + + + + Inactive windows: + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + inactive + + + + + + + + 0 + 0 + + + + Moving windows: + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + moveresize + + + + + + + + 0 + 0 + + + + Combobox popups: + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + comboboxpopup - - - + + + 10 - + 100 - + Qt::Horizontal - + QSlider::TicksBelow - + 10 - - - - - 0 - 0 - - - - Menus: - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - menus - - - - - - - 10 - - - 100 - - - Qt::Horizontal - - - QSlider::TicksBelow - - - 10 - - - - - - - Fading duration: - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - duration - - - - - - - - 60 - 0 - - - - Default - - - 5000 - - - 100 - - - - - - + + + Qt::Vertical - + 20 0 @@ -298,176 +204,239 @@ - - - - + + + + + 170 + 0 + + + + 10 + + + 100 + + + Qt::Horizontal + + + QSlider::TicksBelow + + + 10 + + + + + + + 10 + + + 100 + + + Qt::Horizontal + + + QSlider::TicksBelow + + + 10 + + + + + + + 0 0 - + Transparent - - - - + + + + 0 0 - + Opaque - + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + 0 + 0 + + + + Menus: + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + menus + + + - - + + Set menu translucency independently - + true - + false - - - - - + + + + + 0 0 - + Dropdown menus: - + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - + dropdownmenus - - - + + + 170 0 - + 10 - + 100 - + Qt::Horizontal - + QSlider::TicksBelow - + 10 - - - - + + + + 0 0 - + Popup menus: - + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - + popupmenus - - - + + + 10 - + 100 - + Qt::Horizontal - + QSlider::TicksBelow - + 10 - - - - + + + + 0 0 - + Torn-off menus: - + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - + tornoffmenus - - - + + + 10 - + 100 - + Qt::Horizontal - + QSlider::TicksBelow - + 10 - - - + + + Qt::Vertical - + 20 0 @@ -475,31 +444,31 @@ - - - - + + + + 0 0 - + Transparent - - - - + + + + 0 0 - + Opaque - + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter @@ -516,19 +485,11 @@ dialogs comboboxpopup menus - duration individualmenuconfig dropdownmenus popupmenus tornoffmenus - - - KIntSpinBox - QSpinBox -
knuminput.h
-
-
@@ -537,11 +498,11 @@ menus setDisabled(bool) - + 109 316 - + 212 220