summaryrefslogtreecommitdiffstats
path: root/opensuse/tdelibs/kickoff-drop-shadow.diff
blob: e4c7befc242b1907261f9187e771841d8f4114ac (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
Index: kdefx/kstyle.cpp
===================================================================
--- kdefx/kstyle.cpp.orig
+++ kdefx/kstyle.cpp
@@ -31,6 +31,7 @@
 
 #include <qapplication.h>
 #include <qbitmap.h>
+#include <qmetaobject.h>
 #include <qcleanuphandler.h>
 #include <qmap.h>
 #include <qimage.h>
@@ -79,7 +80,7 @@ namespace
 		QWidget* w1;
 		QWidget* w2;
 	};
-	typedef QMap<const QPopupMenu*,ShadowElements> ShadowMap;
+	typedef QMap<const QWidget*,ShadowElements> ShadowMap;
         static ShadowMap *_shadowMap = 0;
         QSingleCleanupHandler<ShadowMap> cleanupShadowMap;
         ShadowMap &shadowMap() {
@@ -113,8 +114,13 @@ namespace
 
 	const double shadow_strip[4] =
 		{ 0.565, 0.675, 0.835, 0.945 };
-}
 
+	static bool useDropShadow(QWidget* w)
+	{
+		return w && w->metaObject() && 
+			w->metaObject()->findProperty("KStyleMenuDropShadow") != -1;
+	}
+}
 
 namespace
 {
@@ -128,12 +134,12 @@ class TransparencyHandler : public QObje
 
 	protected:
 		void blendToColor(const QColor &col);
-		void blendToPixmap(const QColorGroup &cg, const QPopupMenu* p);
+		void blendToPixmap(const QColorGroup &cg, const QWidget* p);
 #ifdef HAVE_XRENDER
-		void XRenderBlendToPixmap(const QPopupMenu* p);
+		void XRenderBlendToPixmap(const QWidget* p);
 #endif
-		void createShadowWindows(const QPopupMenu* p);
-		void removeShadowWindows(const QPopupMenu* p);
+		void createShadowWindows(const QWidget* p);
+		void removeShadowWindows(const QWidget* p);
 		void rightShadow(QImage& dst);
 		void bottomShadow(QImage& dst);
 	private:
@@ -256,8 +262,16 @@ void KStyle::polish( QWidget* widget )
 				widget->installEventFilter(this);
 		} 
 	}
-}
+	if (widget->isTopLevel())
+	{
+		if (!d->menuHandler && useDropShadow(widget))
+			d->menuHandler = new TransparencyHandler(this, Disabled, 1.0, false);
 
+		if (d->menuHandler && useDropShadow(widget))
+			widget->installEventFilter(d->menuHandler);
+	}
+}
+
 
 void KStyle::unPolish( QWidget* widget )
 {
@@ -267,8 +281,10 @@ void KStyle::unPolish( QWidget* widget )
 			QFrame::Shape shape = frame->frameShape();
 			if (shape == QFrame::ToolBarPanel || shape == QFrame::MenuBarPanel)
 				widget->removeEventFilter(this);
-		} 
+		}
 	}
+	if (widget->isTopLevel() && d->menuHandler && useDropShadow(widget))
+		widget->removeEventFilter(d->menuHandler);
 }
 
 
@@ -1997,7 +2013,7 @@ void TransparencyHandler::bottomShadow(Q
 }
 
 // Create a shadow of thickness 4.
-void TransparencyHandler::createShadowWindows(const QPopupMenu* p)
+void TransparencyHandler::createShadowWindows(const QWidget* p)
 {
 #ifdef Q_WS_X11
 	int x2 = p->x()+p->width();
@@ -2044,7 +2060,7 @@ void TransparencyHandler::createShadowWi
 #endif
 }
 
-void TransparencyHandler::removeShadowWindows(const QPopupMenu* p)
+void TransparencyHandler::removeShadowWindows(const QWidget* p)
 {
 #ifdef Q_WS_X11
 	ShadowMap::iterator it = shadowMap().find(p);
@@ -2070,7 +2086,7 @@ bool TransparencyHandler::eventFilter( Q
 	// Copyright (C) 2000 Daniel M. Duley <mosfet@kde.org>
 
 	// Added 'fake' menu shadows <04-Jul-2002> -- Karol
-	QPopupMenu* p = (QPopupMenu*)object;
+	QWidget* p = (QWidget*)object;
 	QEvent::Type et = event->type();
 
 	if (et == QEvent::Show)
@@ -2109,13 +2125,23 @@ bool TransparencyHandler::eventFilter( Q
 		// * shadows after duplicate show events.
 		// * TODO : determine real cause for duplicate events
 		// * till 20021005
-		if (dropShadow && p->width() > 16 && p->height() > 16 && !shadowMap().contains( p ))
+		if ((dropShadow  || useDropShadow(p))
+		    && p->width() > 16 && p->height() > 16 && !shadowMap().contains( p ))
 			createShadowWindows(p);
 	}
+        else if (et == QEvent::Resize && p->isShown() && p->isTopLevel())
+        {
+		// Handle drop shadow
+		if (dropShadow || useDropShadow(p))
+		{
+			removeShadowWindows(p);
+			createShadowWindows(p);
+		}
+        }
 	else if (et == QEvent::Hide)
 	{
 		// Handle drop shadow
-		if (dropShadow)
+		if (dropShadow || useDropShadow(p))
 			removeShadowWindows(p);
 
 		// Handle translucency
@@ -2140,7 +2166,7 @@ void TransparencyHandler::blendToColor(c
 }
 
 
-void TransparencyHandler::blendToPixmap(const QColorGroup &cg, const QPopupMenu* p)
+void TransparencyHandler::blendToPixmap(const QColorGroup &cg, const QWidget* p)
 {
 	if (opacity < 0.0 || opacity > 1.0)
 		return;
@@ -2153,7 +2179,10 @@ void TransparencyHandler::blendToPixmap(
 		return;
 
 	// Allow styles to define the blend pixmap - allows for some interesting effects.
-	kstyle->renderMenuBlendPixmap( blendPix, cg, p );
+	if (::qt_cast<QPopupMenu*>(p))
+		kstyle->renderMenuBlendPixmap( blendPix, cg, ::qt_cast<QPopupMenu*>(p) );
+	else
+		blendPix.fill(cg.button());	// Just tint as the default behavior
 
 	QImage blendImg = blendPix.convertToImage();
 	QImage backImg  = pix.convertToImage();
@@ -2166,13 +2195,17 @@ void TransparencyHandler::blendToPixmap(
 // Here we go, use XRender in all its glory.
 // NOTE: This is actually a bit slower than the above routines
 // on non-accelerated displays. -- Karol.
-void TransparencyHandler::XRenderBlendToPixmap(const QPopupMenu* p)
+void TransparencyHandler::XRenderBlendToPixmap(const QWidget* p)
 {
 	KPixmap renderPix;
 	renderPix.resize( pix.width(), pix.height() );
 
 	// Allow styles to define the blend pixmap - allows for some interesting effects.
-	kstyle->renderMenuBlendPixmap( renderPix, p->colorGroup(), p );
+	if (::qt_cast<QPopupMenu*>(p))
+	   kstyle->renderMenuBlendPixmap( renderPix, p->colorGroup(),
+			   ::qt_cast<QPopupMenu*>(p) );
+	else
+		renderPix.fill(p->colorGroup().button());	// Just tint as the default behavior
 
 	Display* dpy = qt_xdisplay();
 	Pixmap   alphaPixmap;