Commit 1725e224 authored by Vlad Zahorodnii's avatar Vlad Zahorodnii
Browse files

effects/slide: Ensure that there's only one visibility ref per window

If a window is added and then the current virtual desktop changes, we
can encounter the following situation:

 * desktopChanged signal is emitted, and the slide effect starts
   animation. SlideEffect::prepareSwitching() will setup windows; note
   that the new window may be present in effects->stackingOrder()
 * windowAdded signal is emitted, and slide effect tries to ref the
   window again

In order to ensure that there's only one reference, maintain visibility
refs in a hashtable.

BUG: 455237
parent 58da3aff
Pipeline #191210 passed with stage
in 15 minutes and 9 seconds
......@@ -368,12 +368,17 @@ void SlideEffect::startAnimation(int old, int current, EffectWindow *movingWindo
void SlideEffect::prepareSwitching()
{
const auto windows = effects->stackingOrder();
m_windowData.reserve(windows.count());
for (EffectWindow *w : windows) {
m_windowData[w] = WindowData{
.visibilityRef = EffectWindowVisibleRef(w, EffectWindow::PAINT_DISABLED_BY_DESKTOP),
};
if (shouldElevate(w)) {
effects->setElevatedWindow(w, true);
m_elevatedWindows << w;
}
w->refVisible(EffectWindow::PAINT_DISABLED_BY_DESKTOP);
w->setData(WindowForceBackgroundContrastRole, QVariant(true));
w->setData(WindowForceBlurRole, QVariant(true));
}
......@@ -386,7 +391,6 @@ void SlideEffect::finishedSwitching()
}
const EffectWindowList windows = effects->stackingOrder();
for (EffectWindow *w : windows) {
w->unrefVisible(EffectWindow::PAINT_DISABLED_BY_DESKTOP);
w->setData(WindowForceBackgroundContrastRole, QVariant());
w->setData(WindowForceBlurRole, QVariant());
}
......@@ -396,6 +400,7 @@ void SlideEffect::finishedSwitching()
}
m_elevatedWindows.clear();
m_windowData.clear();
m_paintCtx.fullscreenWindows.clear();
m_movingWindow = nullptr;
m_state = State::Inactive;
......@@ -477,9 +482,12 @@ void SlideEffect::windowAdded(EffectWindow *w)
effects->setElevatedWindow(w, true);
m_elevatedWindows << w;
}
w->refVisible(EffectWindow::PAINT_DISABLED_BY_DESKTOP);
w->setData(WindowForceBackgroundContrastRole, QVariant(true));
w->setData(WindowForceBlurRole, QVariant(true));
m_windowData[w] = WindowData{
.visibilityRef = EffectWindowVisibleRef(w, EffectWindow::PAINT_DISABLED_BY_DESKTOP),
};
}
void SlideEffect::windowDeleted(EffectWindow *w)
......@@ -491,6 +499,7 @@ void SlideEffect::windowDeleted(EffectWindow *w)
m_movingWindow = nullptr;
}
m_elevatedWindows.removeAll(w);
m_windowData.remove(w);
m_paintCtx.fullscreenWindows.removeAll(w);
}
......
......@@ -133,7 +133,13 @@ private:
EffectWindowList fullscreenWindows;
} m_paintCtx;
struct WindowData
{
EffectWindowVisibleRef visibilityRef;
};
EffectWindowList m_elevatedWindows;
QHash<EffectWindow *, WindowData> m_windowData;
};
inline int SlideEffect::horizontalGap() const
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment