From 8c0404ee31e86e1ff6241ee8142eb66659a129cc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lubo=C5=A1=20Lu=C5=88=C3=A1k?= Date: Wed, 17 Sep 2003 08:37:56 +0000 Subject: [PATCH] Improve reseting of the decoration. svn path=/trunk/kdebase/kwin/; revision=251774 --- clients/default/kdedefault.cpp | 56 +++++++++++++++++++++++++--------- clients/default/kdedefault.h | 3 +- 2 files changed, 43 insertions(+), 16 deletions(-) diff --git a/clients/default/kdedefault.cpp b/clients/default/kdedefault.cpp index cb957183b1..f1b75be1ed 100644 --- a/clients/default/kdedefault.cpp +++ b/clients/default/kdedefault.cpp @@ -119,6 +119,7 @@ bool useGradients; bool showGrabBar; bool showTitleBarStipple; bool largeToolButtons; +int titleBarSize; int toolTitleHeight; int normalTitleHeight; @@ -128,7 +129,7 @@ int normalTitleHeight; KDEDefaultHandler::KDEDefaultHandler() { clientHandler = this; - readConfig(); + readConfig( false ); createPixmaps(); KDEDefault_initialized = true; } @@ -148,33 +149,54 @@ KDecoration* KDEDefaultHandler::createDecoration( KDecorationBridge* b ) bool KDEDefaultHandler::reset( unsigned long changed ) { - Q_UNUSED( changed ) -// FRAME KDEDefault_initialized = false; - freePixmaps(); - readConfig(); - createPixmaps(); + changed |= readConfig( true ); + if( changed & SettingColors ) + { // pixmaps need to be recreated + freePixmaps(); + createPixmaps(); + } KDEDefault_initialized = true; - return true; + bool need_recreate = ( changed & ( SettingFont | SettingButtons | SettingBorder )) != 0; + if( need_recreate ) // something else than colors changed + return true; + resetDecorations( changed ); + return false; } -void KDEDefaultHandler::readConfig() +unsigned long KDEDefaultHandler::readConfig( bool update ) { + unsigned long changed = 0; KConfig* conf = KGlobal::config(); conf->setGroup("KDEDefault"); - showGrabBar = conf->readBoolEntry("ShowGrabBar", true); - showTitleBarStipple = conf->readBoolEntry("ShowTitleBarStipple", true); - useGradients = conf->readBoolEntry("UseGradients", true); - int size = conf->readNumEntry("TitleBarSize", 0); + bool new_showGrabBar = conf->readBoolEntry("ShowGrabBar", true); + bool new_showTitleBarStipple = conf->readBoolEntry("ShowTitleBarStipple", true); + bool new_useGradients = conf->readBoolEntry("UseGradients", true); + int new_titleBarSize = conf->readNumEntry("TitleBarSize", 0); - if (size < 0) size = 0; - if (size > 2) size = 2; + if (new_titleBarSize < 0) new_titleBarSize = 0; + if (new_titleBarSize > 2) new_titleBarSize = 2; - normalTitleHeight = 16 + (4*size); + if( update ) + { + if( new_showGrabBar != showGrabBar + || new_titleBarSize != titleBarSize ) + changed |= SettingDecoration; // need recreating the decoration + if( new_showTitleBarStipple != showTitleBarStipple + || new_useGradients != useGradients ) + changed |= SettingColors; // just recreate the pixmaps and repaint + } + + showGrabBar = new_showGrabBar; + showTitleBarStipple = new_showTitleBarStipple; + useGradients = new_useGradients; + titleBarSize = new_titleBarSize; + normalTitleHeight = 16 + (4*titleBarSize); toolTitleHeight = normalTitleHeight - 4; largeToolButtons = (toolTitleHeight >= 16) ? true : false; + return changed; } @@ -764,6 +786,10 @@ void KDEDefaultClient::addClientButtons( const QString& s, bool isLeft ) } } +void KDEDefaultClient::reset( unsigned long ) +{ + widget()->repaint(); +} void KDEDefaultClient::iconChange() { diff --git a/clients/default/kdedefault.h b/clients/default/kdedefault.h index 2a0e69ea7a..080e2f0cf5 100644 --- a/clients/default/kdedefault.h +++ b/clients/default/kdedefault.h @@ -38,7 +38,7 @@ class KDEDefaultHandler: public KDecorationFactory bool reset( unsigned long changed ); private: - void readConfig(); + unsigned long readConfig( bool update ); void createPixmaps(); void freePixmaps(); void drawButtonBackground(KPixmap *pix, @@ -88,6 +88,7 @@ class KDEDefaultClient : public KDecoration void borders( int&, int&, int&, int& ) const; void resize( const QSize& ); QSize minimumSize() const; + void reset( unsigned long changed ); protected: bool eventFilter( QObject*, QEvent* );