From 2d88fd0ee3136e19d6b5285f3c411f6667569d70 Mon Sep 17 00:00:00 2001 From: Vlad Zahorodnii Date: Tue, 21 Apr 2020 12:11:41 +0300 Subject: [PATCH] [scene] Release previous pixmap when a raster buffer is attached We need to release the previous window pixmap if the new pixmap is valid. However, it's currently the case only when the client has attached either an fbo buffer or a wl_buffer. If an internal client has attached a raster buffer, the previous window pixmap won't be released. In order to ensure that we're going to release the previous window pixmaps no matter what type of buffer has been attached, this change refactors WindowPixmap to use isValid() to verify that the new window pixmap is valid. Differential Revision: https://phabricator.kde.org/D29131 --- scene.cpp | 7 ++++++- scene.h | 4 ++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/scene.cpp b/scene.cpp index 2ab7d55e27..22d09eaeb0 100644 --- a/scene.cpp +++ b/scene.cpp @@ -1078,7 +1078,7 @@ void WindowPixmap::create() if (kwinApp()->shouldUseWaylandForCompositing()) { // use Buffer update(); - if ((m_buffer || !m_fbo.isNull()) && m_subSurface.isNull()) { + if (!isRoot() && isValid()) { m_window->unreferencePreviousPixmap(); } return; @@ -1185,6 +1185,11 @@ bool WindowPixmap::isValid() const return m_pixmap != XCB_PIXMAP_NONE; } +bool WindowPixmap::isRoot() const +{ + return !m_parent; +} + KWaylandServer::SurfaceInterface *WindowPixmap::surface() const { if (!m_subSurface.isNull()) { diff --git a/scene.h b/scene.h index b5a4e21f8b..635570f38e 100644 --- a/scene.h +++ b/scene.h @@ -424,6 +424,10 @@ public: * @return @c true if the pixmap has been created and is valid, @c false otherwise */ virtual bool isValid() const; + /** + * Returns @c true if this is the root window pixmap; otherwise returns @c false. + */ + bool isRoot() const; /** * @return The native X11 pixmap handle */