From 43a9add5fec388c9f06363b624768dae3b669a02 Mon Sep 17 00:00:00 2001 From: Xaver Hugl Date: Fri, 3 Mar 2023 14:56:00 +0100 Subject: [PATCH] windowitem: properly handle sub-subsurfaces The damage of the whole subsurface tree needs to be considered, not just the topmost subsurfaces of a window. BUG: 466747 --- src/scene/windowitem.cpp | 18 ++++++++++++------ src/scene/windowitem.h | 1 + 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/src/scene/windowitem.cpp b/src/scene/windowitem.cpp index f11b641fa9..28373bb5b0 100644 --- a/src/scene/windowitem.cpp +++ b/src/scene/windowitem.cpp @@ -176,6 +176,17 @@ void WindowItem::updatePosition() setPosition(m_window->pos()); } +void WindowItem::addSurfaceItemDamageConnects(Item *item) +{ + auto surfaceItem = static_cast(item); + connect(surfaceItem, &SurfaceItem::damaged, this, &WindowItem::markDamaged); + connect(surfaceItem, &SurfaceItem::childAdded, this, &WindowItem::addSurfaceItemDamageConnects); + const auto childItems = item->childItems(); + for (const auto &child : childItems) { + addSurfaceItemDamageConnects(child); + } +} + void WindowItem::updateSurfaceItem(SurfaceItem *surfaceItem) { m_surfaceItem.reset(surfaceItem); @@ -184,12 +195,7 @@ void WindowItem::updateSurfaceItem(SurfaceItem *surfaceItem) connect(m_window, &Window::shadeChanged, this, &WindowItem::updateSurfaceVisibility); connect(m_window, &Window::bufferGeometryChanged, this, &WindowItem::updateSurfacePosition); connect(m_window, &Window::frameGeometryChanged, this, &WindowItem::updateSurfacePosition); - - connect(surfaceItem, &SurfaceItem::damaged, this, &WindowItem::markDamaged); - connect(surfaceItem, &SurfaceItem::childAdded, this, [this](Item *item) { - auto surfaceItem = static_cast(item); - connect(surfaceItem, &SurfaceItem::damaged, this, &WindowItem::markDamaged); - }); + addSurfaceItemDamageConnects(surfaceItem); updateSurfacePosition(); updateSurfaceVisibility(); diff --git a/src/scene/windowitem.h b/src/scene/windowitem.h index 9beaa7807f..329388a33d 100644 --- a/src/scene/windowitem.h +++ b/src/scene/windowitem.h @@ -65,6 +65,7 @@ private Q_SLOTS: void updatePosition(); void updateOpacity(); void updateStackingOrder(); + void addSurfaceItemDamageConnects(Item *item); private: bool computeVisibility() const;