[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
This commit is contained in:
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); reconfigure(ReconfigureAll);
connect(effects, SIGNAL(windowClosed(KWin::EffectWindow*)), this, SLOT(slotWindowClosed(KWin::EffectWindow*))); 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(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) void FallApartEffect::reconfigure(ReconfigureFlags)
@ -157,6 +158,7 @@ void FallApartEffect::slotWindowClosed(EffectWindow* c)
const void* e = c->data(WindowClosedGrabRole).value<void*>(); const void* e = c->data(WindowClosedGrabRole).value<void*>();
if (e && e != this) if (e && e != this)
return; return;
c->setData(WindowClosedGrabRole, QVariant::fromValue(static_cast<void*>(this)));
windows[ c ] = 0; windows[ c ] = 0;
c->refWindow(); c->refWindow();
} }
@ -166,6 +168,25 @@ void FallApartEffect::slotWindowDeleted(EffectWindow* c)
windows.remove(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 bool FallApartEffect::isActive() const
{ {
return !windows.isEmpty(); return !windows.isEmpty();

View file

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