From 688fe7beff7a239d6fd18c814d0522641a378c36 Mon Sep 17 00:00:00 2001 From: Hugo Pereira Da Costa Date: Sun, 6 Sep 2009 18:04:11 +0000 Subject: [PATCH] Fixed calls renderWindowBackground so that gradients appear at the right place in decoration preview. Also removed 'const_cast<>' in ::renderWindowBorder svn path=/trunk/KDE/kdebase/workspace/; revision=1020604 --- clients/nitrogen/nitrogenclient.cpp | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/clients/nitrogen/nitrogenclient.cpp b/clients/nitrogen/nitrogenclient.cpp index fb971d2464..19f5134914 100644 --- a/clients/nitrogen/nitrogenclient.cpp +++ b/clients/nitrogen/nitrogenclient.cpp @@ -383,7 +383,8 @@ namespace Nitrogen int offset = layoutMetric( LM_OuterPaddingTop ); int height = 64 + configuration().buttonSize() - 22; - helper().renderWindowBackground(painter, rect, widget, palette, offset, height ); + const QWidget* window( isPreview() ? NitrogenClient::widget() : widget->window() ); + helper().renderWindowBackground(painter, rect, widget, window, palette, offset, height ); } @@ -393,12 +394,17 @@ namespace Nitrogen void NitrogenClient::renderWindowBorder( QPainter* painter, const QRect& clipRect, const QWidget* widget, const QPalette& palette ) const { - QWidget* window = widget->window(); + const QWidget* window = (isPreview()) ? NitrogenClient::widget() : widget->window(); // get coordinates relative to the client area - QPoint position = (isPreview()) ? - widget->mapTo( const_cast( NitrogenClient::widget() ), widget->rect().topLeft() ): - widget->mapTo( window, widget->rect().topLeft() ); + // this is annoying. One could use mapTo if this was taking const QWidget* and not + // const QWidget* as argument. + const QWidget* w = widget; + QPoint position( 0, 0 ); + while ( w != window && !w->isWindow() && w != w->parentWidget() ) { + position += w->geometry().topLeft(); + w = w->parentWidget(); + } // save painter if (clipRect.isValid()) { @@ -427,7 +433,8 @@ namespace Nitrogen int offset = layoutMetric( LM_OuterPaddingTop ); int gradient_height = 64 + configuration().buttonSize() - 22; - helper().renderWindowBackground(painter, rect, widget, palette, offset, gradient_height ); + const QWidget* window( isPreview() ? NitrogenClient::widget() : widget->window() ); + helper().renderWindowBackground(painter, rect, widget, window, palette, offset, gradient_height ); } @@ -486,7 +493,8 @@ namespace Nitrogen int offset = layoutMetric( LM_OuterPaddingTop ); int height = 64 + configuration().buttonSize() - 22; int voffset = isMaximized() ? 0:HFRAMESIZE; - helper().renderWindowBackground(painter, rect.adjusted( 4, voffset, -4, -4 ), widget(), palette, offset, height ); + const QWidget* window( isPreview() ? widget() : widget()->window() ); + helper().renderWindowBackground(painter, rect.adjusted( 4, voffset, -4, -4 ), widget(), window, palette, offset, height ); } }