[prev in list] [next in list] [prev in thread] [next in thread]
List: kwin
Subject: Re: Patch for bug 174769
From: "David Nadlinger" <david.nadlinger () gmail ! com>
Date: 2008-11-19 21:24:16
Message-ID: a067f750811191324q6f877fcs6fecae9ba8d4377c () mail ! gmail ! com
[Download RAW message or body]
[Attachment #2 (text/plain)]
Sorry for the hassle everyone, I was in a hurry when I sent the patch
(actually, it was 01:45 a.m. and I wanted to go to bed – shouldn't do
that, I know^^).
The main patch is still quite big, but there are a few changes that
make it seem messier than it actually is:
- I have changed the name of mKWinConfig to mNewConfig in order to
better express the purpose
- I have split up the loading code in Options::updateSettings into
subroutines (actually, I have not changed anything except for adding
the backup related code)
- I have renamed the "reinitCompositing" DBus signal to
"reloadCompositingConfig" in order to clarify its purpose
- As I have mentioned before, it took me several iterations to find a
solution. Thus, there are a few basically unneeded changes in the
patch. However, I think they make the code easier to understand, so I
have not removed them.
The second patch contains a small fix (the dropdown boxes for the
window/desktop switching effects were not updated correctly if all
related effects had been disabled) and removes some unused code.
The third patch contains a few comment changes and a lot of whitespace
changes to make the code comply to the KWin coding standards.
I have just created these three with the help of "git add --patch" and
had no time to them yet, so the might not be fully independent.
The patches are attached this time, if you prefer a fancy HTML
rendering, you can still have look at them at
http://github.com/klickverbot/kwin/commits/configbackup.
Please bear with me if I have again made some major mistake ;)
["configbackup.patch" (text/x-diff)]
commit 2b91afd199d76d175b8fa7f40b228fddae535b81
Author: David Nadlinger <david.nadlinger@gmail.com>
Date: Wed Nov 19 20:34:47 2008 +0100
Save a backup of kwinrc to another file to revert if the X server crashes while \
testing the new config.
diff --git a/kcmkwin/kwincompositing/main.cpp b/kcmkwin/kwincompositing/main.cpp
index cd3593d..6a8ad45 100644
--- a/kcmkwin/kwincompositing/main.cpp
+++ b/kcmkwin/kwincompositing/main.cpp
@@ -25,6 +25,7 @@ along with this program. If not, see \
<http://www.gnu.org/licenses/>. #include <kaboutdata.h>
#include <kconfig.h>
#include <kconfiggroup.h>
+#include <kstandarddirs.h>
#include <kdebug.h>
#include <kmessagebox.h>
#include <ksettings/dispatcher.h>
@@ -34,6 +35,7 @@ along with this program. If not, see \
<http://www.gnu.org/licenses/>. #include <kservice.h>
#include <ktitlewidget.h>
+#include <QFile>
#include <QtDBus/QtDBus>
#include <QTimer>
#include <QLabel>
@@ -68,9 +70,8 @@ ConfirmDialog::ConfirmDialog() :
KWinCompositingConfig::KWinCompositingConfig(QWidget *parent, const QVariantList &)
: KCModule( KWinCompositingConfigFactory::componentData(), parent),
- mKWinConfig(KSharedConfig::openConfig("kwinrc")),
- m_showConfirmDialog (false)
-{
+ mNewConfig( KSharedConfig::openConfig( "kwinrc" ) )
+ {
KGlobal::locale()->insertCatalog( "kwin_effects" );
ui.setupUi(this);
layout()->setMargin(0);
@@ -107,6 +108,12 @@ KWinCompositingConfig::KWinCompositingConfig(QWidget *parent, \
const QVariantList connect(ui.glVSync, SIGNAL(toggled(bool)), this, \
SLOT(changed()));
connect(ui.xrenderSmoothScale, SIGNAL(toggled(bool)), this, SLOT(changed()));
+ // Create the backup config. It will be used as a means to revert the config if
+ // the X server crashes and to determine if a confirmation dialog should be \
shown. + // After the new settings have been confirmed to be stable, it is updated \
with the new + // config. It is deleted when the module is closed.
+ mBackupConfig = new KConfig( mNewConfig->name() + '~', KConfig::SimpleConfig );
+
// Open the temporary config file
// Temporary conf file is used to synchronize effect checkboxes with effect
// selector by loading/saving effects from/to temp config when active tab
@@ -181,13 +188,12 @@ KWinCompositingConfig::KWinCompositingConfig(QWidget *parent, \
const QVariantList }
KWinCompositingConfig::~KWinCompositingConfig()
-{
-}
-
-void KWinCompositingConfig::reparseConfiguration(const QByteArray&conf)
-{
- KSettings::Dispatcher::reparseConfiguration(conf);
-}
+ {
+ // Delete the backup file when exiting clean.
+ QString backupFileName = KStandardDirs::locate( "config", mBackupConfig->name() \
); + delete mBackupConfig;
+ QFile::remove( backupFileName );
+ }
void KWinCompositingConfig::compositingEnabled(bool enabled)
{
@@ -195,45 +201,7 @@ void KWinCompositingConfig::compositingEnabled(bool enabled)
ui.tabWidget->setTabEnabled(1, enabled);
ui.tabWidget->setTabEnabled(2, enabled);
ui.tabWidget->setTabEnabled(3, enabled);
-}
-
-void KWinCompositingConfig::showConfirmDialog(bool reinitCompositing)
-{
- bool revert = false;
- // Feel free to extend this to support several kwin instances (multihead) if you
- // think it makes sense.
- OrgKdeKWinInterface kwin("org.kde.kwin", "/KWin", \
QDBusConnection::sessionBus());
- if( reinitCompositing ? !kwin.compositingActive().value() : \
!kwin.waitForCompositingSetup().value() )
- {
- KMessageBox::sorry( this, i18n(
- "Failed to activate desktop effects using the given "
- "configuration options. Settings will be reverted to their previous \
values.\n\n"
- "Check your X configuration. You may also consider changing advanced \
options, "
- "especially changing the compositing type." ));
- revert = true;
- }
- else
- {
- ConfirmDialog confirm;
- if( !confirm.exec())
- revert = true;
}
- if( revert )
- {
- // Revert settings
- KConfigGroup config(mKWinConfig, "Compositing");
- config.deleteGroup();
- QMap<QString, QString>::const_iterator it = mPreviousConfig.constBegin();
- for(; it != mPreviousConfig.constEnd(); ++it) {
- if (it.value().isEmpty())
- continue;
- config.writeEntry(it.key(), it.value());
- }
- // Sync with KWin and reload
- configChanged(reinitCompositing);
- load();
- }
-}
void KWinCompositingConfig::initEffectSelector()
{
@@ -273,8 +241,8 @@ void KWinCompositingConfig::currentTabChanged(int tab)
}
void KWinCompositingConfig::loadGeneralTab()
-{
- KConfigGroup config(mKWinConfig, "Compositing");
+ {
+ KConfigGroup config(mNewConfig, "Compositing");
ui.useCompositing->setChecked(config.readEntry("Enabled", \
mDefaultPrefs.enableCompositing()));
ui.animationSpeedCombo->setCurrentIndex(config.readEntry("AnimationSpeed", 3 ));
@@ -301,14 +269,14 @@ void KWinCompositingConfig::loadGeneralTab()
ui.windowSwitchingCombo->setCurrentIndex( 3 );
if( effectEnabled( "flipswitch", effectconfig ))
ui.windowSwitchingCombo->setCurrentIndex( 4 );
- KConfigGroup presentwindowsconfig(mKWinConfig, "Effect-PresentWindows");
+ KConfigGroup presentwindowsconfig(mNewConfig, "Effect-PresentWindows");
if( effectEnabled( "presentwindows", effectconfig ) && \
presentwindowsconfig.readEntry("TabBox", false) ) \
ui.windowSwitchingCombo->setCurrentIndex( 2 );
// desktop switching
if( effectEnabled( "slide", effectconfig ))
ui.desktopSwitchingCombo->setCurrentIndex( 1 );
- KConfigGroup cubeconfig(mKWinConfig, "Effect-Cube");
+ KConfigGroup cubeconfig(mNewConfig, "Effect-Cube");
if( effectEnabled( "cube", effectconfig ) && \
cubeconfig.readEntry("AnimateDesktopChange", false)) \
ui.desktopSwitchingCombo->setCurrentIndex( 2 );
@@ -331,8 +299,8 @@ void KWinCompositingConfig::loadEffectsTab()
}
void KWinCompositingConfig::loadAdvancedTab()
-{
- KConfigGroup config(mKWinConfig, "Compositing");
+ {
+ KConfigGroup config(mNewConfig, "Compositing");
QString backend = config.readEntry("Backend", "OpenGL");
ui.compositingType->setCurrentIndex((backend == "XRender") ? 1 : 0);
// 4 - off, 5 - shown, 6 - always, other are old values
@@ -355,18 +323,13 @@ void KWinCompositingConfig::loadAdvancedTab()
}
void KWinCompositingConfig::load()
-{
- mKWinConfig->reparseConfiguration();
-
- // Copy Plugins group to temp config file
- QMap<QString, QString> entries = mKWinConfig->entryMap("Plugins");
- QMap<QString, QString>::const_iterator it = entries.constBegin();
- KConfigGroup tmpconfig(mTmpConfig, "Plugins");
- tmpconfig.deleteGroup();
- for(; it != entries.constEnd(); ++it)
{
- tmpconfig.writeEntry(it.key(), it.value());
- }
+ mNewConfig->reparseConfiguration();
+
+ updateBackupWithNewConfig();
+
+ // Copy the plugin settings from the main config file to the temp config.
+ copyPluginsToTmpConfig();
loadGeneralTab();
loadEffectsTab();
@@ -376,14 +339,8 @@ void KWinCompositingConfig::load()
}
void KWinCompositingConfig::saveGeneralTab()
-{
- KConfigGroup config(mKWinConfig, "Compositing");
- // Check if any critical settings that need confirmation have changed
- if(ui.useCompositing->isChecked()
- && ui.useCompositing->isChecked() != config.readEntry("Enabled", \
mDefaultPrefs.enableCompositing()))
- {
- m_showConfirmDialog = true;
- }
+ {
+ KConfigGroup config(mNewConfig, "Compositing");
config.writeEntry("Enabled", ui.useCompositing->isChecked());
config.writeEntry("AnimationSpeed", ui.animationSpeedCombo->currentIndex());
@@ -439,7 +396,7 @@ void KWinCompositingConfig::saveGeneralTab()
effectconfig.writeEntry("kwin4_effect_flipswitchEnabled", true);
break;
}
- KConfigGroup presentwindowsconfig(mKWinConfig, "Effect-PresentWindows");
+ KConfigGroup presentwindowsconfig(mNewConfig, "Effect-PresentWindows");
presentwindowsconfig.writeEntry("TabBox", presentWindowSwitching);
int desktopSwitcher = ui.desktopSwitchingCombo->currentIndex();
@@ -461,7 +418,7 @@ void KWinCompositingConfig::saveGeneralTab()
effectconfig.writeEntry("kwin4_effect_cubeEnabled", true);
break;
}
- KConfigGroup cubeconfig(mKWinConfig, "Effect-Cube");
+ KConfigGroup cubeconfig(mNewConfig, "Effect-Cube");
cubeconfig.writeEntry("AnimateDesktopChange", cubeDesktopSwitching);
saveElectricBorders();
@@ -472,29 +429,13 @@ void KWinCompositingConfig::saveEffectsTab()
ui.effectSelector->save();
}
-bool KWinCompositingConfig::saveAdvancedTab()
-{
- bool advancedChanged = false;
+void KWinCompositingConfig::saveAdvancedTab()
+ {
static const int hps[] = { 6 /*always*/, 5 /*shown*/, 4 /*never*/ };
- KConfigGroup config(mKWinConfig, "Compositing");
+ KConfigGroup config(mNewConfig, "Compositing");
QString glModes[] = { "TFP", "SHM", "Fallback" };
- if( config.readEntry("Backend", "OpenGL")
- != ((ui.compositingType->currentIndex() == 0) ? "OpenGL" : "XRender")
- || config.readEntry("GLMode", "TFP") != glModes[ui.glMode->currentIndex()]
- || config.readEntry("GLDirect", mDefaultPrefs.enableDirectRendering())
- != ui.glDirect->isChecked()
- || config.readEntry("GLVSync", mDefaultPrefs.enableVSync()) != \
ui.glVSync->isChecked()
- || config.readEntry("DisableChecks", false ) != \
ui.disableChecks->isChecked())
- {
- m_showConfirmDialog = true;
- advancedChanged = true;
- }
- else if( config.readEntry("HiddenPreviews", 5) != hps[ \
ui.windowThumbnails->currentIndex() ]
- || config.readEntry("XRenderSmoothScale", false ) != \
ui.xrenderSmoothScale->isChecked() )
- advancedChanged = true;
-
config.writeEntry("Backend", (ui.compositingType->currentIndex() == 0) ? \
"OpenGL" : "XRender");
config.writeEntry("HiddenPreviews", hps[ ui.windowThumbnails->currentIndex() ] \
); config.writeEntry("DisableChecks", ui.disableChecks->isChecked());
@@ -505,16 +446,10 @@ bool KWinCompositingConfig::saveAdvancedTab()
config.writeEntry("GLVSync", ui.glVSync->isChecked());
config.writeEntry("XRenderSmoothScale", ui.xrenderSmoothScale->isChecked());
-
- return advancedChanged;
-}
+ }
void KWinCompositingConfig::save()
-{
- // Save current config. We'll use this for restoring in case something goes \
wrong.
- KConfigGroup config(mKWinConfig, "Compositing");
- mPreviousConfig = config.entryMap();
-
+ {
// bah; tab content being dependent on the other is really bad; and
// deprecated in the HIG for a reason. Its confusing!
// Make sure we only call save on each tab once; as they are stateful due to the \
revert concept @@ -527,40 +462,16 @@ void KWinCompositingConfig::save()
saveEffectsTab();
loadGeneralTab();
saveGeneralTab();
- }
- bool advancedChanged = saveAdvancedTab();
-
- // Copy Plugins group from temp config to real config
- QMap<QString, QString> entries = mTmpConfig->entryMap("Plugins");
- QMap<QString, QString>::const_iterator it = entries.constBegin();
- KConfigGroup realconfig(mKWinConfig, "Plugins");
- realconfig.deleteGroup();
- for(; it != entries.constEnd(); ++it)
- {
- realconfig.writeEntry(it.key(), it.value());
- }
+ }
+ copyPluginsToNewConfig();
- emit changed( false );
+ saveElectricBorders();
+ saveAdvancedTab();
- configChanged(advancedChanged);
+ emit changed( false );
- if(m_showConfirmDialog)
- {
- m_showConfirmDialog = false;
- showConfirmDialog(advancedChanged);
+ activateNewConfig();
}
-}
-
-void KWinCompositingConfig::configChanged(bool reinitCompositing)
-{
- // Send signal to kwin
- mKWinConfig->sync();
- // Send signal to all kwin instances
- QDBusMessage message = QDBusMessage::createSignal("/KWin", "org.kde.KWin",
- reinitCompositing ? "reinitCompositing" : "reloadConfig");
- QDBusConnection::sessionBus().send(message);
-}
-
void KWinCompositingConfig::defaults()
{
@@ -661,25 +572,25 @@ void KWinCompositingConfig::electricBorderSelectionChanged(int \
edge, int index) void KWinCompositingConfig::loadElectricBorders()
{
// Present Windows
- KConfigGroup presentwindowsconfig(mKWinConfig, "Effect-PresentWindows");
+ KConfigGroup presentwindowsconfig(mNewConfig, "Effect-PresentWindows");
changeElectricBorder( (ElectricBorder)presentwindowsconfig.readEntry( \
"BorderActivateAll", int( ElectricTopLeft )), (int)PresentWindowsAll );
changeElectricBorder( (ElectricBorder)presentwindowsconfig.readEntry( \
"BorderActivate", int( ElectricNone )), (int)PresentWindowsCurrent );
// Desktop Grid
- KConfigGroup gridconfig(mKWinConfig, "Effect-DesktopGrid");
+ KConfigGroup gridconfig(mNewConfig, "Effect-DesktopGrid");
changeElectricBorder( (ElectricBorder)gridconfig.readEntry( "BorderActivate",
int( ElectricNone )), (int)DesktopGrid );
// Desktop Cube
- KConfigGroup cubeconfig(mKWinConfig, "Effect-Cube");
+ KConfigGroup cubeconfig(mNewConfig, "Effect-Cube");
changeElectricBorder( (ElectricBorder)cubeconfig.readEntry( "BorderActivate",
int( ElectricNone )), (int)Cube );
// Desktop Cylinder
- KConfigGroup cylinderconfig(mKWinConfig, "Effect-Cylinder");
+ KConfigGroup cylinderconfig(mNewConfig, "Effect-Cylinder");
changeElectricBorder( (ElectricBorder)cylinderconfig.readEntry( \
"BorderActivate", int( ElectricNone )), (int)Cylinder );
// Desktop Grid
- KConfigGroup sphereconfig(mKWinConfig, "Effect-Sphere");
+ KConfigGroup sphereconfig(mNewConfig, "Effect-Sphere");
changeElectricBorder( (ElectricBorder)sphereconfig.readEntry( "BorderActivate",
int( ElectricNone )), (int)Sphere );
}
@@ -756,24 +667,156 @@ ElectricBorder \
KWinCompositingConfig::checkEffectHasElectricBorder( int index ) }
void KWinCompositingConfig::saveElectricBorders()
-{
- KConfigGroup presentwindowsconfig(mKWinConfig, "Effect-PresentWindows");
+ {
+ KConfigGroup presentwindowsconfig(mNewConfig, "Effect-PresentWindows");
presentwindowsconfig.writeEntry( "BorderActivateAll", \
(int)checkEffectHasElectricBorder( (int)PresentWindowsAll ));
presentwindowsconfig.writeEntry( "BorderActivate", \
(int)checkEffectHasElectricBorder( (int)PresentWindowsCurrent ));
- KConfigGroup gridconfig(mKWinConfig, "Effect-DesktopGrid");
+ KConfigGroup gridconfig(mNewConfig, "Effect-DesktopGrid");
gridconfig.writeEntry( "BorderActivate", (int)checkEffectHasElectricBorder( \
(int)DesktopGrid ));
- KConfigGroup cubeconfig(mKWinConfig, "Effect-Cube");
+ KConfigGroup cubeconfig(mNewConfig, "Effect-Cube");
cubeconfig.writeEntry( "BorderActivate", (int)checkEffectHasElectricBorder( \
(int)Cube ));
- KConfigGroup cylinderconfig(mKWinConfig, "Effect-Cylinder");
+ KConfigGroup cylinderconfig(mNewConfig, "Effect-Cylinder");
cylinderconfig.writeEntry( "BorderActivate", (int)checkEffectHasElectricBorder( \
(int)Cylinder ));
- KConfigGroup sphereconfig(mKWinConfig, "Effect-Sphere");
+ KConfigGroup sphereconfig(mNewConfig, "Effect-Sphere");
sphereconfig.writeEntry( "BorderActivate", (int)checkEffectHasElectricBorder( \
(int)Sphere ));
-}
-
+ }
+
+void KWinCompositingConfig::activateNewConfig()
+ {
+ bool configOk = true;
+
+ // Tell KWin to load the new configuration.
+ bool couldReload = sendKWinReloadSignal();
+ // If it was not successfull, show an error message to the user.
+ if ( !couldReload )
+ {
+ KMessageBox::sorry( this, i18n(
+ "Failed to activate desktop effects using the given "
+ "configuration options. Settings will be reverted to their previous \
values.\n\n" + "Check your X configuration. You may also consider changing \
advanced options, " + "especially changing the compositing type." ) );
+ configOk = false;
+ }
+ else
+ {
+ // If the confirmation dialog should be shown, wait for its result.
+ if ( isConfirmationNeeded() )
+ {
+ ConfirmDialog confirm;
+ configOk = confirm.exec();
+ }
+ }
+
+ if ( configOk )
+ {
+ // The new config is stable and was accepted.
+ updateBackupWithNewConfig();
+ }
+ else
+ {
+ // Copy back the old config and load it into the ui.
+ resetNewToBackupConfig();
+ load();
+ // Tell KWin to reload the (old) config.
+ sendKWinReloadSignal();
+ }
+ }
+
+bool KWinCompositingConfig::isConfirmationNeeded() const
+ {
+ // Compare new config with the backup and see if any potentially dangerous
+ // values have been changed.
+ KConfigGroup newGroup( mNewConfig, "Compositing" );
+ KConfigGroup backupGroup( mBackupConfig, "Compositing" );
+
+ // Manually enabling compositing is potentially dangerous, but disabling is \
never. + bool newEnabled = newGroup.readEntry( "Enabled", \
mDefaultPrefs.enableCompositing() ); + bool backupEnabled = backupGroup.readEntry( \
"Enabled", mDefaultPrefs.enableCompositing() ); + if ( newEnabled && \
!backupEnabled ) + {
+ return true;
+ }
+
+ // All potentially dangerous options along with their (safe) default values.
+ QHash<QString, QVariant> confirm;
+ confirm[ "Backend" ] = "OpenGL";
+ confirm[ "GLMode" ] = "TFP";
+ confirm[ "GLDirect" ] = mDefaultPrefs.enableDirectRendering();
+ confirm[ "GLVSync" ] = mDefaultPrefs.enableVSync();
+ confirm[ "DisableChecks" ] = false;
+
+ QHash<QString, QVariant>::const_iterator i = confirm.constBegin();
+ for( ; i != confirm.constEnd(); ++i )
+ {
+ if ( newGroup.readEntry( i.key(), i.value() ) !=
+ backupGroup.readEntry( i.key(), i.value() ) )
+ {
+ return true;
+ }
+ }
+
+ // If we have not returned yet, no critical settings have been changed.
+ return false;
+ }
+
+bool KWinCompositingConfig::sendKWinReloadSignal()
+ {
+ // Save the new config to the file system, thus allowing KWin to read it.
+ mNewConfig->sync();
+
+ // Send signal to all kwin instances.
+ QDBusMessage message = QDBusMessage::createSignal( "/KWin", "org.kde.KWin", \
"reloadCompositingConfig" ); + QDBusConnection::sessionBus().send(message);
+
+ // If compositing is enabled, check if it could be started.
+ KConfigGroup newGroup( mNewConfig, "Compositing" );
+ bool enabled = newGroup.readEntry( "Enabled", mDefaultPrefs.enableCompositing() \
); +
+ if ( !enabled )
+ {
+ return true;
+ }
+ else
+ {
+ // Feel free to extend this to support several kwin instances (multihead) if \
you + // think it makes sense.
+ OrgKdeKWinInterface kwin( "org.kde.kwin", "/KWin", \
QDBusConnection::sessionBus() ); + return kwin.compositingActive().value();
+ }
+ }
+
+void KWinCompositingConfig::updateBackupWithNewConfig()
+ {
+ mNewConfig->copyTo( mBackupConfig->name(), mBackupConfig );
+ mBackupConfig->sync();
+ }
+
+void KWinCompositingConfig::resetNewToBackupConfig()
+ {
+ mBackupConfig->copyTo( mNewConfig->name(), mNewConfig.data() );
+ mNewConfig->sync();
+ }
+
+void KWinCompositingConfig::copyPluginsToTmpConfig()
+ {
+ KConfigGroup newGroup( mNewConfig, "Plugins" );
+ KConfigGroup tmpGroup( mTmpConfig, "Plugins" );
+ tmpGroup.deleteGroup();
+ newGroup.copyTo( &tmpGroup );
+ }
+
+void KWinCompositingConfig::copyPluginsToNewConfig()
+ {
+ KConfigGroup newGroup( mNewConfig, "Plugins" );
+ KConfigGroup tmpGroup( mTmpConfig, "Plugins" );
+ newGroup.deleteGroup();
+ tmpGroup.copyTo( &newGroup );
+ }
+
} // namespace
#include "main.moc"
diff --git a/kcmkwin/kwincompositing/main.h b/kcmkwin/kwincompositing/main.h
index 5c8dbb9..e547a10 100644
--- a/kcmkwin/kwincompositing/main.h
+++ b/kcmkwin/kwincompositing/main.h
@@ -53,43 +53,51 @@ class KWinCompositingConfig : public KCModule
virtual QString quickHelp() const;
public slots:
- virtual void compositingEnabled(bool enabled);
- virtual void showConfirmDialog(bool reinitCompositing);
- void currentTabChanged(int tab);
-
virtual void load();
virtual void save();
virtual void defaults();
- void reparseConfiguration(const QByteArray&conf);
+ private slots:
+ void compositingEnabled(bool enabled);
+ void currentTabChanged(int tab);
+ void electricBorderSelectionChanged(int edge, int index);
+
+ private:
void loadGeneralTab();
void loadEffectsTab();
void loadAdvancedTab();
void loadElectricBorders();
void saveGeneralTab();
void saveEffectsTab();
- bool saveAdvancedTab();
- void electricBorderSelectionChanged(int edge, int index);
+ void saveAdvancedTab();
- void configChanged(bool reinitCompositing);
void initEffectSelector();
- private:
bool effectEnabled( const QString& effect, const KConfigGroup& cfg ) const;
+
void setupElectricBorders();
void addItemToEdgesMonitor(const QString& item);
void changeElectricBorder( ElectricBorder border, int index );
ElectricBorder checkEffectHasElectricBorder( int index );
void saveElectricBorders();
- KSharedConfigPtr mKWinConfig;
+ void activateNewConfig();
+ bool isConfirmationNeeded() const;
+ bool sendKWinReloadSignal();
+
+ void updateBackupWithNewConfig();
+ void resetNewToBackupConfig();
+
+ void copyPluginsToTmpConfig();
+ void copyPluginsToNewConfig();
+
Ui::KWinCompositingConfig ui;
CompositingPrefs mDefaultPrefs;
- QMap<QString, QString> mPreviousConfig;
+ KSharedConfigPtr mNewConfig;
+ KConfig* mBackupConfig;
KTemporaryFile mTmpConfigFile;
KSharedConfigPtr mTmpConfig;
- bool m_showConfirmDialog;
enum ElectricBorderEffects
{
diff --git a/options.cpp b/options.cpp
index d4d701a..966c4b9 100644
--- a/options.cpp
+++ b/options.cpp
@@ -23,10 +23,12 @@ along with this program. If not, see \
<http://www.gnu.org/licenses/>.
#ifndef KCMRULES
+#include <QFile>
#include <QPalette>
#include <QPixmap>
#include <kapplication.h>
#include <kconfig.h>
+#include <kstandarddirs.h>
#include <kglobal.h>
#include <kglobalsettings.h>
@@ -45,9 +47,14 @@ namespace KWin
#ifndef KCMRULES
Options::Options()
- : electric_borders( 0 ),
- electric_border_delay(0)
{
+ // If there is any contents in the backup file, it means that KWin crashed
+ // while testing a new config. Revert the config.
+ // TODO: Notify the user?
+ bool backupImported = importBackup();
+ kWarning( 1212, backupImported ) << "The new settings have most likely caused \
the X server " + "to crash. The configuration options have been reverted to \
their old values."; +
updateSettings();
}
@@ -55,13 +62,44 @@ Options::~Options()
{
}
+
unsigned long Options::updateSettings()
{
- KSharedConfig::Ptr _config = KGlobal::config();
+ return loadSettings( KGlobal::config() );
+ }
+
+bool Options::importBackup()
+ {
+ QString configFileName = KStandardDirs::locate( "config", \
KGlobal::config()->name() ); + QString backupFileName = configFileName + '~';
+
+ if ( !QFile::exists( backupFileName ) )
+ {
+ return false;
+ }
+
+ QFile::remove( configFileName );
+ QFile::rename( backupFileName, configFileName );
+
+ KGlobal::config()->reparseConfiguration();
+ return true;
+ }
+
+unsigned long Options::loadSettings( KSharedConfigPtr configFile )
+ {
unsigned long changed = 0;
- changed |= KDecorationOptions::updateSettings( _config.data() ); // read \
decoration settings + changed |= KDecorationOptions::updateSettings( \
configFile.data() ); // read decoration settings +
+ loadWindowSettings( configFile );
+ loadMouseBindings( configFile );
+ loadCompositingSettings( configFile );
- KConfigGroup config(_config, "Windows");
+ return changed;
+ }
+
+void Options::loadWindowSettings( KSharedConfigPtr configFile )
+ {
+ KConfigGroup config( configFile, "Windows" );
moveMode = stringToMoveResizeMode( config.readEntry("MoveMode", "Opaque" ));
resizeMode = stringToMoveResizeMode( config.readEntry("ResizeMode", "Opaque" ));
show_geometry_tip = config.readEntry("GeometryTip", false);
@@ -94,12 +132,12 @@ unsigned long Options::updateSettings()
if( !focusPolicyIsReasonable()) // #48786, comments #7 and later
focusStealingPreventionLevel = 0;
- KConfigGroup gWindowsConfig( _config, "Windows"); // from kdeglobals
- xineramaEnabled = gWindowsConfig.readEntry ("XineramaEnabled", true);
- xineramaPlacementEnabled = gWindowsConfig.readEntry ("XineramaPlacementEnabled", \
true);
- xineramaMovementEnabled = gWindowsConfig.readEntry ("XineramaMovementEnabled", \
true);
- xineramaMaximizeEnabled = gWindowsConfig.readEntry ("XineramaMaximizeEnabled", \
true);
- xineramaFullscreenEnabled = gWindowsConfig.readEntry \
("XineramaFullscreenEnabled", true); + // This was once loaded from kdeglobals.
+ xineramaEnabled = config.readEntry ("XineramaEnabled", true);
+ xineramaPlacementEnabled = config.readEntry ("XineramaPlacementEnabled", true);
+ xineramaMovementEnabled = config.readEntry ("XineramaMovementEnabled", true);
+ xineramaMaximizeEnabled = config.readEntry ("XineramaMaximizeEnabled", true);
+ xineramaFullscreenEnabled = config.readEntry ("XineramaFullscreenEnabled", \
true);
placement = Placement::policyFromString( config.readEntry("Placement"), true );
xineramaPlacementScreen = qBound( -1, config.readEntry( \
"XineramaPlacementScreen", -1 ), @@ -155,8 +193,29 @@ unsigned long \
Options::updateSettings()
hideUtilityWindowsForInactive = config.readEntry( \
"HideUtilityWindowsForInactive", true);
showDesktopIsMinimizeAll = config.readEntry( "ShowDesktopIsMinimizeAll", false \
);
+ // Read button tooltip animation effect from kdeglobals
+ // Since we want to allow users to enable window decoration tooltips
+ // and not kstyle tooltips and vise-versa, we don't read the
+ // "EffectNoTooltip" setting from kdeglobals.
+
+#if 0
+ FIXME: we have no mac style menu implementation in kwin anymore, so this just \
breaks + things for people!
+ KConfig _globalConfig("kdeglobals");
+ KConfigGroup globalConfig(&_globalConfig, "KDE");
+ topmenus = globalConfig.readEntry("macStyle", false);
+#else
+ topmenus = false;
+#endif
+
+ // QToolTip::setGloballyEnabled( d->show_tooltips );
+ // KDE4 this probably needs to be done manually in clients
+ }
+
+void Options::loadMouseBindings( KSharedConfigPtr configFile )
+ {
// Mouse bindings
- config = KConfigGroup(_config,"MouseBindings");
+ KConfigGroup config( configFile, "MouseBindings" );
CmdActiveTitlebar1 = \
mouseCommand(config.readEntry("CommandActiveTitlebar1","Raise"), true \
);
CmdActiveTitlebar2 = \
mouseCommand(config.readEntry("CommandActiveTitlebar2","Lower"), true \
);
CmdActiveTitlebar3 = \
mouseCommand(config.readEntry("CommandActiveTitlebar3","Operations menu"), true ); @@ \
-172,42 +231,19 @@ unsigned long Options::updateSettings()
CmdAll2 = mouseCommand(config.readEntry("CommandAll2","Toggle raise and lower"), \
false );
CmdAll3 = mouseCommand(config.readEntry("CommandAll3","Resize"), false );
CmdAllWheel = mouseWheelCommand(config.readEntry("CommandAllWheel","Nothing"));
+ }
- config=KConfigGroup(_config,"Compositing");
- refreshRate = config.readEntry( "RefreshRate", 0 );
-
- // Read button tooltip animation effect from kdeglobals
- // Since we want to allow users to enable window decoration tooltips
- // and not kstyle tooltips and vise-versa, we don't read the
- // "EffectNoTooltip" setting from kdeglobals.
-
-#if 0
- FIXME: we have no mac style menu implementation in kwin anymore, so this just \
breaks
- things for people!
- KConfig _globalConfig("kdeglobals");
- KConfigGroup globalConfig(&_globalConfig, "KDE");
- topmenus = globalConfig.readEntry("macStyle", false);
-#else
- topmenus = false;
-#endif
-
-// QToolTip::setGloballyEnabled( d->show_tooltips );
-// KDE4 this probably needs to be done manually in clients
-
+void Options::loadCompositingSettings( KSharedConfigPtr configFile )
+ {
// Driver-specific config detection
CompositingPrefs prefs;
prefs.detect();
- reloadCompositingSettings( prefs );
- return changed;
- }
+ // Compositing settings
+ KConfigGroup config( configFile, "Compositing");
-void Options::reloadCompositingSettings(const CompositingPrefs& prefs)
- {
- KSharedConfig::Ptr _config = KGlobal::config();
- KConfigGroup config(_config, "Compositing");
+ refreshRate = config.readEntry( "RefreshRate", 0 );
- // Compositing settings
useCompositing = config.readEntry("Enabled", prefs.enableCompositing());
QString compositingBackend = config.readEntry("Backend", "OpenGL");
if( compositingBackend == "XRender" )
diff --git a/options.h b/options.h
index c7bcd5f..db085f7 100644
--- a/options.h
+++ b/options.h
@@ -44,6 +44,7 @@ class Options : public KDecorationOptions
~Options();
virtual unsigned long updateSettings();
+ bool importBackup();
/*!
Different focus policies:
@@ -313,6 +314,12 @@ class Options : public KDecorationOptions
double animationTimeFactor() const;
private:
+ unsigned long loadSettings( KSharedConfigPtr configFile );
+ void loadWindowSettings( KSharedConfigPtr configFile );
+ void loadMouseBindings( KSharedConfigPtr configFile );
+ void loadCompositingSettings( KSharedConfigPtr configFile );
+
+
WindowOperation OpTitlebarDblClick;
// mouse bindings
@@ -342,7 +349,6 @@ class Options : public KDecorationOptions
int animationSpeed; // 0 - instant, 5 - very slow
MouseCommand wheelToMouseCommand( MouseWheelCommand com, int delta );
- void reloadCompositingSettings(const CompositingPrefs& prefs);
};
extern Options* options;
diff --git a/org.kde.KWin.xml b/org.kde.KWin.xml
index ec27372..ddc0605 100644
--- a/org.kde.KWin.xml
+++ b/org.kde.KWin.xml
@@ -34,7 +34,7 @@
<method name="previousDesktop"/>
<method name="circulateDesktopApplications"/>
<signal name="reloadConfig"/>
- <signal name="reinitCompositing"/>
+ <signal name="reloadCompositingConfig"/>
<method name="loadEffect">
<arg name="name" type="s" direction="in"/>
</method>
@@ -49,16 +49,13 @@
</method>
<method name="loadedEffects">
<arg type="as" direction="out"/>
- </method>
+ </method>
<method name="listOfEffects">
<arg type="as" direction="out"/>
</method>
<method name="compositingActive">
<arg type="b" direction="out"/>
</method>
- <method name="waitForCompositingSetup">
- <arg type="b" direction="out"/>
- </method>
<method name="decorationSupportedColors">
<arg type="ai" direction="out"/>
<annotation name="com.trolltech.QtDBus.QtTypeName.Out0" \
value="QList<int>"/>
diff --git a/workspace.cpp b/workspace.cpp
index 03f02c8..fccf285 100644
--- a/workspace.cpp
+++ b/workspace.cpp
@@ -147,7 +147,7 @@ Workspace::Workspace( bool restore )
QDBusConnection dbus = QDBusConnection::sessionBus();
dbus.registerObject("/KWin", this);
dbus.connect(QString(), "/KWin", "org.kde.KWin", "reloadConfig", this, \
SLOT(slotReloadConfig()));
- dbus.connect(QString(), "/KWin", "org.kde.KWin", "reinitCompositing", this, \
SLOT(slotReinitCompositing())); + dbus.connect(QString(), "/KWin", "org.kde.KWin", \
"reloadCompositingConfig", this, SLOT(slotReloadCompositingConfig())); _self = this;
mgr = new PluginMgr;
QX11Info info;
@@ -1081,15 +1081,17 @@ void Workspace::slotReconfigure()
}
}
-void Workspace::slotReinitCompositing()
+void Workspace::slotReloadCompositingConfig()
{
- // Reparse config. Config options will be reloaded by setupCompositing()
+ // Load the compositing settings from the test config.
KGlobal::config()->reparseConfiguration();
options->updateSettings();
- // Stop any current compositing
+ // Update any settings that can be set in the compositing kcm.
+ updateElectricBorders();
+
+ // Reinitialize compositing.
finishCompositing();
- // And start new one
setupCompositing();
if( effects ) // setupCompositing() may fail
effects->reconfigure();
diff --git a/workspace.h b/workspace.h
index 32a928d..c710bfd 100644
--- a/workspace.h
+++ b/workspace.h
@@ -469,7 +469,6 @@ class Workspace : public QObject, public KDecorationDefines
void reconfigure();
void slotReconfigure();
- void slotReinitCompositing();
void slotKillWindow();
@@ -500,6 +499,7 @@ class Workspace : public QObject, public KDecorationDefines
void writeWindowRules();
void slotBlockShortcuts(int data);
void slotReloadConfig();
+ void slotReloadCompositingConfig();
void setPopupClientOpacity( QAction* action );
void setupCompositing();
void performCompositing();
["cleanup.patch" (text/x-diff)]
commit 8732f1ce175c9c923b53708e0b32a59f1a0e93d1
Author: David Nadlinger <david.nadlinger@gmail.com>
Date: Wed Nov 19 21:00:35 2008 +0100
Fixed a little bug (dropdowns on the general tab were not updated correctly); \
removed a few unneeded functino calls and stale connects, cleaned up a bit.
diff --git a/kcmkwin/kwincompositing/main.cpp b/kcmkwin/kwincompositing/main.cpp
index 6a8ad45..2514420 100644
--- a/kcmkwin/kwincompositing/main.cpp
+++ b/kcmkwin/kwincompositing/main.cpp
@@ -88,8 +88,6 @@ KWinCompositingConfig::KWinCompositingConfig(QWidget *parent, const \
QVariantList
connect(ui.effectAnimations, SIGNAL(toggled(bool)), this, SLOT(changed()));
connect(ui.effectSelector, SIGNAL(changed(bool)), this, SLOT(changed()));
- connect(ui.effectSelector, SIGNAL(configCommitted(const QByteArray&)),
- this, SLOT(reparseConfiguration(const QByteArray&)));
connect(ui.windowSwitchingCombo, SIGNAL(currentIndexChanged(int)), this, \
SLOT(changed()));
connect(ui.desktopSwitchingCombo, SIGNAL(currentIndexChanged(int)), this, \
SLOT(changed())); @@ -98,7 +96,6 @@ \
KWinCompositingConfig::KWinCompositingConfig(QWidget *parent, const QVariantList \
connect(ui.edges_monitor, SIGNAL(changed()), this, SLOT(changed()));
connect(ui.edges_monitor, SIGNAL(edgeSelectionChanged(int,int)), this, \
SLOT(electricBorderSelectionChanged(int,int)));
- connect(ui.compositingType, SIGNAL(currentIndexChanged(int)), this, \
SLOT(compositingModeChanged()));
connect(ui.compositingType, SIGNAL(currentIndexChanged(int)), this, \
SLOT(changed()));
connect(ui.windowThumbnails, SIGNAL(activated(int)), this, SLOT(changed()));
connect(ui.disableChecks, SIGNAL(toggled(bool)), this, SLOT(changed()));
@@ -225,14 +222,16 @@ void KWinCompositingConfig::currentTabChanged(int tab)
// block signals to don't emit the changed()-signal by just switching the \
current tab blockSignals(true);
// write possible changes done to synchronize effect checkboxes and selector
+ // TODO: This segment is prone to fail when the UI is changed;
+ // you'll most likely not think of the hard coded numbers here when just \
changing the order of the tabs. if (tab == 0)
{
// General tab was activated
saveEffectsTab();
loadGeneralTab();
- }
- else
- {
+ }
+ else if ( tab == 2 )
+ {
// Effects tab was activated
saveGeneralTab();
loadEffectsTab();
@@ -263,6 +262,8 @@ void KWinCompositingConfig::loadGeneralTab()
#undef LOAD_EFFECT_CONFIG
// window switching
+ // Set current option to "none" if no plugin is activated.
+ ui.windowSwitchingCombo->setCurrentIndex( 0 );
if( effectEnabled( "boxswitch", effectconfig ))
ui.windowSwitchingCombo->setCurrentIndex( 1 );
if( effectEnabled( "coverswitch", effectconfig ))
@@ -274,14 +275,14 @@ void KWinCompositingConfig::loadGeneralTab()
ui.windowSwitchingCombo->setCurrentIndex( 2 );
// desktop switching
+ // Set current option to "none" if no plugin is activated.
+ ui.desktopSwitchingCombo->setCurrentIndex( 0 );
if( effectEnabled( "slide", effectconfig ))
ui.desktopSwitchingCombo->setCurrentIndex( 1 );
KConfigGroup cubeconfig(mNewConfig, "Effect-Cube");
if( effectEnabled( "cube", effectconfig ) && \
cubeconfig.readEntry("AnimateDesktopChange", false)) \
ui.desktopSwitchingCombo->setCurrentIndex( 2 );
-
- loadElectricBorders();
-}
+ }
bool KWinCompositingConfig::effectEnabled( const QString& effect, const \
KConfigGroup& cfg ) const {
@@ -332,11 +333,12 @@ void KWinCompositingConfig::load()
copyPluginsToTmpConfig();
loadGeneralTab();
+ loadElectricBorders();
loadEffectsTab();
loadAdvancedTab();
emit changed( false );
-}
+ }
void KWinCompositingConfig::saveGeneralTab()
{
@@ -420,9 +422,7 @@ void KWinCompositingConfig::saveGeneralTab()
}
KConfigGroup cubeconfig(mNewConfig, "Effect-Cube");
cubeconfig.writeEntry("AnimateDesktopChange", cubeDesktopSwitching);
-
- saveElectricBorders();
-}
+ }
void KWinCompositingConfig::saveEffectsTab()
{
diff --git a/workspace.cpp b/workspace.cpp
index fccf285..89e4d2c 100644
--- a/workspace.cpp
+++ b/workspace.cpp
@@ -972,19 +972,6 @@ void Workspace::reconfigure()
reconfigureTimer.start( 200 );
}
-// This DBUS call is used by the compositing kcm. Since the reconfigure()
-// DBUS call delays the actual reconfiguring, it is not possible to immediately
-// call compositingActive(). Therefore the kcm will instead call this to ensure
-// the reconfiguring has already happened.
-bool Workspace::waitForCompositingSetup()
- {
- if( !reconfigureTimer.isActive())
- return false;
- reconfigureTimer.stop();
- slotReconfigure();
- return compositingActive();
- }
-
void Workspace::slotSettingsChanged(int category)
{
kDebug(1212) << "Workspace::slotSettingsChanged()";
@@ -1065,7 +1052,6 @@ void Workspace::slotReconfigure()
setupCompositing();
if( effects ) // setupCompositing() may fail
effects->reconfigure();
- addRepaintFull();
}
else
finishCompositing();
diff --git a/workspace.h b/workspace.h
index c710bfd..4bc78ff 100644
--- a/workspace.h
+++ b/workspace.h
@@ -262,8 +262,7 @@ class Workspace : public QObject, public KDecorationDefines
void previousDesktop();
void circulateDesktopApplications();
bool compositingActive();
- bool waitForCompositingSetup();
-
+
void setCurrentScreen( int new_screen );
QString desktopName( int desk ) const;
["code-polishing.patch" (text/x-diff)]
commit 52d272953c4f3d0bdb334b6de06c1aa136d52789
Author: David Nadlinger <david.nadlinger@gmail.com>
Date: Wed Nov 19 21:05:05 2008 +0100
Added a few comments; changed indents to comply with the KWin coding standards.
diff --git a/kcmkwin/kwincompositing/main.cpp b/kcmkwin/kwincompositing/main.cpp
index 2514420..d923af3 100644
--- a/kcmkwin/kwincompositing/main.cpp
+++ b/kcmkwin/kwincompositing/main.cpp
@@ -113,23 +113,22 @@ KWinCompositingConfig::KWinCompositingConfig(QWidget *parent, \
const QVariantList
// Open the temporary config file
// Temporary conf file is used to synchronize effect checkboxes with effect
- // selector by loading/saving effects from/to temp config when active tab
- // changes.
+ // selector by loading/saving effects from/to temp config when active tab
+ // changes.
mTmpConfigFile.open();
mTmpConfig = KSharedConfig::openConfig(mTmpConfigFile.fileName());
if( CompositingPrefs::compositingPossible() )
- {
+ {
// Driver-specific config detection
mDefaultPrefs.detect();
-
initEffectSelector();
- // Load config
+ // Initialize the user interface with the config loaded from kwinrc.
load();
- }
+ }
else
- {
+ {
ui.useCompositing->setEnabled(false);
ui.useCompositing->setChecked(false);
compositingEnabled(false);
@@ -140,7 +139,7 @@ KWinCompositingConfig::KWinCompositingConfig(QWidget *parent, \
const QVariantList ui.statusTitleWidget->setText(text);
ui.statusTitleWidget->setPixmap(KTitleWidget::InfoMessage, \
KTitleWidget::ImageLeft); ui.statusTitleWidget->show();
- }
+ }
KAboutData *about = new KAboutData(I18N_NOOP("kcmkwincompositing"), 0,
ki18n("KWin Desktop Effects Configuration Module"),
@@ -182,7 +181,7 @@ KWinCompositingConfig::KWinCompositingConfig(QWidget *parent, \
const QVariantList ui.desktopSwitchingCombo->addItem(i18n("No Effect"));
ui.desktopSwitchingCombo->addItem(slide);
ui.desktopSwitchingCombo->addItem(cube);
-}
+ }
KWinCompositingConfig::~KWinCompositingConfig()
{
@@ -193,7 +192,8 @@ KWinCompositingConfig::~KWinCompositingConfig()
}
void KWinCompositingConfig::compositingEnabled(bool enabled)
-{
+ {
+ // Enable the other configuration tabs only when compositing is enabled.
ui.compositingOptionsContainer->setEnabled(enabled);
ui.tabWidget->setTabEnabled(1, enabled);
ui.tabWidget->setTabEnabled(2, enabled);
@@ -201,7 +201,7 @@ void KWinCompositingConfig::compositingEnabled(bool enabled)
}
void KWinCompositingConfig::initEffectSelector()
-{
+ {
// Find all .desktop files of the effects
KService::List offers = KServiceTypeTrader::self()->query("KWin/Effect");
QList<KPluginInfo> effectinfos = KPluginInfo::fromServices(offers);
@@ -215,17 +215,18 @@ void KWinCompositingConfig::initEffectSelector()
ui.effectSelector->addPlugins(effectinfos, KPluginSelector::ReadConfigFile, \
i18n("Demos"), "Demos", mTmpConfig);
ui.effectSelector->addPlugins(effectinfos, KPluginSelector::ReadConfigFile, \
i18n("Tests"), "Tests", mTmpConfig);
ui.effectSelector->addPlugins(effectinfos, KPluginSelector::ReadConfigFile, \
i18n("Tools"), "Tools", mTmpConfig);
-}
+ }
void KWinCompositingConfig::currentTabChanged(int tab)
-{
+ {
// block signals to don't emit the changed()-signal by just switching the \
current tab blockSignals(true);
+
// write possible changes done to synchronize effect checkboxes and selector
// TODO: This segment is prone to fail when the UI is changed;
// you'll most likely not think of the hard coded numbers here when just \
changing the order of the tabs. if (tab == 0)
- {
+ {
// General tab was activated
saveEffectsTab();
loadGeneralTab();
@@ -235,9 +236,10 @@ void KWinCompositingConfig::currentTabChanged(int tab)
// Effects tab was activated
saveGeneralTab();
loadEffectsTab();
- }
+ }
+
blockSignals(false);
-}
+ }
void KWinCompositingConfig::loadGeneralTab()
{
@@ -251,10 +253,11 @@ void KWinCompositingConfig::loadGeneralTab()
int winManagementEnabled = LOAD_EFFECT_CONFIG("presentwindows")
+ LOAD_EFFECT_CONFIG("desktopgrid")
+ LOAD_EFFECT_CONFIG("dialogparent");
- if (winManagementEnabled > 0 && winManagementEnabled < 3) {
+ if (winManagementEnabled > 0 && winManagementEnabled < 3)
+ {
ui.effectWinManagement->setTristate(true);
ui.effectWinManagement->setCheckState(Qt::PartiallyChecked);
- }
+ }
else
ui.effectWinManagement->setChecked(winManagementEnabled);
ui.effectShadows->setChecked(LOAD_EFFECT_CONFIG("shadow"));
@@ -285,19 +288,19 @@ void KWinCompositingConfig::loadGeneralTab()
}
bool KWinCompositingConfig::effectEnabled( const QString& effect, const \
KConfigGroup& cfg ) const
-{
+ {
KService::List services = KServiceTypeTrader::self()->query(
"KWin/Effect", "[X-KDE-PluginInfo-Name] == 'kwin4_effect_" + effect + "'");
if( services.isEmpty())
return false;
QVariant v = services.first()->property("X-KDE-PluginInfo-EnabledByDefault");
return cfg.readEntry("kwin4_effect_" + effect + "Enabled", v.toBool());
-}
+ }
void KWinCompositingConfig::loadEffectsTab()
-{
+ {
ui.effectSelector->load();
-}
+ }
void KWinCompositingConfig::loadAdvancedTab()
{
@@ -321,7 +324,7 @@ void KWinCompositingConfig::loadAdvancedTab()
ui.glVSync->setChecked(config.readEntry("GLVSync", \
mDefaultPrefs.enableVSync()));
ui.xrenderSmoothScale->setChecked(config.readEntry("XRenderSmoothScale", \
false));
-}
+ }
void KWinCompositingConfig::load()
{
@@ -350,11 +353,12 @@ void KWinCompositingConfig::saveGeneralTab()
// Save effects
KConfigGroup effectconfig(mTmpConfig, "Plugins");
#define WRITE_EFFECT_CONFIG(effectname, widget) \
effectconfig.writeEntry("kwin4_effect_" effectname "Enabled", \
widget->isChecked())
- if (ui.effectWinManagement->checkState() != Qt::PartiallyChecked) {
+ if (ui.effectWinManagement->checkState() != Qt::PartiallyChecked)
+ {
WRITE_EFFECT_CONFIG("presentwindows", ui.effectWinManagement);
WRITE_EFFECT_CONFIG("desktopgrid", ui.effectWinManagement);
WRITE_EFFECT_CONFIG("dialogparent", ui.effectWinManagement);
- }
+ }
WRITE_EFFECT_CONFIG("shadow", ui.effectShadows);
// TODO: maybe also do some effect-specific configuration here, e.g.
// enable/disable desktopgrid's animation according to this setting
@@ -425,9 +429,9 @@ void KWinCompositingConfig::saveGeneralTab()
}
void KWinCompositingConfig::saveEffectsTab()
-{
+ {
ui.effectSelector->save();
-}
+ }
void KWinCompositingConfig::saveAdvancedTab()
{
@@ -453,12 +457,14 @@ void KWinCompositingConfig::save()
// bah; tab content being dependent on the other is really bad; and
// deprecated in the HIG for a reason. Its confusing!
// Make sure we only call save on each tab once; as they are stateful due to the \
revert concept
- if (ui.tabWidget->currentIndex() == 0) { // general was active
+ if ( ui.tabWidget->currentIndex() == 0 ) // "General" tab was active
+ {
saveGeneralTab();
loadEffectsTab();
saveEffectsTab();
- }
- else { // effects tab was active
+ }
+ else
+ {
saveEffectsTab();
loadGeneralTab();
saveGeneralTab();
@@ -474,7 +480,7 @@ void KWinCompositingConfig::save()
}
void KWinCompositingConfig::defaults()
-{
+ {
ui.tabWidget->setCurrentIndex(0);
ui.useCompositing->setChecked(mDefaultPrefs.enableCompositing());
@@ -504,16 +510,16 @@ void KWinCompositingConfig::defaults()
}
// set top left to present windows
ui.edges_monitor->selectEdgeItem( (int)Monitor::TopLeft, (int)PresentWindowsAll \
);
-}
+ }
QString KWinCompositingConfig::quickHelp() const
-{
+ {
return i18n("<h1>Desktop Effects</h1>");
-}
+ }
void KWinCompositingConfig::setupElectricBorders()
-{
+ {
addItemToEdgesMonitor( i18n("No Effect"));
// search the effect names
@@ -545,18 +551,18 @@ void KWinCompositingConfig::setupElectricBorders()
{
addItemToEdgesMonitor( services.first()->name());
}
-}
+ }
void KWinCompositingConfig::addItemToEdgesMonitor(const QString& item)
-{
+ {
for( int i=0; i<8; i++ )
{
ui.edges_monitor->addEdgeItem( i, item );
}
-}
+ }
void KWinCompositingConfig::electricBorderSelectionChanged(int edge, int index)
-{
+ {
if( index == (int)NoEffect )
return;
for( int i=0; i<8; i++)
@@ -566,11 +572,11 @@ void KWinCompositingConfig::electricBorderSelectionChanged(int \
edge, int index) if( ui.edges_monitor->selectedEdgeItem( i ) == index )
ui.edges_monitor->selectEdgeItem( i, (int)NoEffect );
}
-}
+ }
void KWinCompositingConfig::loadElectricBorders()
-{
+ {
// Present Windows
KConfigGroup presentwindowsconfig(mNewConfig, "Effect-PresentWindows");
changeElectricBorder( (ElectricBorder)presentwindowsconfig.readEntry( \
"BorderActivateAll", @@ -593,10 +599,10 @@ void \
KWinCompositingConfig::loadElectricBorders() KConfigGroup sphereconfig(mNewConfig, \
"Effect-Sphere");
changeElectricBorder( (ElectricBorder)sphereconfig.readEntry( "BorderActivate",
int( ElectricNone )), (int)Sphere );
-}
+ }
void KWinCompositingConfig::changeElectricBorder( ElectricBorder border, int index )
-{
+ {
switch (border)
{
case ElectricTop:
@@ -627,10 +633,10 @@ void KWinCompositingConfig::changeElectricBorder( \
ElectricBorder border, int ind // nothing
break;
}
-}
+ }
ElectricBorder KWinCompositingConfig::checkEffectHasElectricBorder( int index )
-{
+ {
if( ui.edges_monitor->selectedEdgeItem( (int)Monitor::Top ) == index )
{
return ElectricTop;
@@ -664,7 +670,7 @@ ElectricBorder \
KWinCompositingConfig::checkEffectHasElectricBorder( int index ) return \
ElectricTopLeft; }
return ElectricNone;
-}
+ }
void KWinCompositingConfig::saveElectricBorders()
{
@@ -818,6 +824,5 @@ void KWinCompositingConfig::copyPluginsToNewConfig()
}
} // namespace
-
+
#include "main.moc"
-
diff --git a/options.cpp b/options.cpp
index 966c4b9..45f5466 100644
--- a/options.cpp
+++ b/options.cpp
@@ -119,7 +119,7 @@ void Options::loadWindowSettings( KSharedConfigPtr configFile )
altTabStyle = KDE; // what a default :-)
if ( val == "CDE" )
altTabStyle = CDE;
-
+
separateScreenFocus = config.readEntry( "SeparateScreenFocus", false );
activeMouseScreen = config.readEntry( "ActiveMouseScreen", focusPolicy != \
ClickToFocus );
@@ -274,10 +274,10 @@ void Options::loadCompositingSettings( KSharedConfigPtr \
configFile ) hiddenPreviews = HiddenPreviewsShown;
else if( hps == 6 )
hiddenPreviews = HiddenPreviewsAlways;
-
+
unredirectFullscreen = config.readEntry( "UnredirectFullscreen", true );
animationSpeed = qBound( 0, config.readEntry( "AnimationSpeed", 3 ), 6 );
-
+
if( !disableCompositingChecks && !prefs.validateSetup( compositingMode ))
useCompositing = false;
}
diff --git a/options.h b/options.h
index db085f7..45b9c6e 100644
--- a/options.h
+++ b/options.h
@@ -36,7 +36,7 @@ namespace KWin
class Client;
class CompositingPrefs;
-class Options : public KDecorationOptions
+class Options : public KDecorationOptions
{
public:
@@ -136,7 +136,7 @@ class Options : public KDecorationOptions
*/
enum AltTabStyle { KDE, CDE };
AltTabStyle altTabStyle;
-
+
// whether to see Xinerama screens separately for focus (in Alt+Tab, when \
activating next client) bool separateScreenFocus;
// whether active Xinerama screen is the one with mouse (or with the active \
window) @@ -150,7 +150,7 @@ class Options : public KDecorationOptions
bool xineramaMovementEnabled;
bool xineramaMaximizeEnabled;
bool xineramaFullscreenEnabled;
-
+
// number, or -1 = active screen (Workspace::activeScreen())
int xineramaPlacementScreen;
@@ -161,13 +161,13 @@ class Options : public KDecorationOptions
MoveResizeMode resizeMode;
MoveResizeMode moveMode;
-
+
static MoveResizeMode stringToMoveResizeMode( const QString& s );
static const char* moveResizeModeToString( MoveResizeMode mode );
Placement::Policy placement;
- bool focusPolicyIsReasonable()
+ bool focusPolicyIsReasonable()
{
return focusPolicy == ClickToFocus || focusPolicy == FocusFollowsMouse;
}
@@ -207,12 +207,12 @@ class Options : public KDecorationOptions
* List of window classes to ignore PPosition size hint
*/
QStringList ignorePositionClasses;
-
+
bool checkIgnoreFocusStealing( const Client* c );
WindowOperation operationTitlebarDblClick() { return OpTitlebarDblClick; }
- enum MouseCommand
+ enum MouseCommand
{
MouseRaise, MouseLower, MouseOperationsMenu, MouseToggleRaiseAndLower,
MouseActivateAndRaise, MouseActivateAndLower, MouseActivate,
@@ -227,7 +227,7 @@ class Options : public KDecorationOptions
MouseOpacityMore, MouseOpacityLess,
MouseNothing
};
-
+
enum MouseWheelCommand
{
MouseWheelRaiseLower, MouseWheelShadeUnshade, MouseWheelMaximizeRestore,
@@ -281,13 +281,13 @@ class Options : public KDecorationOptions
* @returns the activation delay for electric borders in milliseconds.
*/
int electricBorderDelay();
-
+
bool topMenuEnabled() const { return topmenus; }
bool desktopTopMenu() const { return desktop_topmenu; }
-
+
// timeout before non-responding application will be killed after attempt to \
close int killPingTimeout;
-
+
// Whether to hide utility windows for inactive applications.
bool hideUtilityWindowsForInactive;
@@ -297,7 +297,7 @@ class Options : public KDecorationOptions
HiddenPreviews hiddenPreviews;
bool unredirectFullscreen;
bool disableCompositingChecks;
-
+
uint refreshRate;
// This is for OpenGL mode
int smoothScale; // 0 = no, 1 = yes when transformed,
@@ -305,7 +305,7 @@ class Options : public KDecorationOptions
// -1 = auto
// This is for XRender mode
bool xrenderSmoothScale;
-
+
enum GLMode { GLTFP, GLSHM, GLFallback };
GLMode glMode;
bool glDirect;
@@ -322,7 +322,7 @@ class Options : public KDecorationOptions
WindowOperation OpTitlebarDblClick;
- // mouse bindings
+ // mouse bindings
MouseCommand CmdActiveTitlebar1;
MouseCommand CmdActiveTitlebar2;
MouseCommand CmdActiveTitlebar3;
diff --git a/workspace.cpp b/workspace.cpp
index 89e4d2c..d6037ee 100644
--- a/workspace.cpp
+++ b/workspace.cpp
@@ -994,6 +994,7 @@ void Workspace::slotReconfigure()
KGlobal::config()->reparseConfiguration();
unsigned long changed = options->updateSettings();
+
tab_box->reconfigure();
popupinfo->reconfigure();
initPositioning->reinitCascading( 0 );
@@ -2284,7 +2285,7 @@ void Workspace::electricBorderSwitchDesktop( ElectricBorder \
border, const QPoint int desk_before = currentDesktop();
setCurrentDesktop( desk );
if( currentDesktop() != desk_before )
- QCursor::setPos( pos );
+ QCursor::setPos( pos );
}
// this function is called when the user entered an electric border
_______________________________________________
kwin mailing list
kwin@kde.org
https://mail.kde.org/mailman/listinfo/kwin
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic