From 207bc1d9e65b123f3f48ff94daa5117d0521cb02 Mon Sep 17 00:00:00 2001 From: Vlad Zahorodnii Date: Sat, 9 Dec 2023 14:44:11 +0200 Subject: [PATCH] scene: Introduce WorkspaceScene::overlayItem The overlay item is the parent for all overlay contents above windows. --- src/scene/workspacescene.cpp | 29 +++++++++++++++++------------ src/scene/workspacescene.h | 2 ++ 2 files changed, 19 insertions(+), 12 deletions(-) diff --git a/src/scene/workspacescene.cpp b/src/scene/workspacescene.cpp index 0c629b5151..c2b3d14f2a 100644 --- a/src/scene/workspacescene.cpp +++ b/src/scene/workspacescene.cpp @@ -86,6 +86,7 @@ namespace KWin WorkspaceScene::WorkspaceScene(std::unique_ptr renderer) : Scene(std::move(renderer)) , m_containerItem(std::make_unique(this)) + , m_overlayItem(std::make_unique(this)) { setGeometry(workspace()->geometry()); connect(workspace(), &Workspace::geometryChanged, this, [this]() { @@ -108,7 +109,7 @@ void WorkspaceScene::createDndIconItem() if (!dragIcon) { return; } - m_dndIcon = std::make_unique(dragIcon, this); + m_dndIcon = std::make_unique(dragIcon, this, m_overlayItem.get()); if (waylandServer()->seat()->isDragPointer()) { auto updatePosition = [this]() { const auto pointerPos = waylandServer()->seat()->pointerPos(); @@ -140,6 +141,11 @@ Item *WorkspaceScene::containerItem() const return m_containerItem.get(); } +Item *WorkspaceScene::overlayItem() const +{ + return m_overlayItem.get(); +} + static SurfaceItem *findTopMostSurface(SurfaceItem *item) { const QList children = item->childItems(); @@ -305,6 +311,7 @@ void WorkspaceScene::preparePaintGenericScreen() }); } + resetRepaintsHelper(m_overlayItem.get(), painted_delegate); m_paintContext.damage = infiniteRegion(); } @@ -348,9 +355,7 @@ void WorkspaceScene::preparePaintSimpleScreen() } } - if (m_dndIcon) { - accumulateRepaints(m_dndIcon.get(), painted_delegate, &m_paintContext.damage); - } + accumulateRepaints(m_overlayItem.get(), painted_delegate, &m_paintContext.damage); } void WorkspaceScene::postPaint() @@ -373,8 +378,15 @@ void WorkspaceScene::paint(const RenderTarget &renderTarget, const QRegion ®i effects->paintScreen(renderTarget, viewport, m_paintContext.mask, region, painted_screen); m_paintScreenCount = 0; - Q_EMIT frameRendered(); + if (m_overlayItem) { + const QRegion repaint = region & m_overlayItem->mapToScene(m_overlayItem->boundingRect()).toRect(); + if (!repaint.isEmpty()) { + m_renderer->renderItem(renderTarget, viewport, m_overlayItem.get(), 0, repaint, WindowPaintData{}); + } + } + + Q_EMIT frameRendered(); m_renderer->endFrame(); } @@ -431,13 +443,6 @@ void WorkspaceScene::paintSimpleScreen(const RenderTarget &renderTarget, const R for (const Phase2Data &paintData : std::as_const(m_paintContext.phase2Data)) { paintWindow(renderTarget, viewport, paintData.item, paintData.mask, paintData.region); } - - if (m_dndIcon) { - const QRegion repaint = region & m_dndIcon->mapToScene(m_dndIcon->boundingRect()).toRect(); - if (!repaint.isEmpty()) { - m_renderer->renderItem(renderTarget, viewport, m_dndIcon.get(), 0, repaint, WindowPaintData{}); - } - } } void WorkspaceScene::createStackingOrder() diff --git a/src/scene/workspacescene.h b/src/scene/workspacescene.h index a25805516f..11f9c1872f 100644 --- a/src/scene/workspacescene.h +++ b/src/scene/workspacescene.h @@ -46,6 +46,7 @@ public: void initialize(); Item *containerItem() const; + Item *overlayItem() const; SurfaceItem *scanoutCandidate() const override; QRegion prePaint(SceneDelegate *delegate) override; @@ -129,6 +130,7 @@ private: int m_paintScreenCount = 0; PaintContext m_paintContext; std::unique_ptr m_containerItem; + std::unique_ptr m_overlayItem; std::unique_ptr m_dndIcon; };