diff --git a/autotests/integration/scene_opengl_shadow_test.cpp b/autotests/integration/scene_opengl_shadow_test.cpp index 7ef0e98482..876562f8dd 100644 --- a/autotests/integration/scene_opengl_shadow_test.cpp +++ b/autotests/integration/scene_opengl_shadow_test.cpp @@ -34,7 +34,9 @@ #include "effects.h" #include "platform.h" #include "shadow.h" +#include "shadowitem.h" #include "wayland_server.h" +#include "windowitem.h" #include "workspace.h" Q_DECLARE_METATYPE(KWin::WindowQuadList); @@ -638,8 +640,8 @@ void SceneOpenGLShadowTest::testShadowTileOverlaps() // Get shadow. QVERIFY(client->effectWindow()); QVERIFY(client->effectWindow()->sceneWindow()); - QVERIFY(client->effectWindow()->sceneWindow()->shadow()); - auto *shadow = client->effectWindow()->sceneWindow()->shadow(); + auto *shadow = client->windowItem()->shadowItem()->shadow(); + QVERIFY(shadow); // Validate shadow quads. const WindowQuadList &quads = shadow->shadowQuads(); @@ -730,7 +732,7 @@ void SceneOpenGLShadowTest::testNoCornerShadowTiles() QVERIFY(client->effectWindow()); QVERIFY(client->effectWindow()->sceneWindow()); - KWin::Shadow *shadow = client->effectWindow()->sceneWindow()->shadow(); + KWin::Shadow *shadow = client->windowItem()->shadowItem()->shadow(); QVERIFY(shadow != nullptr); const WindowQuadList &quads = shadow->shadowQuads(); @@ -810,7 +812,7 @@ void SceneOpenGLShadowTest::testDistributeHugeCornerTiles() QVERIFY(client->effectWindow()); QVERIFY(client->effectWindow()->sceneWindow()); - KWin::Shadow *shadow = client->effectWindow()->sceneWindow()->shadow(); + KWin::Shadow *shadow = client->windowItem()->shadowItem()->shadow(); QVERIFY(shadow != nullptr); WindowQuadList expectedQuads; diff --git a/autotests/integration/scene_qpainter_shadow_test.cpp b/autotests/integration/scene_qpainter_shadow_test.cpp index 8e0a9d7699..7c6509e800 100644 --- a/autotests/integration/scene_qpainter_shadow_test.cpp +++ b/autotests/integration/scene_qpainter_shadow_test.cpp @@ -39,7 +39,9 @@ #include "platform.h" #include "plugins/scenes/qpainter/scene_qpainter.h" #include "shadow.h" +#include "shadowitem.h" #include "wayland_server.h" +#include "windowitem.h" #include "workspace.h" Q_DECLARE_METATYPE(KWin::WindowQuadList) @@ -642,8 +644,8 @@ void SceneQPainterShadowTest::testShadowTileOverlaps() // Get shadow. QVERIFY(client->effectWindow()); QVERIFY(client->effectWindow()->sceneWindow()); - QVERIFY(client->effectWindow()->sceneWindow()->shadow()); - auto *shadow = client->effectWindow()->sceneWindow()->shadow(); + auto *shadow = client->windowItem()->shadowItem()->shadow(); + QVERIFY(shadow); // Validate shadow quads. const WindowQuadList &quads = shadow->shadowQuads(); @@ -756,8 +758,8 @@ void SceneQPainterShadowTest::testShadowTextureReconstruction() // Get SceneQPainterShadow's texture. QVERIFY(client->effectWindow()); QVERIFY(client->effectWindow()->sceneWindow()); - QVERIFY(client->effectWindow()->sceneWindow()->shadow()); - auto &shadowTexture = static_cast(client->effectWindow()->sceneWindow()->shadow())->shadowTexture(); + auto *shadow = client->windowItem()->shadowItem()->shadow(); + auto &shadowTexture = static_cast(shadow)->shadowTexture(); QCOMPARE(shadowTexture, referenceShadowTexture); } diff --git a/src/plugins/scenes/qpainter/scene_qpainter.cpp b/src/plugins/scenes/qpainter/scene_qpainter.cpp index 6dd0a43750..e7e023a7ec 100644 --- a/src/plugins/scenes/qpainter/scene_qpainter.cpp +++ b/src/plugins/scenes/qpainter/scene_qpainter.cpp @@ -17,10 +17,12 @@ #include "main.h" #include "renderloop.h" #include "screens.h" +#include "shadowitem.h" #include "surfaceitem.h" #include "toplevel.h" #include "platform.h" #include "wayland_server.h" +#include "windowitem.h" #include @@ -287,10 +289,11 @@ void SceneQPainter::Window::renderSurfaceItem(QPainter *painter, SurfaceItem *su void SceneQPainter::Window::renderShadow(QPainter* painter) { - if (!toplevel->shadow()) { + const ShadowItem *shadowItem = windowItem()->shadowItem(); + if (!shadowItem) { return; } - SceneQPainterShadow *shadow = static_cast(toplevel->shadow()); + SceneQPainterShadow *shadow = static_cast(shadowItem->shadow()); const QImage &shadowTexture = shadow->shadowTexture(); const WindowQuadList &shadowQuads = shadow->shadowQuads(); diff --git a/src/scene.cpp b/src/scene.cpp index 4f64bea720..a349f56d15 100644 --- a/src/scene.cpp +++ b/src/scene.cpp @@ -470,7 +470,6 @@ void Scene::addToplevel(Toplevel *c) c->effectWindow()->setSceneWindow(w); c->updateShadow(); - w->updateShadow(c->shadow()); } void Scene::removeToplevel(Toplevel *toplevel) @@ -490,8 +489,8 @@ void Scene::windowClosed(Toplevel *toplevel, Deleted *deleted) Q_ASSERT(m_windows.contains(toplevel)); Window *window = m_windows.take(toplevel); window->updateToplevel(deleted); - if (window->shadow()) { - window->shadow()->setToplevel(deleted); + if (window->shadowItem()) { + window->shadowItem()->shadow()->setToplevel(deleted); } m_windows[deleted] = window; } @@ -1056,27 +1055,6 @@ void Scene::Window::discardQuads() cached_quad_list.reset(); } -const Shadow *Scene::Window::shadow() const -{ - if (shadowItem()) { - return shadowItem()->shadow(); - } - return nullptr; -} - -Shadow *Scene::Window::shadow() -{ - if (shadowItem()) { - return shadowItem()->shadow(); - } - return nullptr; -} - -void Scene::Window::updateShadow(Shadow* shadow) -{ - m_windowItem->setShadow(shadow); -} - void Scene::Window::preprocess(Item *item) { item->preprocess(); diff --git a/src/scene.h b/src/scene.h index 2a7dc42832..7e1d51c4b5 100644 --- a/src/scene.h +++ b/src/scene.h @@ -350,9 +350,6 @@ public: void updateToplevel(Deleted *deleted); // creates initial quad list for the window virtual WindowQuadList buildQuads(bool force = false) const; - void updateShadow(Shadow* shadow); - const Shadow* shadow() const; - Shadow* shadow(); void referencePreviousPixmap(); void unreferencePreviousPixmap(); void discardQuads(); diff --git a/src/shadow.cpp b/src/shadow.cpp index 85d5167994..671bae7326 100644 --- a/src/shadow.cpp +++ b/src/shadow.cpp @@ -12,8 +12,8 @@ #include "atoms.h" #include "abstract_client.h" #include "composite.h" -#include "effects.h" #include "internal_client.h" +#include "scene.h" #include "toplevel.h" #include "wayland_server.h" @@ -45,9 +45,6 @@ Shadow::~Shadow() Shadow *Shadow::createShadow(Toplevel *toplevel) { - if (!effects) { - return nullptr; - } Shadow *shadow = createShadowFromDecoration(toplevel); if (!shadow && waylandServer()) { shadow = createShadowFromWayland(toplevel); @@ -58,13 +55,6 @@ Shadow *Shadow::createShadow(Toplevel *toplevel) if (!shadow) { shadow = createShadowFromInternalWindow(toplevel); } - if (!shadow) { - return nullptr; - } - if (toplevel->effectWindow() && toplevel->effectWindow()->sceneWindow()) { - toplevel->effectWindow()->sceneWindow()->updateShadow(shadow); - emit toplevel->shadowChanged(); - } return shadow; } diff --git a/src/toplevel.cpp b/src/toplevel.cpp index 952363c0e1..f822e05820 100644 --- a/src/toplevel.cpp +++ b/src/toplevel.cpp @@ -19,6 +19,7 @@ #include "effects.h" #include "screens.h" #include "shadow.h" +#include "shadowitem.h" #include "windowitem.h" #include "workspace.h" @@ -427,31 +428,21 @@ bool Toplevel::isOnOutput(AbstractOutput *output) const void Toplevel::updateShadow() { - if (shadow()) { - if (!effectWindow()->sceneWindow()->shadow()->updateShadow()) { - effectWindow()->sceneWindow()->updateShadow(nullptr); + WindowItem *windowItem = this->windowItem(); + if (!windowItem) { + return; + } + if (auto shadowItem = windowItem->shadowItem()) { + if (!shadowItem->shadow()->updateShadow()) { + windowItem->setShadow(nullptr); } emit shadowChanged(); } else { - Shadow::createShadow(this); - } -} - -Shadow *Toplevel::shadow() -{ - if (effectWindow() && effectWindow()->sceneWindow()) { - return effectWindow()->sceneWindow()->shadow(); - } else { - return nullptr; - } -} - -const Shadow *Toplevel::shadow() const -{ - if (effectWindow() && effectWindow()->sceneWindow()) { - return effectWindow()->sceneWindow()->shadow(); - } else { - return nullptr; + Shadow *shadow = Shadow::createShadow(this); + if (shadow) { + windowItem->setShadow(shadow); + emit shadowChanged(); + } } } diff --git a/src/toplevel.h b/src/toplevel.h index e6e41aee08..02ce5b7518 100644 --- a/src/toplevel.h +++ b/src/toplevel.h @@ -463,14 +463,6 @@ public: */ void elevate(bool elevate); - /** - * Returns the pointer to the Toplevel's Shadow. A Shadow - * is only available if Compositing is enabled and the corresponding X window - * has the Shadow property set. - * @returns The Shadow belonging to this Toplevel, @c null if there's no Shadow. - */ - const Shadow *shadow() const; - Shadow *shadow(); /** * Updates the Shadow associated with this Toplevel from X11 Property. * Call this method when the Property changes or Compositing is started.