From 060b3100826f7eab9ba988af31c433e66755ea4e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Gr=C3=A4=C3=9Flin?= Date: Fri, 12 Dec 2014 22:12:11 +0100 Subject: [PATCH] [aurorae] Do not update shadow from ::paint Paint is in the middle of the compositor rendering loop. Updating the shadow at that point breaks KWin. Thus we delay the update to the next event cycle. Obviously it would be even better to only update the shadow if it changed, but that might be too expensive. --- clients/aurorae/src/aurorae.cpp | 10 ++++++++-- clients/aurorae/src/aurorae.h | 3 +++ 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/clients/aurorae/src/aurorae.cpp b/clients/aurorae/src/aurorae.cpp index 664ee42bda..70b31b0417 100644 --- a/clients/aurorae/src/aurorae.cpp +++ b/clients/aurorae/src/aurorae.cpp @@ -511,13 +511,19 @@ void Decoration::paint(QPainter *painter, const QRect &repaintRegion) m_padding->top(), m_buffer.width() - m_padding->left() - m_padding->right(), m_buffer.height() - m_padding->top() - m_padding->bottom())); - setShadow(s); + m_scheduledShadow = s; } else { - setShadow(QSharedPointer()); + m_scheduledShadow = QSharedPointer(); } + QMetaObject::invokeMethod(this, "updateShadow", Qt::QueuedConnection); painter->drawImage(rect(), m_buffer, r); } +void Decoration::updateShadow() +{ + setShadow(m_scheduledShadow); +} + QMouseEvent Decoration::translatedMouseEvent(QMouseEvent *orig) { if (!m_padding || client().data()->isMaximized()) { diff --git a/clients/aurorae/src/aurorae.h b/clients/aurorae/src/aurorae.h index 26296bf94c..ee1896a44c 100644 --- a/clients/aurorae/src/aurorae.h +++ b/clients/aurorae/src/aurorae.h @@ -61,6 +61,8 @@ public Q_SLOTS: void init() override; void installTitleItem(QQuickItem *item); + void updateShadow(); + Q_SIGNALS: void configChanged(); @@ -92,6 +94,7 @@ private: QScopedPointer m_updateTimer; QScopedPointer m_context; QScopedPointer m_offscreenSurface; + QSharedPointer m_scheduledShadow; }; class ThemeFinder : public QObject