From 5a98d8bbbdedb7e5db10a37dfbd556b4a4fc4628 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Gr=C3=A4=C3=9Flin?= Date: Mon, 1 Jun 2015 16:25:21 +0200 Subject: [PATCH] [wayland] Set depth in ShellClient depending on whether the Buffer has alpha We need to set the depth in order to properly determine whether the Surface has an alpha channel and whether blending needs to be enabled for rendering. For this a new method is introduced in Toplevel to set the depth. If the depth changed in a way that the Toplevel gained or lost the alpha channel a signal is emitted which implies that the hasAlpha property of Toplevel is no longer constant. --- shell_client.cpp | 1 + toplevel.cpp | 13 +++++++++++++ toplevel.h | 7 ++++++- 3 files changed, 20 insertions(+), 1 deletion(-) diff --git a/shell_client.cpp b/shell_client.cpp index 9c75487f7e..c9b3c94645 100644 --- a/shell_client.cpp +++ b/shell_client.cpp @@ -165,6 +165,7 @@ void ShellClient::addDamage(const QRegion &damage) } setGeometry(QRect(position, m_clientSize)); } + setDepth(m_shellSurface->surface()->buffer()->hasAlphaChannel() ? 32 : 24); setReadyForPainting(); Toplevel::addDamage(damage); } diff --git a/toplevel.cpp b/toplevel.cpp index 48724cbee4..8f80323e82 100644 --- a/toplevel.cpp +++ b/toplevel.cpp @@ -42,6 +42,7 @@ namespace KWin Toplevel::Toplevel() : m_visual(XCB_NONE) + , bit_depth(24) , info(NULL) , ready_for_painting(true) , m_isDamaged(false) @@ -475,6 +476,18 @@ QByteArray Toplevel::windowRole() const return QByteArray(info->windowRole()); } +void Toplevel::setDepth(int depth) +{ + if (bit_depth == depth) { + return; + } + const bool oldAlpha = hasAlpha(); + bit_depth = depth; + if (oldAlpha != hasAlpha()) { + emit hasAlphaChanged(); + } +} + } // namespace #include "toplevel.moc" diff --git a/toplevel.h b/toplevel.h index ea21734546..3aea1bc0c3 100644 --- a/toplevel.h +++ b/toplevel.h @@ -71,7 +71,7 @@ class Toplevel : public QObject { Q_OBJECT - Q_PROPERTY(bool alpha READ hasAlpha CONSTANT) + Q_PROPERTY(bool alpha READ hasAlpha NOTIFY hasAlphaChanged) Q_PROPERTY(qulonglong frameId READ frameId) Q_PROPERTY(QRect geometry READ geometry NOTIFY geometryChanged) Q_PROPERTY(QRect visibleRect READ visibleRect) @@ -414,6 +414,10 @@ Q_SIGNALS: * @since 5.3 **/ void surfaceIdChanged(quint32); + /** + * @since 5.4 + **/ + void hasAlphaChanged(); protected Q_SLOTS: /** @@ -460,6 +464,7 @@ protected: friend QDebug& operator<<(QDebug& stream, const Toplevel*); void deleteEffectWindow(); virtual bool shouldUnredirect() const = 0; + void setDepth(int depth); QRect geom; xcb_visualid_t m_visual; int bit_depth;