From 2cc47004c305c6af8506e8ea5fc341574ef8e55f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Gr=C3=A4=C3=9Flin?= Date: Tue, 7 Jun 2016 15:53:39 +0200 Subject: [PATCH] Fix calculation of the shadow size in the OpenGL compositor Summary: This change addresses the problem of the incorrectly rendered shadows when opening a window (e.g. Kickoff) a second time. In case of e.g. Kickoff not all elements are set, thus e.g. left might be 0, but right has a value. So for calculating the height the maximum of the values must be used. Test Plan: Opened Kickoff and systray a few times Reviewers: #kwin, #plasma_on_wayland Subscribers: plasma-devel, kwin Tags: #plasma_on_wayland, #kwin Differential Revision: https://phabricator.kde.org/D1792 --- scene_opengl.cpp | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/scene_opengl.cpp b/scene_opengl.cpp index e6bdc5a078..38fc53ed15 100644 --- a/scene_opengl.cpp +++ b/scene_opengl.cpp @@ -2276,8 +2276,12 @@ void SceneOpenGLShadow::buildQuads() const QRectF outerRect(QPointF(-leftOffset(), -topOffset()), QPointF(topLevel()->width() + rightOffset(), topLevel()->height() + bottomOffset())); - const qreal width = topLeft.width() + top.width() + topRight.width(); - const qreal height = topLeft.height() + left.height() + bottomLeft.height(); + const int width = qMax(topLeft.width(), bottomLeft.width()) + + qMax(top.width(), bottom.width()) + + qMax(topRight.width(), bottomRight.width()); + const int height = qMax(topLeft.height(), bottomLeft.height()) + + qMax(left.height(), right.height()) + + qMax(bottomLeft.height(), bottomRight.height()); qreal tx1(0.0), tx2(0.0), ty1(0.0), ty2(0.0); @@ -2377,9 +2381,14 @@ bool SceneOpenGLShadow::prepareBackend() const QSize bottomLeft(shadowPixmap(ShadowElementBottomLeft).size()); const QSize left(shadowPixmap(ShadowElementLeft).size()); const QSize topLeft(shadowPixmap(ShadowElementTopLeft).size()); + const QSize bottomRight(shadowPixmap(ShadowElementBottomRight).size()); - const int width = topLeft.width() + top.width() + topRight.width(); - const int height = topLeft.height() + left.height() + bottomLeft.height(); + const int width = qMax(topLeft.width(), bottomLeft.width()) + + qMax(top.width(), bottom.width()) + + qMax(topRight.width(), bottomRight.width()); + const int height = qMax(topLeft.height(), bottomLeft.height()) + + qMax(left.height(), right.height()) + + qMax(bottomLeft.height(), bottomRight.height()); if (width == 0 || height == 0) { return false;