From bc78e7628134195598c805c306b0392e4fc881ee Mon Sep 17 00:00:00 2001 From: Hugo Pereira Da Costa Date: Sat, 29 Aug 2009 21:24:07 +0000 Subject: [PATCH] put mask calculation in separate method, to be used in preview mode. In preview mode, set painter clipMask so that it matches widget mask, to fix corner painting svn path=/trunk/KDE/kdebase/workspace/; revision=1017184 --- clients/web/Web.cpp | 21 ++++++++++++++------- clients/web/Web.h | 1 + 2 files changed, 15 insertions(+), 7 deletions(-) diff --git a/clients/web/Web.cpp b/clients/web/Web.cpp index b9dbba6961..4ac4eb60ac 100644 --- a/clients/web/Web.cpp +++ b/clients/web/Web.cpp @@ -227,6 +227,8 @@ WebClient::paintEvent(QPaintEvent * pe) titleEdgeBottomBottom-(r_y+titleEdgeTop) ); titleRect.setTop(1); + QRegion mask( calcMask() ); + QPainter p(widget()); p.setPen(Qt::black); @@ -235,13 +237,15 @@ WebClient::paintEvent(QPaintEvent * pe) p.setBrush( pal.background() ); p.setClipRegion(pe->region() - titleRect); + if( isPreview() && shape_ ) p.setClipRegion( mask, Qt::IntersectClip ); + QRect r(widget()->rect()); r.adjust(0, 0, -1, -1); p.drawRect(r); - + p.setClipRegion(pe->region()); - + if( isPreview() && shape_ ) p.setClipRegion( mask, Qt::IntersectClip ); p.fillRect(titleRect, options()->color(ColorTitleBar, isActive())); if (shape_) @@ -289,11 +293,8 @@ WebClient::paintEvent(QPaintEvent * pe) p.drawText(titleRect, Qt::AlignCenter, caption()); } -void WebClient::updateWindowShape() +QRegion WebClient::calcMask(void) const { - if (!shape_) - return; - QRegion mask(0, 0, width(), height()); int r(width()); @@ -326,8 +327,14 @@ void WebClient::updateWindowShape() mask -= QRegion(r - 3, b - 2, 3, 1); mask -= QRegion(r - 2, b - 3, 2, 1); mask -= QRegion(r - 1, b - 5, 1, 2); + return mask; +} - setMask(mask); +void WebClient::updateWindowShape() +{ + if (!shape_) + return; + setMask(calcMask()); } KDecoration* WebFactory::createDecoration( KDecorationBridge* b ) diff --git a/clients/web/Web.h b/clients/web/Web.h index fb6c136e5a..54d90b3fd8 100644 --- a/clients/web/Web.h +++ b/clients/web/Web.h @@ -45,6 +45,7 @@ namespace Web virtual int layoutMetric(LayoutMetric lm, bool respectWindowState = true, const KCommonDecorationButton * = 0) const; virtual KCommonDecorationButton *createButton(ButtonType type); + virtual QRegion calcMask( void ) const; virtual void updateWindowShape(); virtual void init();