From eea8200479a5d32a312d0497f76c664a61f81ef8 Mon Sep 17 00:00:00 2001 From: Vlad Zahorodnii Date: Tue, 30 May 2023 17:13:30 +0300 Subject: [PATCH] scene: Don't hide closed windows If a closed window is kept alive, it means that somebody needs to animate it and therefore it should be visible. Otherwise the window would be destroyed and its item would be removed from the scene. This change makes the WindowItem not change its visibility if the associated window is closed. If the window had been invisible before it was closed, the item would be invisible; if the window had been visible before it was closed, the item would be visible. --- src/libkwineffects/kwinanimationeffect.cpp | 2 +- src/libkwineffects/kwineffects.h | 8 +++----- src/plugins/fallapart/fallapart.cpp | 1 - src/plugins/fallapart/fallapart.h | 1 - src/plugins/glide/glide.cpp | 1 - src/plugins/glide/glide.h | 1 - src/plugins/sheet/sheet.cpp | 1 - src/plugins/sheet/sheet.h | 1 - src/plugins/slidingpopups/slidingpopups.cpp | 2 +- src/scene/windowitem.cpp | 12 ------------ src/scene/windowitem.h | 8 +++----- 11 files changed, 8 insertions(+), 30 deletions(-) diff --git a/src/libkwineffects/kwinanimationeffect.cpp b/src/libkwineffects/kwinanimationeffect.cpp index c92fc91e69..ae042897a1 100644 --- a/src/libkwineffects/kwinanimationeffect.cpp +++ b/src/libkwineffects/kwinanimationeffect.cpp @@ -258,7 +258,7 @@ quint64 AnimationEffect::p_animate(EffectWindow *w, Attribute a, uint meta, int AniData &animation = it->first.last(); animation.id = ret_id; - animation.visibleRef = EffectWindowVisibleRef(w, EffectWindow::PAINT_DISABLED_BY_MINIMIZE | EffectWindow::PAINT_DISABLED_BY_DESKTOP | EffectWindow::PAINT_DISABLED_BY_DELETE | EffectWindow::PAINT_DISABLED); + animation.visibleRef = EffectWindowVisibleRef(w, EffectWindow::PAINT_DISABLED_BY_MINIMIZE | EffectWindow::PAINT_DISABLED_BY_DESKTOP | EffectWindow::PAINT_DISABLED); animation.timeLine.setDirection(TimeLine::Forward); animation.timeLine.setDuration(std::chrono::milliseconds(ms)); animation.timeLine.setEasingCurve(curve); diff --git a/src/libkwineffects/kwineffects.h b/src/libkwineffects/kwineffects.h index 9d4056f22d..c5e0cde3d0 100644 --- a/src/libkwineffects/kwineffects.h +++ b/src/libkwineffects/kwineffects.h @@ -2295,14 +2295,12 @@ public: enum { /** Window will not be painted */ PAINT_DISABLED = 1 << 0, - /** Window will not be painted because it is deleted */ - PAINT_DISABLED_BY_DELETE = 1 << 1, /** Window will not be painted because of which desktop it's on */ - PAINT_DISABLED_BY_DESKTOP = 1 << 2, + PAINT_DISABLED_BY_DESKTOP = 1 << 1, /** Window will not be painted because it is minimized */ - PAINT_DISABLED_BY_MINIMIZE = 1 << 3, + PAINT_DISABLED_BY_MINIMIZE = 1 << 2, /** Window will not be painted because it's not on the current activity */ - PAINT_DISABLED_BY_ACTIVITY = 1 << 4 + PAINT_DISABLED_BY_ACTIVITY = 1 << 3, }; explicit EffectWindow(); diff --git a/src/plugins/fallapart/fallapart.cpp b/src/plugins/fallapart/fallapart.cpp index 08a861b968..c225041428 100644 --- a/src/plugins/fallapart/fallapart.cpp +++ b/src/plugins/fallapart/fallapart.cpp @@ -179,7 +179,6 @@ void FallApartEffect::slotWindowClosed(EffectWindow *c) FallApartAnimation &animation = windows[c]; animation.progress = 0; animation.deletedRef = EffectWindowDeletedRef(c); - animation.visibleRef = EffectWindowVisibleRef(c, EffectWindow::PAINT_DISABLED_BY_DELETE); redirect(c); } diff --git a/src/plugins/fallapart/fallapart.h b/src/plugins/fallapart/fallapart.h index 745038f56f..16a389a386 100644 --- a/src/plugins/fallapart/fallapart.h +++ b/src/plugins/fallapart/fallapart.h @@ -17,7 +17,6 @@ namespace KWin struct FallApartAnimation { EffectWindowDeletedRef deletedRef; - EffectWindowVisibleRef visibleRef; std::chrono::milliseconds lastPresentTime = std::chrono::milliseconds::zero(); qreal progress = 0; }; diff --git a/src/plugins/glide/glide.cpp b/src/plugins/glide/glide.cpp index 784fc114ad..e4aab50214 100644 --- a/src/plugins/glide/glide.cpp +++ b/src/plugins/glide/glide.cpp @@ -274,7 +274,6 @@ void GlideEffect::windowClosed(EffectWindow *w) GlideAnimation &animation = m_animations[w]; animation.deletedRef = EffectWindowDeletedRef(w); - animation.visibleRef = EffectWindowVisibleRef(w, EffectWindow::PAINT_DISABLED_BY_DELETE); animation.timeLine.reset(); animation.timeLine.setDirection(TimeLine::Forward); animation.timeLine.setDuration(m_duration); diff --git a/src/plugins/glide/glide.h b/src/plugins/glide/glide.h index d8c117b334..a5748d3401 100644 --- a/src/plugins/glide/glide.h +++ b/src/plugins/glide/glide.h @@ -21,7 +21,6 @@ namespace KWin struct GlideAnimation { EffectWindowDeletedRef deletedRef; - EffectWindowVisibleRef visibleRef; TimeLine timeLine; }; diff --git a/src/plugins/sheet/sheet.cpp b/src/plugins/sheet/sheet.cpp index 687fb5e602..7a30d36a8f 100644 --- a/src/plugins/sheet/sheet.cpp +++ b/src/plugins/sheet/sheet.cpp @@ -206,7 +206,6 @@ void SheetEffect::slotWindowClosed(EffectWindow *w) Animation &animation = m_animations[w]; animation.deletedRef = EffectWindowDeletedRef(w); - animation.visibleRef = EffectWindowVisibleRef(w, EffectWindow::PAINT_DISABLED_BY_DELETE); animation.timeLine.reset(); animation.parentY = 0; animation.timeLine.setDuration(m_duration); diff --git a/src/plugins/sheet/sheet.h b/src/plugins/sheet/sheet.h index 56f0ba79ab..8208aabc6c 100644 --- a/src/plugins/sheet/sheet.h +++ b/src/plugins/sheet/sheet.h @@ -52,7 +52,6 @@ private: struct Animation { EffectWindowDeletedRef deletedRef; - EffectWindowVisibleRef visibleRef; TimeLine timeLine; int parentY; }; diff --git a/src/plugins/slidingpopups/slidingpopups.cpp b/src/plugins/slidingpopups/slidingpopups.cpp index 5f850ecbf5..6f20894d98 100644 --- a/src/plugins/slidingpopups/slidingpopups.cpp +++ b/src/plugins/slidingpopups/slidingpopups.cpp @@ -543,7 +543,7 @@ void SlidingPopupsEffect::slideOut(EffectWindow *w) if (w->isDeleted()) { animation.deletedRef = EffectWindowDeletedRef(w); } - animation.visibleRef = EffectWindowVisibleRef(w, EffectWindow::PAINT_DISABLED | EffectWindow::PAINT_DISABLED_BY_DELETE); + animation.visibleRef = EffectWindowVisibleRef(w, EffectWindow::PAINT_DISABLED); animation.kind = AnimationKind::Out; animation.timeLine.setDirection(TimeLine::Backward); animation.timeLine.setDuration((*dataIt).slideOutDuration); diff --git a/src/scene/windowitem.cpp b/src/scene/windowitem.cpp index 4dd3b939e7..cc72d6dc74 100644 --- a/src/scene/windowitem.cpp +++ b/src/scene/windowitem.cpp @@ -84,9 +84,6 @@ void WindowItem::refVisible(int reason) if (reason & PAINT_DISABLED_BY_HIDDEN) { m_forceVisibleByHiddenCount++; } - if (reason & PAINT_DISABLED_BY_DELETE) { - m_forceVisibleByDeleteCount++; - } if (reason & PAINT_DISABLED_BY_DESKTOP) { m_forceVisibleByDesktopCount++; } @@ -105,10 +102,6 @@ void WindowItem::unrefVisible(int reason) Q_ASSERT(m_forceVisibleByHiddenCount > 0); m_forceVisibleByHiddenCount--; } - if (reason & PAINT_DISABLED_BY_DELETE) { - Q_ASSERT(m_forceVisibleByDeleteCount > 0); - m_forceVisibleByDeleteCount--; - } if (reason & PAINT_DISABLED_BY_DESKTOP) { Q_ASSERT(m_forceVisibleByDesktopCount > 0); m_forceVisibleByDesktopCount--; @@ -150,11 +143,6 @@ bool WindowItem::computeVisibility() const if (waylandServer() && waylandServer()->isScreenLocked()) { return m_window->isLockScreen() || m_window->isInputMethod() || m_window->isLockScreenOverlay(); } - if (m_window->isDeleted()) { - if (m_forceVisibleByDeleteCount == 0) { - return false; - } - } if (!m_window->isOnCurrentDesktop()) { if (m_forceVisibleByDesktopCount == 0) { return false; diff --git a/src/scene/windowitem.h b/src/scene/windowitem.h index 414f931f12..0a992a39c7 100644 --- a/src/scene/windowitem.h +++ b/src/scene/windowitem.h @@ -36,10 +36,9 @@ class KWIN_EXPORT WindowItem : public Item public: enum { PAINT_DISABLED_BY_HIDDEN = 1 << 0, - PAINT_DISABLED_BY_DELETE = 1 << 1, - PAINT_DISABLED_BY_DESKTOP = 1 << 2, - PAINT_DISABLED_BY_MINIMIZE = 1 << 3, - PAINT_DISABLED_BY_ACTIVITY = 1 << 4 + PAINT_DISABLED_BY_DESKTOP = 1 << 1, + PAINT_DISABLED_BY_MINIMIZE = 1 << 2, + PAINT_DISABLED_BY_ACTIVITY = 1 << 3, }; ~WindowItem() override; @@ -80,7 +79,6 @@ private: std::unique_ptr m_shadowItem; std::optional m_elevation; int m_forceVisibleByHiddenCount = 0; - int m_forceVisibleByDeleteCount = 0; int m_forceVisibleByDesktopCount = 0; int m_forceVisibleByMinimizeCount = 0; int m_forceVisibleByActivityCount = 0;