[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-core-devel
Subject:    Re: Re: plasma and new shadow mess
From:       Weng Xuetian <wengxt () gmail ! com>
Date:       2013-01-07 12:00:48
Message-ID: CAKiDycGxMd42ZtA2NVKdnTurTHAOZr3+oHuHb9it3Pk__XbhSQ () mail ! gmail ! com
[Download RAW message or body]

[Attachment #2 (multipart/alternative)]


On Mon, Jan 7, 2013 at 5:14 AM, Martin Gr=C3=A4=C3=9Flin <mgraesslin@kde.or=
g> wrote:
On Monday 07 January 2013 10:51:11 Aaron J. Seigo wrote:
> On Sunday, January 6, 2013 17:40:42 Thomas L=C3=BCbking wrote:
> > 1. it will make kwin link generic-shell what is sematically the
> > gnome/unity
> > shell approach.

In the case of TabBox or anything else in KWin (and also for most things in
Plasma like tooltips, extenders) we don't have the requirement that the
shadows may not be part of the window geometry as it just does not matter.
So
we get the disadvantage without any advantage.

Ok,  it's also not hard if we want to do so.

Here is something I have locally for trying to workaround kwin's shadow in
different approach.
It draw the shadow inside qml by using svg (well, just like what plasma do
in the past).

The only remain problem while I was trying is how to set the blur mask.
Actually current code already suggest the blur region is svg and using it
without plasma will somehow fails.
One way to set blur mask properly, is to set the imagePath by qml itself
(since Plasma::FrameSvg is not exported to qml), and add proper offset.
These can be all passed by rootObject.

http://paste.ubuntu.com/1506434/ (also attached)

This patch only change the big icon tabbox, but change to other is trivial.
It draw the shadow inside tabbox by Plasma::Svg.

Screenshot:
http://wstaw.org/m/2013/01/07/plasma-desktopoj1171.png

Well, it's not perfect, since if we really want qml based blur mask, we
should get region and apply all qml transform agaisnst the mask, which is
not possible from current API, but for tabbox, we may survive with such
limitation.

[Attachment #5 (text/html)]

<div dir="ltr"><br>On Mon, Jan 7, 2013 at 5:14 AM, Martin Gräßlin &lt;<a \
href="mailto:mgraesslin@kde.org">mgraesslin@kde.org</a>&gt; wrote:<br>On Monday 07 \
January 2013 10:51:11 Aaron J. Seigo wrote:<br>&gt; On Sunday, January 6, 2013 \
17:40:42 Thomas Lübking wrote:<br> &gt; &gt; 1. it will make kwin link generic-shell \
what is sematically the<br>&gt; &gt; gnome/unity<br>&gt; &gt; shell \
approach.<br><br>In the case of TabBox or anything else in KWin (and also for most \
things in<br>Plasma like tooltips, extenders) we don&#39;t have the requirement that \
the<br> shadows may not be part of the window geometry as it just does not matter. \
So<br>we get the disadvantage without any advantage.<br><br>Ok,   it&#39;s also not \
hard if we want to do so.<br><br>Here is something I have locally for trying to \
workaround kwin&#39;s shadow in different approach.<br> It draw the shadow inside qml \
by using svg (well, just like what plasma do in the past).<br><br>The only remain \
problem while I was trying is how to set the blur mask. Actually current code already \
suggest the blur region is svg and using it without plasma will somehow fails.<br> \
One way to set blur mask properly, is to set the imagePath by qml itself (since \
Plasma::FrameSvg is not exported to qml), and add proper offset. These can be all \
passed by rootObject.<br><br><a \
href="http://paste.ubuntu.com/1506434/">http://paste.ubuntu.com/1506434/</a> (also \
attached)<br> <br>This patch only change the big icon tabbox, but change to other is \
trivial. It draw the shadow inside tabbox by Plasma::Svg.<br><br>Screenshot:<br><a \
href="http://wstaw.org/m/2013/01/07/plasma-desktopoj1171.png">http://wstaw.org/m/2013/01/07/plasma-desktopoj1171.png</a><br>
 <br>Well, it&#39;s not perfect, since if we really want qml based blur mask, we \
should get region and apply all qml transform agaisnst the mask, which is not \
possible from current API, but for tabbox, we may survive with such limitation.</div>

--90e6ba3fd8b77edd2004d2b194df--


["kwin-qml-shadow.patch" (application/octet-stream)]

diff --git a/kwin/tabbox/declarative.cpp b/kwin/tabbox/declarative.cpp
index 3bdcfac..2e4e234 100644
--- a/kwin/tabbox/declarative.cpp
+++ b/kwin/tabbox/declarative.cpp
@@ -179,16 +179,31 @@ void DeclarativeView::showEvent(QShowEvent *event)
 
 void DeclarativeView::resizeEvent(QResizeEvent *event)
 {
-    m_frame->resizeFrame(event->size());
-    if (Plasma::Theme::defaultTheme()->windowTranslucencyEnabled() && \
                !tabBox->embedded()) {
-        // blur background
-        Plasma::WindowEffects::enableBlurBehind(winId(), true, m_frame->mask());
-        Plasma::WindowEffects::overrideShadow(winId(), true);
-    } else if (tabBox->embedded()) {
+    if (tabBox->embedded()) {
         Plasma::WindowEffects::enableBlurBehind(winId(), false);
-    } else {
-        // do not trim to mask with compositing enabled, otherwise shadows are \
                cropped
-        setMask(m_frame->mask());
+    }
+    else {
+        QString maskImagePath = rootObject()->property("maskImagePath").toString();
+        if (maskImagePath.isEmpty()) {
+            clearMask();
+            Plasma::WindowEffects::enableBlurBehind(winId(), false);
+        } else {
+            double maskWidth = rootObject()->property("maskWidth").toDouble();
+            double maskHeight = rootObject()->property("maskHeight").toDouble();
+            int maskTopMargin = rootObject()->property("maskTopMargin").toInt();
+            int maskLeftMargin = rootObject()->property("maskLeftMargin").toInt();
+            m_frame->setImagePath(maskImagePath);
+            m_frame->resizeFrame(QSizeF(maskWidth, maskHeight));
+            QRegion mask = m_frame->mask().translated(maskLeftMargin, \
maskTopMargin); +            if \
(Plasma::Theme::defaultTheme()->windowTranslucencyEnabled()) { +                // \
blur background +                Plasma::WindowEffects::enableBlurBehind(winId(), \
true, mask); +                Plasma::WindowEffects::overrideShadow(winId(), true);
+            } else {
+                // do not trim to mask with compositing enabled, otherwise shadows \
are cropped +                setMask(mask);
+            }
+        }
     }
     QDeclarativeView::resizeEvent(event);
 }
@@ -208,7 +223,7 @@ void DeclarativeView::hideEvent(QHideEvent *event)
 
 bool DeclarativeView::x11Event(XEvent *e)
 {
-    if (tabBox->embedded() && 
+    if (tabBox->embedded() &&
         (e->type == ButtonPress || e->type == ButtonRelease || e->type == \
MotionNotify)) {  XEvent ev;
 
diff --git a/kwin/tabbox/qml/CMakeLists.txt b/kwin/tabbox/qml/CMakeLists.txt
index d4bc863..c3b3ee7 100644
--- a/kwin/tabbox/qml/CMakeLists.txt
+++ b/kwin/tabbox/qml/CMakeLists.txt
@@ -22,5 +22,5 @@ install( FILES clients/thumbnails/metadata.desktop   DESTINATION \
${SERVICES_INST  install( FILES clients/window_strip/metadata.desktop DESTINATION \
${SERVICES_INSTALL_DIR}/${KWIN_NAME} RENAME \
kwin4_window_switcher_window_strip.desktop )  
 # install additional icon tabbox into those that need it
-install (FILES IconTabBox.qml DESTINATION \
${DATA_INSTALL_DIR}/${KWIN_NAME}/tabbox/big_icons/contents/ui) +install (FILES \
IconTabBox.qml ShadowedSvgItem.qml DESTINATION \
${DATA_INSTALL_DIR}/${KWIN_NAME}/tabbox/big_icons/contents/ui)  install (FILES \
IconTabBox.qml DESTINATION \
                ${DATA_INSTALL_DIR}/${KWIN_NAME}/tabbox/small_icons/contents/ui)
diff --git a/kwin/tabbox/qml/clients/big_icons/contents/ui/main.qml \
b/kwin/tabbox/qml/clients/big_icons/contents/ui/main.qml index 7115b7f..a81e2d6 \
                100644
--- a/kwin/tabbox/qml/clients/big_icons/contents/ui/main.qml
+++ b/kwin/tabbox/qml/clients/big_icons/contents/ui/main.qml
@@ -26,10 +26,15 @@ Item {
     property int screenWidth : 0
     property int screenHeight : 0
     property int imagePathPrefix: (new Date()).getTime()
-    property int optimalWidth: (icons.iconSize + icons.margins.left + \
icons.margins.right) * icons.count + background.margins.left + \
                background.margins.bottom
-    property int optimalHeight: icons.iconSize + icons.margins.top + \
icons.margins.bottom + background.margins.top + background.margins.bottom + 40 +    \
property int optimalWidth: (icons.iconSize + icons.margins.left + \
icons.margins.right) * icons.count + background.leftMargin + background.bottomMargin \
+    property int optimalHeight: icons.iconSize + icons.margins.top + \
icons.margins.bottom + background.topMargin + background.bottomMargin + 40  property \
bool canStretchX: false  property bool canStretchY: false
+    property string maskImagePath: "dialogs/background"
+    property double maskWidth: background.centerWidth
+    property double maskHeight: background.centerHeight
+    property int maskTopMargin: background.centerTopMargin
+    property int maskLeftMargin: background.centerLeftMargin
     width: Math.min(Math.max(screenWidth * 0.3, optimalWidth), screenWidth * 0.9)
     height: Math.min(Math.max(screenHeight * 0.05, optimalHeight), screenHeight * \
0.5)  
@@ -42,24 +47,22 @@ Item {
         icons.modelChanged();
     }
 
-    PlasmaCore.FrameSvgItem {
+    ShadowedSvgItem {
         id: background
         anchors.fill: parent
-        imagePath: "dialogs/background"
     }
 
     IconTabBox {
         id: icons
         iconSize: 128
-        height: iconSize + background.margins.top + background.margins.bottom
+        height: iconSize + background.topMargin + background.bottomMargin
         anchors {
             top: parent.top
             left: parent.left
             right: parent.right
-            topMargin: background.margins.top
-            rightMargin: background.margins.right
-            bottomMargin: background.margins.bottom
-            leftMargin: background.margins.left
+            topMargin: background.topMargin
+            rightMargin: background.rightMargin
+            leftMargin: background.leftMargin
         }
     }
     Item {
@@ -69,9 +72,9 @@ Item {
             left: parent.left
             right: parent.right
             bottom: parent.bottom
-            leftMargin: background.margins.left
-            rightMargin: background.margins.right
-            bottomMargin: background.margins.bottom
+            leftMargin: background.leftMargin
+            rightMargin: background.rightMargin
+            bottomMargin: background.bottomMargin
         }
         Text {
             function constrainWidth() {
diff --git a/kwin/tabbox/qml/tabbox.qml b/kwin/tabbox/qml/tabbox.qml
index 4176231..9fccc0b 100644
--- a/kwin/tabbox/qml/tabbox.qml
+++ b/kwin/tabbox/qml/tabbox.qml
@@ -26,6 +26,11 @@ Loader {
     property int screenHeight : 0
     property bool allDesktops: true
     property string longestCaption: ""
+    property string maskImagePath: item && item.maskImagePath != undefined ? \
item.maskImagePath : "" +    property double maskWidth: item && item.maskWidth != \
undefined ? item.maskWidth : 0 +    property double maskHeight: item && \
item.maskHeight != undefined ? item.maskHeight : 0 +    property int maskTopMargin: \
item && item.maskTopMargin != undefined ? item.maskTopMargin : 0 +    property int \
maskLeftMargin: item && item.maskLeftMargin != undefined ? item.maskLeftMargin : 0  \
onLoaded: {  if (item.screenWidth != undefined) {
             item.screenWidth = screenWidth;



[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic