diff --git a/composite.cpp b/composite.cpp
index f842d62935..050160b5c5 100644
--- a/composite.cpp
+++ b/composite.cpp
@@ -306,6 +306,7 @@ void Workspace::suspendCompositing( bool suspend )
compositingSuspended = suspend;
finishCompositing();
setupCompositing(); // will do nothing if suspended
+ emit compositingToggled( !compositingSuspended );
}
void Workspace::resetCompositing()
diff --git a/kcmkwin/kwincompositing/main.cpp b/kcmkwin/kwincompositing/main.cpp
index 3d4bb90d6f..eb6542dd02 100644
--- a/kcmkwin/kwincompositing/main.cpp
+++ b/kcmkwin/kwincompositing/main.cpp
@@ -74,6 +74,7 @@ KWinCompositingConfig::KWinCompositingConfig(QWidget *parent, const QVariantList
: KCModule( KWinCompositingConfigFactory::componentData(), parent )
, mKWinConfig(KSharedConfig::openConfig( "kwinrc" ))
, m_showConfirmDialog( false )
+ , kwinInterface( NULL )
{
KGlobal::locale()->insertCatalog( "kwin_effects" );
ui.setupUi(this);
@@ -95,6 +96,8 @@ KWinCompositingConfig::KWinCompositingConfig(QWidget *parent, const QVariantList
#define XRENDER_INDEX -1
#endif
+ kwinInterface = new OrgKdeKWinInterface( "org.kde.kwin", "/KWin", QDBusConnection::sessionBus() );
+
connect(ui.useCompositing, SIGNAL(toggled(bool)), this, SLOT(compositingEnabled(bool)));
connect(ui.tabWidget, SIGNAL(currentChanged(int)), this, SLOT(currentTabChanged(int)));
@@ -120,6 +123,8 @@ KWinCompositingConfig::KWinCompositingConfig(QWidget *parent, const QVariantList
connect(ui.glDirect, SIGNAL(toggled(bool)), this, SLOT(changed()));
connect(ui.glVSync, SIGNAL(toggled(bool)), this, SLOT(changed()));
connect(ui.xrenderSmoothScale, SIGNAL(toggled(bool)), this, SLOT(changed()));
+ connect(ui.compositingStateButton, SIGNAL(clicked(bool)), kwinInterface, SLOT(toggleCompositing()));
+ connect(kwinInterface, SIGNAL(compositingToggled(bool)), this, SLOT(setupCompositingState(bool)));
// Open the temporary config file
// Temporary conf file is used to synchronize effect checkboxes with effect
@@ -149,6 +154,8 @@ KWinCompositingConfig::KWinCompositingConfig(QWidget *parent, const QVariantList
ui.statusTitleWidget->setText(text);
ui.statusTitleWidget->setPixmap(KTitleWidget::InfoMessage, KTitleWidget::ImageLeft);
ui.statusTitleWidget->show();
+
+ setupCompositingState( false, false );
}
KAboutData *about = new KAboutData(I18N_NOOP("kcmkwincompositing"), 0,
@@ -234,6 +241,11 @@ void KWinCompositingConfig::showConfirmDialog( bool reinitCompositing )
ConfirmDialog confirm;
if( !confirm.exec())
revert = true;
+ else
+ {
+ // compositing is enabled now
+ setupCompositingState( kwinInterface->compositingActive() );
+ }
}
if( revert )
{
@@ -297,7 +309,8 @@ void KWinCompositingConfig::currentTabChanged(int tab)
void KWinCompositingConfig::loadGeneralTab()
{
KConfigGroup config(mKWinConfig, "Compositing");
- ui.useCompositing->setChecked(config.readEntry("Enabled", mDefaultPrefs.enableCompositing()));
+ bool enabled = config.readEntry("Enabled", mDefaultPrefs.enableCompositing());
+ ui.useCompositing->setChecked( enabled );
ui.animationSpeedCombo->setCurrentIndex(config.readEntry("AnimationSpeed", 3 ));
// Load effect settings
@@ -339,6 +352,48 @@ void KWinCompositingConfig::loadGeneralTab()
ui.desktopSwitchingCombo->setCurrentIndex( 2 );
if( effectEnabled( "fadedesktop", effectconfig ))
ui.desktopSwitchingCombo->setCurrentIndex( 3 );
+
+ if( enabled )
+ setupCompositingState( kwinInterface->compositingActive() );
+ else
+ setupCompositingState( false, false );
+ }
+
+void KWinCompositingConfig::setupCompositingState( bool active, bool enabled )
+ {
+ // compositing state
+ QString stateIcon;
+ QString stateText;
+ QString stateButtonText;
+ if( enabled )
+ {
+ // check if compositing is active or suspended
+ if( active )
+ {
+ stateIcon = QString( "dialog-ok-apply" );
+ stateText = i18n( "Compositing is active" );
+ stateButtonText = i18n( "Suspend Compositing" );
+ }
+ else
+ {
+ stateIcon = QString( "dialog-cancel" );
+ stateText = i18n( "Compositing is temporarily disabled" );
+ stateButtonText = i18n( "Resume Compositing" );
+ }
+ }
+ else
+ {
+ // compositing is disabled
+ stateIcon = QString( "dialog-cancel" );
+ stateText = i18n( "Compositing is disabled" );
+ stateButtonText = i18n( "Resume Compositing" );
+ }
+ ui.compositingStateIcon->setPixmap( KIcon( stateIcon ).pixmap( 32, 32 ) );
+ ui.compositingStateLabel->setText( stateText );
+ ui.compositingStateButton->setText( stateButtonText );
+ ui.compositingStateIcon->setEnabled( enabled );
+ ui.compositingStateLabel->setEnabled( enabled );
+ ui.compositingStateButton->setEnabled( enabled );
}
bool KWinCompositingConfig::effectEnabled( const QString& effect, const KConfigGroup& cfg ) const
@@ -410,6 +465,10 @@ void KWinCompositingConfig::saveGeneralTab()
config.writeEntry("Enabled", ui.useCompositing->isChecked());
config.writeEntry("AnimationSpeed", ui.animationSpeedCombo->currentIndex());
+ // disable the compositing state if compositing was turned off
+ if( !ui.useCompositing->isChecked() )
+ setupCompositingState( false, false );
+
// Save effects
KConfigGroup effectconfig(mTmpConfig, "Plugins");
#define WRITE_EFFECT_CONFIG(effectname, widget) effectconfig.writeEntry("kwin4_effect_" effectname "Enabled", widget->isChecked())
diff --git a/kcmkwin/kwincompositing/main.h b/kcmkwin/kwincompositing/main.h
index d9b7db9693..93f69f9e48 100644
--- a/kcmkwin/kwincompositing/main.h
+++ b/kcmkwin/kwincompositing/main.h
@@ -26,6 +26,8 @@ along with this program. If not, see .
#include
#include
+#include "kwin_interface.h"
+
#include "ui_main.h"
#include "compositingprefs.h"
#include "ktimerdialog.h"
@@ -71,6 +73,7 @@ class KWinCompositingConfig : public KCModule
void configChanged(bool reinitCompositing);
void initEffectSelector();
+ void setupCompositingState( bool active, bool enabled = true );
private:
bool effectEnabled( const QString& effect, const KConfigGroup& cfg ) const;
@@ -83,6 +86,8 @@ class KWinCompositingConfig : public KCModule
KTemporaryFile mTmpConfigFile;
KSharedConfigPtr mTmpConfig;
bool m_showConfirmDialog;
+
+ OrgKdeKWinInterface* kwinInterface;
};
} // namespace
diff --git a/kcmkwin/kwincompositing/main.ui b/kcmkwin/kwincompositing/main.ui
index 5a5872f184..d1bb83589f 100644
--- a/kcmkwin/kwincompositing/main.ui
+++ b/kcmkwin/kwincompositing/main.ui
@@ -37,7 +37,7 @@
-
-
-
+
-
Common Settings
@@ -225,6 +225,49 @@
+ -
+
+
+ Compositing State
+
+
+
-
+
+
+
+
+
+
+ -
+
+
+
+
+
+
+ -
+
+
+ Qt::Horizontal
+
+
+
+ 40
+ 20
+
+
+
+
+ -
+
+
+
+
+
+
+
+
+
diff --git a/org.kde.KWin.xml b/org.kde.KWin.xml
index 00cdb75605..9ed31f1174 100644
--- a/org.kde.KWin.xml
+++ b/org.kde.KWin.xml
@@ -38,6 +38,9 @@
+
+
+
diff --git a/workspace.h b/workspace.h
index e1856bf4de..6f6189b29a 100644
--- a/workspace.h
+++ b/workspace.h
@@ -644,6 +644,9 @@ class Workspace : public QObject, public KDecorationDefines
protected:
bool keyPressMouseEmulation( XKeyEvent& ev );
+ Q_SIGNALS:
+ Q_SCRIPTABLE void compositingToggled( bool active );
+
private:
void init();
void initShortcuts();