You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
tde-packaging/opensuse/tdebase/mach_blass.diff

161 lines
4.6 KiB

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;
};