From 76104a522afc11dd5dfdf87e05240037a4600b3e Mon Sep 17 00:00:00 2001 From: Hugo Pereira Da Costa Date: Wed, 2 Sep 2009 05:28:38 +0000 Subject: [PATCH] fixed preview event painting, to use pixmap as intermediate painting device, in order to proper account for event clip rect, and avoid decorations appearing out of the widget rect svn path=/trunk/KDE/kdebase/workspace/; revision=1018742 --- kcmkwin/kwindecoration/preview.cpp | 28 ++++++++++++++++------------ 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/kcmkwin/kwindecoration/preview.cpp b/kcmkwin/kwindecoration/preview.cpp index b08b2bbfc7..b9a4b5dab2 100644 --- a/kcmkwin/kwindecoration/preview.cpp +++ b/kcmkwin/kwindecoration/preview.cpp @@ -109,19 +109,23 @@ void KDecorationPreview::disablePreview() void KDecorationPreview::paintEvent( QPaintEvent* e ) { + + QWidget::paintEvent(e); + + // render existing decorations into a pixmap + // there is some translations involved to make use of event.rect() + // and optimize painting + QRect rect( KDecorationPreview::rect().intersected( e->rect() ) ); + QPixmap pixmap( rect.size() ); + pixmap.fill( Qt::transparent ); + if( deco[Inactive] ) deco[Inactive]->widget()->render( &pixmap, deco[Inactive]->widget()->mapToParent( -rect.topLeft() ) ); + if( deco[Active] ) deco[Active]->widget()->render( &pixmap, deco[Active]->widget()->mapToParent( -rect.topLeft() ) ); + + // draw pixmap on widget QPainter painter( this ); - QPoint delta = mapTo( window(), QPoint(0, 0) ); - - if ( deco[Inactive] ) - { - QWidget *w = deco[Inactive]->widget(); - w->render( &painter, delta + w->mapToParent( QPoint(0, 0) ) ); - } - if ( deco[Active] ) - { - QWidget *w = deco[Active]->widget(); - w->render( &painter, delta + w->mapToParent( QPoint(0, 0) ) ); - } + painter.setClipRect( e->rect() ); + painter.drawPixmap( rect.topLeft(), pixmap ); + } void KDecorationPreview::resizeEvent( QResizeEvent* e )