summaryrefslogtreecommitdiffstats
path: root/opensuse/core/tdebase/mach_blass.diff
blob: 8ea798d1311ec4c1287fea927b37c5d3d5e0d4f9 (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
Index: ksmserver/shutdowndlg.cpp
===================================================================
--- ksmserver/shutdowndlg.cpp.orig
+++ ksmserver/shutdowndlg.cpp
@@ -35,6 +35,7 @@ Copyright (C) 2000 Matthias Ettrich <ett
 #include <kuser.h>
 #include <kpixmap.h>
 #include <kimageeffect.h>
+#include <kpixmapeffect.h>
 #include <kdialog.h>
 #include <kseparator.h>
 
@@ -48,6 +49,9 @@ Copyright (C) 2000 Matthias Ettrich <ett
 
 #include "shutdowndlg.moc"
 
+static const int max_faded = 2300;
+static const int slice = 20;
+
 KSMShutdownFeedback * KSMShutdownFeedback::s_pSelf = 0L;
 
 KSMShutdownFeedback::KSMShutdownFeedback()
@@ -56,12 +60,22 @@ KSMShutdownFeedback::KSMShutdownFeedback
 {
     setBackgroundMode( QWidget::NoBackground );
     setGeometry( QApplication::desktop()->geometry() );
-    QTimer::singleShot( 10, this, SLOT( slotPaintEffect() ) );
-    m_root.resize( width(), height() );
-}
+    if( QPixmap::defaultDepth() > 8 )
+    {
+        grabbed.create( size(), 32 );
+        QTimer::singleShot( 0, this, SLOT( slotGrab() ) );
+    }
+    else
+    {
+        QTimer::singleShot( 10, this, SLOT( slotPaintEffectOld() ) );
+        m_root.resize( width(), height() );
+    }
 
 
-void KSMShutdownFeedback::slotPaintEffect()
+}
+
+// the upstream KDE effect
+void KSMShutdownFeedback::slotPaintEffectOld()
 {
     if ( m_currentY >= height() ) {
         if ( backgroundMode() == QWidget::NoBackground ) {
@@ -80,7 +94,76 @@ void KSMShutdownFeedback::slotPaintEffec
     bitBlt( this, 0, m_currentY, &pixmap );
     bitBlt( &m_root, 0, m_currentY, &pixmap );
     m_currentY += 10;
-    QTimer::singleShot( 1, this, SLOT( slotPaintEffect() ) );
+    QTimer::singleShot( 1, this, SLOT( slotPaintEffectOld() ) );
+}
+
+// the SUSE effect
+void KSMShutdownFeedback::slotGrab()
+{
+    // we start the passed early
+    if ( m_currentY * 4 >= height() * 3 && passed.isNull())
+        passed.start();
+
+    if ( m_currentY >= height() ) {
+        slotPaintEffectNew();
+        return;
+    }
+
+    QImage img;
+    img = QPixmap::grabWindow( qt_xrootwin(), 0,
+                               m_currentY, width(),
+                               slice );
+    bitBlt(&grabbed, 0, m_currentY, &img);
+    m_currentY += slice;
+    QTimer::singleShot(0, this, SLOT(slotGrab()));
+}
+
+void KSMShutdownFeedback::slotPaintEffectNew()
+{
+    const unsigned int shift_scale = 10;
+    const unsigned int scale = 1 << shift_scale;
+
+    //kdDebug() << "passed before paint " << passed.elapsed() << endl;
+    unsigned int current_fade = QMIN(scale, passed.elapsed() * scale / max_faded);
+    QImage copy;
+    copy.create( grabbed.size(), grabbed.depth() );
+    unsigned int pixels = grabbed.width()*grabbed.height();
+    QRgb *orig = ( QRgb* )grabbed.bits();
+    QRgb *dest = ( QRgb* )copy.bits();
+    QColor clr;
+
+    int r, g, b, tg;
+
+    for ( unsigned int i = 0; i < pixels; ++i )
+    {
+        r = qRed( orig[i] );
+        g = qGreen( orig[i] );
+        b = qBlue( orig[i] );
+
+        // qGray formla
+        tg = (r*11 + g*16 + b*5)/32;
+        // make it a bit darker than gray
+        tg = tg - tg / 5;
+
+        r = ( ( r << shift_scale ) + current_fade * ( tg - r ) ) >> shift_scale;
+        g = ( ( g << shift_scale ) + current_fade * ( tg - g ) ) >> shift_scale;
+        b = ( ( b << shift_scale ) + current_fade * ( tg - b ) ) >> shift_scale;
+
+        dest[i] = qRgb(r, g, b);
+    }
+    //kdDebug() << "passed before bitBlt " << passed.elapsed() << endl;
+    bitBlt( this, 0, 0, &copy);
+    //kdDebug() << "passed after bitBlt " << passed.elapsed() << endl;
+
+    if ( current_fade >= scale ) {
+        if ( backgroundMode() == QWidget::NoBackground ) {
+            setBackgroundMode( QWidget::NoBackground );
+            setBackgroundPixmap( copy );
+        }
+        return;
+    }
+
+    QTimer::singleShot( 0, this, SLOT( slotPaintEffectNew() ) );
 }
 
 //////
Index: ksmserver/shutdowndlg.h
===================================================================
--- ksmserver/shutdowndlg.h.orig
+++ ksmserver/shutdowndlg.h
@@ -9,7 +9,9 @@ Copyright (C) 2000 Matthias Ettrich <ett
 
 #include <qpixmap.h>
 #include <qdialog.h>
+#include <qdatetime.h>
 #include <kpushbutton.h>
+#include <qimage.h>
 class QPushButton;
 class QVButtonGroup;
 class QPopupMenu;
@@ -31,13 +33,17 @@ protected:
     ~KSMShutdownFeedback() {}
 
 private slots:
-    void slotPaintEffect();
+    void slotPaintEffectOld();
+    void slotPaintEffectNew();
+    void slotGrab();
 
 private:
     static KSMShutdownFeedback * s_pSelf;
     KSMShutdownFeedback();
     int m_currentY;
     QPixmap m_root;
+    QTime passed;
+    QImage grabbed;
 };