File fix-plasma-theme-workaround-tabbox.patch of Package kdebase4-workspace

From 1f414ec2c5a98ffd9ed83713a8c89d4d337df7e8 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Thomas=20L=C3=BCbking?= <thomas.luebking@gmail.com>
Date: Wed, 13 Feb 2013 22:14:29 +0100
Subject: [PATCH] fix plasma theme workaround (tabbox)

BUG: 315064
FIXED-IN: 4.10.1
---
 kwin/tabbox/declarative.cpp         | 31 ++++++++++++++++++++-----------
 kwin/tabbox/qml/ShadowedSvgItem.qml | 15 ++++++++++++---
 2 files changed, 32 insertions(+), 14 deletions(-)

diff --git a/kwin/tabbox/declarative.cpp b/kwin/tabbox/declarative.cpp
index 5beaf1b..61e377d 100644
--- a/kwin/tabbox/declarative.cpp
+++ b/kwin/tabbox/declarative.cpp
@@ -102,17 +102,20 @@ QPixmap ImageProvider::requestPixmap(const QString &id, QSize *size, const QSize
     return icon;
 }
 
-static bool compositing()
+// WARNING: this code exists to cover a bug in Qt which prevents plasma from detecting the state change
+// of the compositor through KWindowSystem.
+// once plasma uses (again) a KSelectionWatcher or Qt is fixed in this regard, the code can go.
+static QString plasmaThemeVariant()
 {
 #ifndef TABBOX_KCM
     if (!Workspace::self()->compositing() || !effects) {
-        return false;
+        return Plasma::Theme::defaultTheme()->currentThemeHasImage("opaque/dialogs/background") ? QLatin1String("opaque/") : QLatin1String("");
     }
-    if (!static_cast<EffectsHandlerImpl*>(effects)->provides(Effect::Blur)) {
-        return false;
+    if (static_cast<EffectsHandlerImpl*>(effects)->provides(Effect::Blur)) {
+        return Plasma::Theme::defaultTheme()->currentThemeHasImage("translucent/dialogs/background") ? QLatin1String("translucent/") : QLatin1String("");
     }
 #endif
-    return Plasma::Theme::defaultTheme()->currentThemeHasImage("translucent/dialogs/background");
+    return QLatin1String("");
 }
 
 DeclarativeView::DeclarativeView(QAbstractItemModel *model, TabBoxConfig::TabBoxMode mode, QWidget *parent)
@@ -145,7 +148,7 @@ DeclarativeView::DeclarativeView(QAbstractItemModel *model, TabBoxConfig::TabBox
     kdeclarative.setupBindings();
     qmlRegisterType<ThumbnailItem>("org.kde.kwin", 0, 1, "ThumbnailItem");
     rootContext()->setContextProperty("viewId", static_cast<qulonglong>(winId()));
-    rootContext()->setContextProperty("compositing", compositing());
+    rootContext()->setContextProperty("plasmaThemeVariant", plasmaThemeVariant());
     if (m_mode == TabBoxConfig::ClientTabBox) {
         rootContext()->setContextProperty("clientModel", model);
     } else if (m_mode == TabBoxConfig::DesktopTabBox) {
@@ -188,8 +191,10 @@ void DeclarativeView::showEvent(QShowEvent *event)
         item->setProperty("currentIndex", tabBox->first().row());
         connect(item, SIGNAL(currentIndexChanged(int)), SLOT(currentIndexChanged(int)));
     }
-    rootContext()->setContextProperty("compositing", compositing());
+    rootContext()->setContextProperty("plasmaThemeVariant", plasmaThemeVariant());
     slotUpdateGeometry();
+    QResizeEvent re(size(), size()); // to set mask and blurring.
+    resizeEvent(&re);
     QGraphicsView::showEvent(event);
 }
 
@@ -210,11 +215,15 @@ void DeclarativeView::resizeEvent(QResizeEvent *event)
             m_frame->setImagePath(maskImagePath);
             m_frame->resizeFrame(QSizeF(maskWidth, maskHeight));
             QRegion mask = m_frame->mask().translated(maskLeftMargin, maskTopMargin);
-            if (compositing()) {
-                // blur background
-                Plasma::WindowEffects::enableBlurBehind(winId(), true, mask);
+#ifndef TABBOX_KCM
+            // notice: this covers an issue with plasma detecting the compositing state. see plasmaThemeVariant()
+            if (Workspace::self()->compositing() && effects) {
+                // blur background?!
+                Plasma::WindowEffects::enableBlurBehind(winId(), static_cast<EffectsHandlerImpl*>(effects)->provides(Effect::Blur), mask);
                 clearMask();
-            } else {
+            } else 
+#endif
+            {
                 // do not trim to mask with compositing enabled, otherwise shadows are cropped
                 setMask(mask);
             }
diff --git a/kwin/tabbox/qml/ShadowedSvgItem.qml b/kwin/tabbox/qml/ShadowedSvgItem.qml
index 8bf76c8..9ebe39f 100644
--- a/kwin/tabbox/qml/ShadowedSvgItem.qml
+++ b/kwin/tabbox/qml/ShadowedSvgItem.qml
@@ -32,16 +32,25 @@ Item {
     property int centerLeftMargin: shadow.margins.left
     property alias maskImagePath: shadow.imagePath
 
+    PlasmaCore.FrameSvg {
+        id: themeInfo
+        imagePath: plasmaThemeVariant + "dialogs/background"
+        // NOTICE: the followin plasmaThemeVariant access causes necessary re-evaluation!
+        property bool hasNewShadows: plasmaThemeVariant != "opaque/" && hasElementPrefix("shadow")
+    }
+
     PlasmaCore.FrameSvgItem {
         id: shadow
-        imagePath: (compositing ? "translucent" : "opaque") + "/dialogs/background"
-        prefix: "shadow"
+        prefix: themeInfo.hasNewShadows ? "shadow" : ""
+
+        imagePath: plasmaThemeVariant + "dialogs/background"
         anchors.fill: parent
+        visible: true
 
         PlasmaCore.FrameSvgItem {
             id: background
             imagePath: shadow.imagePath
-            visible: false
+            visible: themeInfo.hasNewShadows
             anchors {
                 fill: parent
                 leftMargin: shadow.margins.left
-- 
1.8.1.2

openSUSE Build Service is sponsored by