diff --git a/paintredirector.cpp b/paintredirector.cpp index dcea50af15..4113178e17 100644 --- a/paintredirector.cpp +++ b/paintredirector.cpp @@ -27,6 +27,7 @@ DEALINGS IN THE SOFTWARE. #include #include #include +#include namespace KWin { @@ -43,15 +44,22 @@ PaintRedirector::PaintRedirector( QWidget* w ) QPixmap PaintRedirector::performPendingPaint() { //qDebug() << "### performing paint, pending:" << pending.boundingRect(); - QPixmap pixmap( pending.boundingRect().size()); - pixmap.fill( Qt::transparent ); + const QSize size = pending.boundingRect().size(); + if ( scratch.width() < size.width() || scratch.height() < size.height() ) + { + int w = qCeil( size.width() / 128. ) * 128; + int h = qCeil( size.height() / 128. ) * 128; + scratch = QPixmap( qMax( scratch.width(), w ), qMax( scratch.height(), h ) ); + } + scratch.fill( Qt::transparent ); recursionCheck = true; // do not use DrawWindowBackground, it's ok to be transparent - widget->render( &pixmap, QPoint(), pending.boundingRect(), QWidget::DrawChildren ); + widget->render( &scratch, QPoint(), pending.boundingRect(), QWidget::DrawChildren ); recursionCheck = false; pending = QRegion(); scheduled = QRegion(); - return pixmap; + cleanupTimer.start(2000, this); + return scratch; } bool PaintRedirector::isToolTip( QWidget *object ) const @@ -128,6 +136,15 @@ void PaintRedirector::removed( QWidget* w ) w->installEventFilter( this ); } +void PaintRedirector::timerEvent( QTimerEvent* event ) + { + if ( event->timerId() == cleanupTimer.timerId() ) + { + cleanupTimer.stop(); + scratch = QPixmap(); + } + } + } // namespace #include "paintredirector.moc" diff --git a/paintredirector.h b/paintredirector.h index ce11daa457..2964913f28 100644 --- a/paintredirector.h +++ b/paintredirector.h @@ -28,6 +28,7 @@ DEALINGS IN THE SOFTWARE. #include #include #include +#include namespace KWin { @@ -50,11 +51,14 @@ class PaintRedirector void added( QWidget* widget ); void removed( QWidget* widget ); bool isToolTip( QWidget* widget ) const; + void timerEvent( QTimerEvent* event ); QWidget* widget; QRegion pending; QRegion scheduled; + QPixmap scratch; bool recursionCheck; QTimer timer; + QBasicTimer cleanupTimer; }; } // namespace