[effects/fallapart] Fix flickering problem

Summary:
The Fall Apart effect doesn't grab windows so a conflict could happen
if an alternative window open/close animation effect is enabled(e.g.
Fade, Glide).

### Before

{F5912324}

//Fall apart and Fade conflict with each other.//

### After

{F5912325}

//Only Fall apart animates the disappearing of System Settings.//

Test Plan:
* Enabled fall apart effect and fade effect
* Closed a window

Reviewers: #kwin, davidedmundson

Reviewed By: #kwin, davidedmundson

Subscribers: kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D13527
icc-effect-5.14.5
Vlad Zagorodniy 2018-06-14 12:04:35 +03:00
parent 3e2ff0e870
commit 5daa612bce
2 changed files with 23 additions and 1 deletions

View File

@ -38,6 +38,7 @@ FallApartEffect::FallApartEffect()
reconfigure(ReconfigureAll);
connect(effects, SIGNAL(windowClosed(KWin::EffectWindow*)), this, SLOT(slotWindowClosed(KWin::EffectWindow*)));
connect(effects, SIGNAL(windowDeleted(KWin::EffectWindow*)), this, SLOT(slotWindowDeleted(KWin::EffectWindow*)));
connect(effects, SIGNAL(windowDataChanged(KWin::EffectWindow*,int)), this, SLOT(slotWindowDataChanged(KWin::EffectWindow*,int)));
}
void FallApartEffect::reconfigure(ReconfigureFlags)
@ -157,6 +158,7 @@ void FallApartEffect::slotWindowClosed(EffectWindow* c)
const void* e = c->data(WindowClosedGrabRole).value<void*>();
if (e && e != this)
return;
c->setData(WindowClosedGrabRole, QVariant::fromValue(static_cast<void*>(this)));
windows[ c ] = 0;
c->refWindow();
}
@ -166,6 +168,25 @@ void FallApartEffect::slotWindowDeleted(EffectWindow* c)
windows.remove(c);
}
void FallApartEffect::slotWindowDataChanged(EffectWindow* w, int role)
{
if (role != WindowClosedGrabRole) {
return;
}
if (w->data(role).value<void*>() == this) {
return;
}
auto it = windows.find(w);
if (it == windows.end()) {
return;
}
it.key()->unrefWindow();
windows.erase(it);
}
bool FallApartEffect::isActive() const
{
return !windows.isEmpty();

View File

@ -54,9 +54,10 @@ public:
public Q_SLOTS:
void slotWindowClosed(KWin::EffectWindow *c);
void slotWindowDeleted(KWin::EffectWindow *w);
void slotWindowDataChanged(KWin::EffectWindow *w, int role);
private:
QHash< const EffectWindow*, double > windows;
QHash< EffectWindow*, double > windows;
bool isRealWindow(EffectWindow* w);
int blockSize;
};