2007-11-27 19:40:25 +00:00
|
|
|
/********************************************************************
|
2007-07-19 16:20:05 +00:00
|
|
|
KWin - the KDE window manager
|
|
|
|
This file is part of the KDE project.
|
|
|
|
|
|
|
|
Copyright (C) 2007 Rivo Laks <rivolaks@hot.ee>
|
|
|
|
|
2007-11-27 19:40:25 +00:00
|
|
|
This program is free software; you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
the Free Software Foundation; either version 2 of the License, or
|
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*********************************************************************/
|
2007-07-19 16:20:05 +00:00
|
|
|
|
|
|
|
#include "main.h"
|
|
|
|
|
2008-08-15 11:09:07 +00:00
|
|
|
#include "kwin_interface.h"
|
2007-07-20 16:19:09 +00:00
|
|
|
|
2007-07-19 16:20:05 +00:00
|
|
|
#include <kaboutdata.h>
|
|
|
|
#include <kconfig.h>
|
|
|
|
#include <kconfiggroup.h>
|
|
|
|
#include <kdebug.h>
|
2008-08-15 11:09:07 +00:00
|
|
|
#include <kmessagebox.h>
|
2007-07-19 16:20:05 +00:00
|
|
|
#include <ksettings/dispatcher.h>
|
2007-09-18 10:09:07 +00:00
|
|
|
#include <kpluginselector.h>
|
|
|
|
#include <kservicetypetrader.h>
|
|
|
|
#include <kplugininfo.h>
|
|
|
|
#include <kservice.h>
|
2008-10-14 13:23:50 +00:00
|
|
|
#include <ktitlewidget.h>
|
2009-04-01 16:24:40 +00:00
|
|
|
#include <knotification.h>
|
2007-07-19 16:20:05 +00:00
|
|
|
|
|
|
|
#include <QtDBus/QtDBus>
|
2007-09-18 19:00:23 +00:00
|
|
|
#include <QTimer>
|
2007-09-18 19:38:57 +00:00
|
|
|
#include <QLabel>
|
2007-08-28 13:01:13 +00:00
|
|
|
#include <KPluginFactory>
|
|
|
|
#include <KPluginLoader>
|
2008-12-29 20:09:15 +00:00
|
|
|
#include <KIcon>
|
2007-07-19 16:20:05 +00:00
|
|
|
|
2007-08-28 13:01:13 +00:00
|
|
|
K_PLUGIN_FACTORY(KWinCompositingConfigFactory,
|
|
|
|
registerPlugin<KWin::KWinCompositingConfig>();
|
|
|
|
)
|
|
|
|
K_EXPORT_PLUGIN(KWinCompositingConfigFactory("kcmkwincompositing"))
|
2007-07-19 16:20:05 +00:00
|
|
|
|
|
|
|
namespace KWin
|
|
|
|
{
|
|
|
|
|
|
|
|
|
2007-09-18 19:00:23 +00:00
|
|
|
ConfirmDialog::ConfirmDialog() :
|
2008-08-29 12:03:12 +00:00
|
|
|
KTimerDialog(10000, KTimerDialog::CountDown, 0,
|
2007-10-05 16:36:17 +00:00
|
|
|
i18n("Confirm Desktop Effects Change"), KTimerDialog::Ok|KTimerDialog::Cancel,
|
|
|
|
KTimerDialog::Cancel)
|
2007-09-18 19:00:23 +00:00
|
|
|
{
|
2008-08-29 12:03:12 +00:00
|
|
|
setObjectName( "mainKTimerDialog" );
|
2007-10-05 16:36:17 +00:00
|
|
|
setButtonGuiItem( KDialog::Ok, KGuiItem( i18n( "&Accept Configuration" ), "dialog-ok" ));
|
|
|
|
setButtonGuiItem( KDialog::Cancel, KGuiItem( i18n( "&Return to Previous Configuration" ), "dialog-cancel" ));
|
|
|
|
|
|
|
|
QLabel *label = new QLabel( i18n( "Desktop effects settings have changed.\n"
|
|
|
|
"Do you want to keep the new settings?\n"
|
|
|
|
"They will be automatically reverted in 10 seconds." ), this );
|
|
|
|
label->setWordWrap( true );
|
|
|
|
setMainWidget( label );
|
2008-12-29 20:09:15 +00:00
|
|
|
|
|
|
|
setWindowIcon(KIcon("preferences-desktop-effect"));
|
2007-09-18 19:00:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-08-28 13:01:13 +00:00
|
|
|
KWinCompositingConfig::KWinCompositingConfig(QWidget *parent, const QVariantList &)
|
2008-12-08 05:08:31 +00:00
|
|
|
: KCModule( KWinCompositingConfigFactory::componentData(), parent )
|
|
|
|
, mKWinConfig(KSharedConfig::openConfig( "kwinrc" ))
|
|
|
|
, m_showConfirmDialog( false )
|
2009-04-18 10:07:16 +00:00
|
|
|
, kwinInterface( NULL )
|
2008-11-25 01:42:30 +00:00
|
|
|
{
|
2007-11-13 17:29:46 +00:00
|
|
|
KGlobal::locale()->insertCatalog( "kwin_effects" );
|
2007-07-19 16:20:05 +00:00
|
|
|
ui.setupUi(this);
|
2007-12-17 08:26:19 +00:00
|
|
|
layout()->setMargin(0);
|
2009-06-24 13:09:58 +00:00
|
|
|
ui.verticalSpacer->changeSize(20, KDialog::groupSpacingHint());
|
|
|
|
ui.verticalSpacer_2->changeSize(20, KDialog::groupSpacingHint());
|
2007-09-18 10:09:07 +00:00
|
|
|
ui.tabWidget->setCurrentIndex(0);
|
2008-10-14 13:23:50 +00:00
|
|
|
ui.statusTitleWidget->hide();
|
2007-07-19 16:20:05 +00:00
|
|
|
|
2008-12-08 11:00:01 +00:00
|
|
|
#define OPENGL_INDEX 0
|
|
|
|
#define XRENDER_INDEX 1
|
2008-12-08 10:48:38 +00:00
|
|
|
#ifndef KWIN_HAVE_OPENGL_COMPOSITING
|
2008-12-08 11:00:01 +00:00
|
|
|
ui.compositingType->removeItem( OPENGL_INDEX );
|
|
|
|
ui.glGroup->setEnabled( false );
|
|
|
|
#define OPENGL_INDEX -1
|
|
|
|
#define XRENDER_INDEX 0
|
2008-12-08 10:48:38 +00:00
|
|
|
#endif
|
|
|
|
#ifndef KWIN_HAVE_XRENDER_COMPOSITING
|
2008-12-08 11:00:01 +00:00
|
|
|
ui.compositingType->removeItem( XRENDER_INDEX );
|
|
|
|
ui.xrenderGroup->setEnabled( false );
|
|
|
|
#define XRENDER_INDEX -1
|
2008-12-08 10:48:38 +00:00
|
|
|
#endif
|
|
|
|
|
2009-04-18 10:07:16 +00:00
|
|
|
kwinInterface = new OrgKdeKWinInterface( "org.kde.kwin", "/KWin", QDBusConnection::sessionBus() );
|
|
|
|
|
2007-09-18 10:09:07 +00:00
|
|
|
connect(ui.useCompositing, SIGNAL(toggled(bool)), this, SLOT(compositingEnabled(bool)));
|
2007-09-20 13:21:49 +00:00
|
|
|
connect(ui.tabWidget, SIGNAL(currentChanged(int)), this, SLOT(currentTabChanged(int)));
|
2007-07-19 16:20:05 +00:00
|
|
|
|
|
|
|
connect(ui.useCompositing, SIGNAL(toggled(bool)), this, SLOT(changed()));
|
2007-07-21 20:54:50 +00:00
|
|
|
connect(ui.effectWinManagement, SIGNAL(toggled(bool)), this, SLOT(changed()));
|
|
|
|
connect(ui.effectShadows, SIGNAL(toggled(bool)), this, SLOT(changed()));
|
|
|
|
connect(ui.effectAnimations, SIGNAL(toggled(bool)), this, SLOT(changed()));
|
2007-07-19 16:20:05 +00:00
|
|
|
|
2007-09-18 10:09:07 +00:00
|
|
|
connect(ui.effectSelector, SIGNAL(changed(bool)), this, SLOT(changed()));
|
2008-12-08 05:08:31 +00:00
|
|
|
connect(ui.effectSelector, SIGNAL(configCommitted(const QByteArray&)),
|
|
|
|
this, SLOT(reparseConfiguration(const QByteArray&)));
|
2007-09-18 10:09:07 +00:00
|
|
|
|
2008-08-26 07:31:57 +00:00
|
|
|
connect(ui.windowSwitchingCombo, SIGNAL(currentIndexChanged(int)), this, SLOT(changed()));
|
|
|
|
connect(ui.desktopSwitchingCombo, SIGNAL(currentIndexChanged(int)), this, SLOT(changed()));
|
2008-08-30 07:25:54 +00:00
|
|
|
connect(ui.animationSpeedCombo, SIGNAL(currentIndexChanged(int)), this, SLOT(changed()));
|
2008-08-26 07:31:57 +00:00
|
|
|
|
2008-11-14 12:36:59 +00:00
|
|
|
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()));
|
|
|
|
connect(ui.glMode, SIGNAL(currentIndexChanged(int)), this, SLOT(changed()));
|
|
|
|
connect(ui.glTextureFilter, SIGNAL(currentIndexChanged(int)), this, SLOT(changed()));
|
|
|
|
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()));
|
2009-04-18 10:07:16 +00:00
|
|
|
connect(ui.compositingStateButton, SIGNAL(clicked(bool)), kwinInterface, SLOT(toggleCompositing()));
|
|
|
|
connect(kwinInterface, SIGNAL(compositingToggled(bool)), this, SLOT(setupCompositingState(bool)));
|
2008-11-14 12:36:59 +00:00
|
|
|
|
2009-11-29 20:35:47 +00:00
|
|
|
// NOTICE: this is intended to workaround broken GL implementations that succesfully segfault on glXQuery :-(
|
|
|
|
KConfigGroup gl_workaround_config(mKWinConfig, "Compositing");
|
|
|
|
bool checkIsSave = gl_workaround_config.readEntry("CheckIsSafe", true);
|
|
|
|
gl_workaround_config.writeEntry("CheckIsSafe", false);
|
|
|
|
gl_workaround_config.sync();
|
|
|
|
|
2008-12-08 05:08:31 +00:00
|
|
|
// 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.
|
|
|
|
mTmpConfigFile.open();
|
|
|
|
mTmpConfig = KSharedConfig::openConfig(mTmpConfigFile.fileName());
|
2008-11-25 01:42:30 +00:00
|
|
|
|
2009-11-29 20:35:47 +00:00
|
|
|
if( checkIsSave && CompositingPrefs::compositingPossible() )
|
2008-11-25 01:45:09 +00:00
|
|
|
{
|
2007-09-26 16:35:30 +00:00
|
|
|
// Driver-specific config detection
|
|
|
|
mDefaultPrefs.detect();
|
|
|
|
initEffectSelector();
|
2008-11-25 01:45:09 +00:00
|
|
|
// Initialize the user interface with the config loaded from kwinrc.
|
2007-09-26 16:35:30 +00:00
|
|
|
load();
|
2008-11-25 01:45:09 +00:00
|
|
|
}
|
2007-09-26 16:35:30 +00:00
|
|
|
else
|
2008-11-25 01:45:09 +00:00
|
|
|
{
|
2007-09-26 16:35:30 +00:00
|
|
|
ui.useCompositing->setEnabled(false);
|
|
|
|
ui.useCompositing->setChecked(false);
|
|
|
|
compositingEnabled(false);
|
2007-09-27 13:26:55 +00:00
|
|
|
|
2007-11-12 16:32:25 +00:00
|
|
|
QString text = i18n("Compositing is not supported on your system.");
|
2008-10-14 13:23:50 +00:00
|
|
|
text += "<br>";
|
2007-11-12 16:32:25 +00:00
|
|
|
text += CompositingPrefs::compositingNotPossibleReason();
|
2008-10-14 13:23:50 +00:00
|
|
|
ui.statusTitleWidget->setText(text);
|
|
|
|
ui.statusTitleWidget->setPixmap(KTitleWidget::InfoMessage, KTitleWidget::ImageLeft);
|
|
|
|
ui.statusTitleWidget->show();
|
2009-04-18 10:07:16 +00:00
|
|
|
|
|
|
|
setupCompositingState( false, false );
|
2008-11-25 01:45:09 +00:00
|
|
|
}
|
2007-07-19 16:20:05 +00:00
|
|
|
|
2009-11-29 20:35:47 +00:00
|
|
|
gl_workaround_config.writeEntry("CheckIsSafe", checkIsSave);
|
|
|
|
gl_workaround_config.sync();
|
|
|
|
|
2007-07-19 16:20:05 +00:00
|
|
|
KAboutData *about = new KAboutData(I18N_NOOP("kcmkwincompositing"), 0,
|
2007-07-20 16:19:09 +00:00
|
|
|
ki18n("KWin Desktop Effects Configuration Module"),
|
2007-07-19 16:20:05 +00:00
|
|
|
0, KLocalizedString(), KAboutData::License_GPL, ki18n("(c) 2007 Rivo Laks"));
|
|
|
|
about->addAuthor(ki18n("Rivo Laks"), KLocalizedString(), "rivolaks@hot.ee");
|
|
|
|
setAboutData(about);
|
2008-08-26 07:31:57 +00:00
|
|
|
|
|
|
|
// search the effect names
|
|
|
|
KServiceTypeTrader* trader = KServiceTypeTrader::self();
|
|
|
|
KService::List services;
|
2009-01-15 09:55:15 +00:00
|
|
|
QString boxswitch, presentwindows, coverswitch, flipswitch, slide, cube, fadedesktop;
|
2008-08-26 07:31:57 +00:00
|
|
|
// window switcher
|
|
|
|
services = trader->query("KWin/Effect", "[X-KDE-PluginInfo-Name] == 'kwin4_effect_boxswitch'");
|
|
|
|
if( !services.isEmpty() )
|
|
|
|
boxswitch = services.first()->name();
|
|
|
|
services = trader->query("KWin/Effect", "[X-KDE-PluginInfo-Name] == 'kwin4_effect_presentwindows'");
|
|
|
|
if( !services.isEmpty() )
|
|
|
|
presentwindows = services.first()->name();
|
|
|
|
services = trader->query("KWin/Effect", "[X-KDE-PluginInfo-Name] == 'kwin4_effect_coverswitch'");
|
|
|
|
if( !services.isEmpty() )
|
|
|
|
coverswitch = services.first()->name();
|
|
|
|
services = trader->query("KWin/Effect", "[X-KDE-PluginInfo-Name] == 'kwin4_effect_flipswitch'");
|
|
|
|
if( !services.isEmpty() )
|
|
|
|
flipswitch = services.first()->name();
|
|
|
|
// desktop switcher
|
|
|
|
services = trader->query("KWin/Effect", "[X-KDE-PluginInfo-Name] == 'kwin4_effect_slide'");
|
|
|
|
if( !services.isEmpty() )
|
|
|
|
slide = services.first()->name();
|
2009-02-06 18:53:16 +00:00
|
|
|
services = trader->query("KWin/Effect", "[X-KDE-PluginInfo-Name] == 'kwin4_effect_cubeslide'");
|
2008-08-26 07:31:57 +00:00
|
|
|
if( !services.isEmpty() )
|
|
|
|
cube = services.first()->name();
|
2009-01-15 09:55:15 +00:00
|
|
|
services = trader->query("KWin/Effect", "[X-KDE-PluginInfo-Name] == 'kwin4_effect_fadedesktop'");
|
|
|
|
if( !services.isEmpty() )
|
|
|
|
fadedesktop = services.first()->name();
|
2008-08-26 07:31:57 +00:00
|
|
|
// init the combo boxes
|
|
|
|
ui.windowSwitchingCombo->addItem(i18n("No Effect"));
|
|
|
|
ui.windowSwitchingCombo->addItem(boxswitch);
|
|
|
|
ui.windowSwitchingCombo->addItem(presentwindows);
|
|
|
|
ui.windowSwitchingCombo->addItem(coverswitch);
|
|
|
|
ui.windowSwitchingCombo->addItem(flipswitch);
|
|
|
|
|
|
|
|
ui.desktopSwitchingCombo->addItem(i18n("No Effect"));
|
|
|
|
ui.desktopSwitchingCombo->addItem(slide);
|
|
|
|
ui.desktopSwitchingCombo->addItem(cube);
|
2009-01-15 09:55:15 +00:00
|
|
|
ui.desktopSwitchingCombo->addItem(fadedesktop);
|
2008-11-25 01:45:09 +00:00
|
|
|
}
|
2007-07-19 16:20:05 +00:00
|
|
|
|
|
|
|
KWinCompositingConfig::~KWinCompositingConfig()
|
2008-11-25 01:42:30 +00:00
|
|
|
{
|
|
|
|
}
|
2008-12-05 18:41:24 +00:00
|
|
|
|
|
|
|
void KWinCompositingConfig::reparseConfiguration( const QByteArray& conf )
|
|
|
|
{
|
|
|
|
KSettings::Dispatcher::reparseConfiguration( conf );
|
|
|
|
}
|
2007-09-18 10:09:07 +00:00
|
|
|
|
2008-12-08 05:08:31 +00:00
|
|
|
void KWinCompositingConfig::compositingEnabled( bool enabled )
|
2008-11-25 01:45:09 +00:00
|
|
|
{
|
|
|
|
// Enable the other configuration tabs only when compositing is enabled.
|
2007-09-18 10:09:07 +00:00
|
|
|
ui.compositingOptionsContainer->setEnabled(enabled);
|
|
|
|
ui.tabWidget->setTabEnabled(1, enabled);
|
2008-11-14 11:53:25 +00:00
|
|
|
ui.tabWidget->setTabEnabled(2, enabled);
|
2008-08-15 11:09:07 +00:00
|
|
|
}
|
2007-09-18 19:00:23 +00:00
|
|
|
|
2008-12-08 05:08:31 +00:00
|
|
|
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;
|
2009-04-18 10:07:16 +00:00
|
|
|
else
|
|
|
|
{
|
|
|
|
// compositing is enabled now
|
|
|
|
setupCompositingState( kwinInterface->compositingActive() );
|
2009-09-11 21:03:24 +00:00
|
|
|
checkLoadedEffects();
|
2009-04-18 10:07:16 +00:00
|
|
|
}
|
2008-12-08 05:08:31 +00:00
|
|
|
}
|
|
|
|
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();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-09-18 10:09:07 +00:00
|
|
|
void KWinCompositingConfig::initEffectSelector()
|
2008-11-25 01:45:09 +00:00
|
|
|
{
|
2007-09-18 10:09:07 +00:00
|
|
|
// Find all .desktop files of the effects
|
|
|
|
KService::List offers = KServiceTypeTrader::self()->query("KWin/Effect");
|
|
|
|
QList<KPluginInfo> effectinfos = KPluginInfo::fromServices(offers);
|
|
|
|
|
|
|
|
// Add them to the plugin selector
|
2008-12-08 05:08:31 +00:00
|
|
|
ui.effectSelector->addPlugins(effectinfos, KPluginSelector::ReadConfigFile, i18n("Appearance"), "Appearance", mTmpConfig);
|
|
|
|
ui.effectSelector->addPlugins(effectinfos, KPluginSelector::ReadConfigFile, i18n("Accessibility"), "Accessibility", mTmpConfig);
|
|
|
|
ui.effectSelector->addPlugins(effectinfos, KPluginSelector::ReadConfigFile, i18n("Focus"), "Focus", mTmpConfig);
|
|
|
|
ui.effectSelector->addPlugins(effectinfos, KPluginSelector::ReadConfigFile, i18n("Window Management"), "Window Management", mTmpConfig);
|
|
|
|
ui.effectSelector->addPlugins(effectinfos, KPluginSelector::ReadConfigFile, i18n("Candy"), "Candy", mTmpConfig);
|
|
|
|
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);
|
2008-11-25 01:45:09 +00:00
|
|
|
}
|
2007-09-18 10:09:07 +00:00
|
|
|
|
2007-09-20 13:21:49 +00:00
|
|
|
void KWinCompositingConfig::currentTabChanged(int tab)
|
2008-11-25 01:45:09 +00:00
|
|
|
{
|
2008-07-20 12:38:33 +00:00
|
|
|
// block signals to don't emit the changed()-signal by just switching the current tab
|
|
|
|
blockSignals(true);
|
2008-11-25 01:45:09 +00:00
|
|
|
|
2008-07-20 12:38:33 +00:00
|
|
|
// write possible changes done to synchronize effect checkboxes and selector
|
2008-11-25 01:42:30 +00:00
|
|
|
// 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.
|
2007-09-20 13:21:49 +00:00
|
|
|
if (tab == 0)
|
2008-11-25 01:45:09 +00:00
|
|
|
{
|
2007-09-20 13:21:49 +00:00
|
|
|
// General tab was activated
|
|
|
|
saveEffectsTab();
|
|
|
|
loadGeneralTab();
|
2008-11-25 01:42:30 +00:00
|
|
|
}
|
2009-02-27 15:40:53 +00:00
|
|
|
else if ( tab == 1 )
|
2008-11-25 01:42:30 +00:00
|
|
|
{
|
2007-09-20 13:21:49 +00:00
|
|
|
// Effects tab was activated
|
|
|
|
saveGeneralTab();
|
|
|
|
loadEffectsTab();
|
2008-11-25 01:45:09 +00:00
|
|
|
}
|
|
|
|
|
2008-07-20 12:38:33 +00:00
|
|
|
blockSignals(false);
|
2008-11-25 01:45:09 +00:00
|
|
|
}
|
2007-07-19 16:20:05 +00:00
|
|
|
|
2007-09-20 13:21:49 +00:00
|
|
|
void KWinCompositingConfig::loadGeneralTab()
|
2008-11-25 01:42:30 +00:00
|
|
|
{
|
2008-12-08 05:08:31 +00:00
|
|
|
KConfigGroup config(mKWinConfig, "Compositing");
|
2009-04-18 10:07:16 +00:00
|
|
|
bool enabled = config.readEntry("Enabled", mDefaultPrefs.enableCompositing());
|
|
|
|
ui.useCompositing->setChecked( enabled );
|
2008-08-30 07:25:54 +00:00
|
|
|
ui.animationSpeedCombo->setCurrentIndex(config.readEntry("AnimationSpeed", 3 ));
|
2007-07-19 16:20:05 +00:00
|
|
|
|
2007-07-21 20:54:50 +00:00
|
|
|
// Load effect settings
|
2008-12-08 05:08:31 +00:00
|
|
|
KConfigGroup effectconfig(mTmpConfig, "Plugins");
|
2007-09-20 13:21:49 +00:00
|
|
|
#define LOAD_EFFECT_CONFIG(effectname) effectconfig.readEntry("kwin4_effect_" effectname "Enabled", true)
|
2007-12-10 19:04:21 +00:00
|
|
|
int winManagementEnabled = LOAD_EFFECT_CONFIG("presentwindows")
|
|
|
|
+ LOAD_EFFECT_CONFIG("desktopgrid")
|
2008-08-05 12:41:31 +00:00
|
|
|
+ LOAD_EFFECT_CONFIG("dialogparent");
|
2008-11-25 01:45:09 +00:00
|
|
|
if (winManagementEnabled > 0 && winManagementEnabled < 3)
|
|
|
|
{
|
2007-12-10 19:04:21 +00:00
|
|
|
ui.effectWinManagement->setTristate(true);
|
|
|
|
ui.effectWinManagement->setCheckState(Qt::PartiallyChecked);
|
2008-11-25 01:45:09 +00:00
|
|
|
}
|
2007-12-10 19:04:21 +00:00
|
|
|
else
|
|
|
|
ui.effectWinManagement->setChecked(winManagementEnabled);
|
2007-07-21 20:54:50 +00:00
|
|
|
ui.effectShadows->setChecked(LOAD_EFFECT_CONFIG("shadow"));
|
|
|
|
ui.effectAnimations->setChecked(LOAD_EFFECT_CONFIG("minimizeanimation"));
|
2007-09-20 13:21:49 +00:00
|
|
|
#undef LOAD_EFFECT_CONFIG
|
2008-08-26 07:31:57 +00:00
|
|
|
|
|
|
|
// window switching
|
2008-11-25 01:42:30 +00:00
|
|
|
// Set current option to "none" if no plugin is activated.
|
|
|
|
ui.windowSwitchingCombo->setCurrentIndex( 0 );
|
2009-09-13 11:36:45 +00:00
|
|
|
KConfigGroup boxswitchconfig(mKWinConfig, "Effect-BoxSwitch");
|
|
|
|
if( effectEnabled( "boxswitch", effectconfig ) && boxswitchconfig.readEntry("TabBox", true))
|
2008-08-26 07:31:57 +00:00
|
|
|
ui.windowSwitchingCombo->setCurrentIndex( 1 );
|
2009-09-13 11:36:45 +00:00
|
|
|
KConfigGroup coverswitchconfig(mKWinConfig, "Effect-CoverSwitch");
|
|
|
|
if( effectEnabled( "coverswitch", effectconfig ) && coverswitchconfig.readEntry("TabBox", false))
|
2008-08-26 07:31:57 +00:00
|
|
|
ui.windowSwitchingCombo->setCurrentIndex( 3 );
|
2009-07-21 10:18:48 +00:00
|
|
|
KConfigGroup flipswitchconfig(mKWinConfig, "Effect-FlipSwitch");
|
|
|
|
if( effectEnabled( "flipswitch", effectconfig ) && flipswitchconfig.readEntry("TabBox", false))
|
2008-08-26 07:31:57 +00:00
|
|
|
ui.windowSwitchingCombo->setCurrentIndex( 4 );
|
2008-12-08 05:08:31 +00:00
|
|
|
KConfigGroup presentwindowsconfig(mKWinConfig, "Effect-PresentWindows");
|
2008-10-01 15:21:21 +00:00
|
|
|
if( effectEnabled( "presentwindows", effectconfig ) && presentwindowsconfig.readEntry("TabBox", false) )
|
2008-08-26 07:31:57 +00:00
|
|
|
ui.windowSwitchingCombo->setCurrentIndex( 2 );
|
|
|
|
|
|
|
|
// desktop switching
|
2008-11-25 01:42:30 +00:00
|
|
|
// Set current option to "none" if no plugin is activated.
|
|
|
|
ui.desktopSwitchingCombo->setCurrentIndex( 0 );
|
2008-10-01 15:21:21 +00:00
|
|
|
if( effectEnabled( "slide", effectconfig ))
|
2008-08-26 07:31:57 +00:00
|
|
|
ui.desktopSwitchingCombo->setCurrentIndex( 1 );
|
2009-02-06 18:53:16 +00:00
|
|
|
if( effectEnabled( "cubeslide", effectconfig ))
|
2008-08-26 07:31:57 +00:00
|
|
|
ui.desktopSwitchingCombo->setCurrentIndex( 2 );
|
2009-01-15 09:55:15 +00:00
|
|
|
if( effectEnabled( "fadedesktop", effectconfig ))
|
|
|
|
ui.desktopSwitchingCombo->setCurrentIndex( 3 );
|
2009-04-18 10:07:16 +00:00
|
|
|
|
|
|
|
if( enabled )
|
|
|
|
setupCompositingState( kwinInterface->compositingActive() );
|
|
|
|
else
|
|
|
|
setupCompositingState( false, false );
|
|
|
|
}
|
|
|
|
|
|
|
|
void KWinCompositingConfig::setupCompositingState( bool active, bool enabled )
|
|
|
|
{
|
2009-10-30 08:10:35 +00:00
|
|
|
if( !qgetenv( "KDE_FAILSAFE" ).isNull() )
|
2009-06-26 15:29:00 +00:00
|
|
|
enabled = false;
|
2009-04-18 10:07:16 +00:00
|
|
|
// 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" );
|
|
|
|
}
|
2009-06-24 13:09:58 +00:00
|
|
|
const int iconSize = (QApplication::fontMetrics().height() > 24) ? 32 : 22;
|
|
|
|
ui.compositingStateIcon->setPixmap( KIcon( stateIcon ).pixmap( iconSize, iconSize ) );
|
2009-04-18 10:07:16 +00:00
|
|
|
ui.compositingStateLabel->setText( stateText );
|
|
|
|
ui.compositingStateButton->setText( stateButtonText );
|
|
|
|
ui.compositingStateIcon->setEnabled( enabled );
|
|
|
|
ui.compositingStateLabel->setEnabled( enabled );
|
|
|
|
ui.compositingStateButton->setEnabled( enabled );
|
2008-11-25 01:42:30 +00:00
|
|
|
}
|
2007-07-21 20:54:50 +00:00
|
|
|
|
2008-10-01 15:21:21 +00:00
|
|
|
bool KWinCompositingConfig::effectEnabled( const QString& effect, const KConfigGroup& cfg ) const
|
2008-11-25 01:45:09 +00:00
|
|
|
{
|
2008-10-01 15:21:21 +00:00
|
|
|
KService::List services = KServiceTypeTrader::self()->query(
|
2009-10-30 06:51:59 +00:00
|
|
|
"KWin/Effect", "[X-KDE-PluginInfo-Name] == 'kwin4_effect_" + effect + '\'');
|
2008-10-01 15:21:21 +00:00
|
|
|
if( services.isEmpty())
|
|
|
|
return false;
|
|
|
|
QVariant v = services.first()->property("X-KDE-PluginInfo-EnabledByDefault");
|
|
|
|
return cfg.readEntry("kwin4_effect_" + effect + "Enabled", v.toBool());
|
2008-11-25 01:45:09 +00:00
|
|
|
}
|
2008-10-01 15:21:21 +00:00
|
|
|
|
2007-09-20 13:21:49 +00:00
|
|
|
void KWinCompositingConfig::loadEffectsTab()
|
2008-11-25 01:45:09 +00:00
|
|
|
{
|
2007-09-18 10:09:07 +00:00
|
|
|
ui.effectSelector->load();
|
2008-11-25 01:45:09 +00:00
|
|
|
}
|
2007-07-19 16:20:05 +00:00
|
|
|
|
2008-11-14 12:36:59 +00:00
|
|
|
void KWinCompositingConfig::loadAdvancedTab()
|
2008-11-25 01:42:30 +00:00
|
|
|
{
|
2008-12-08 05:08:31 +00:00
|
|
|
KConfigGroup config(mKWinConfig, "Compositing");
|
2008-11-14 12:36:59 +00:00
|
|
|
QString backend = config.readEntry("Backend", "OpenGL");
|
2008-12-08 11:00:01 +00:00
|
|
|
ui.compositingType->setCurrentIndex((backend == "XRender") ? XRENDER_INDEX : 0);
|
2008-11-14 12:36:59 +00:00
|
|
|
// 4 - off, 5 - shown, 6 - always, other are old values
|
|
|
|
int hps = config.readEntry("HiddenPreviews", 5);
|
|
|
|
if( hps == 6 ) // always
|
|
|
|
ui.windowThumbnails->setCurrentIndex( 0 );
|
|
|
|
else if( hps == 4 ) // never
|
|
|
|
ui.windowThumbnails->setCurrentIndex( 2 );
|
|
|
|
else // shown, or default
|
|
|
|
ui.windowThumbnails->setCurrentIndex( 1 );
|
|
|
|
ui.disableChecks->setChecked( config.readEntry( "DisableChecks", false ));
|
|
|
|
|
|
|
|
QString glMode = config.readEntry("GLMode", "TFP");
|
|
|
|
ui.glMode->setCurrentIndex((glMode == "TFP") ? 0 : ((glMode == "SHM") ? 1 : 2));
|
|
|
|
ui.glTextureFilter->setCurrentIndex(config.readEntry("GLTextureFilter", 1));
|
|
|
|
ui.glDirect->setChecked(config.readEntry("GLDirect", mDefaultPrefs.enableDirectRendering()));
|
|
|
|
ui.glVSync->setChecked(config.readEntry("GLVSync", mDefaultPrefs.enableVSync()));
|
|
|
|
|
|
|
|
ui.xrenderSmoothScale->setChecked(config.readEntry("XRenderSmoothScale", false));
|
2008-11-25 01:45:09 +00:00
|
|
|
}
|
2008-11-14 12:36:59 +00:00
|
|
|
|
2007-09-20 13:21:49 +00:00
|
|
|
void KWinCompositingConfig::load()
|
|
|
|
{
|
2008-12-08 05:08:31 +00:00
|
|
|
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());
|
2007-09-20 13:21:49 +00:00
|
|
|
|
|
|
|
loadGeneralTab();
|
|
|
|
loadEffectsTab();
|
2008-11-14 12:36:59 +00:00
|
|
|
loadAdvancedTab();
|
2007-09-20 13:21:49 +00:00
|
|
|
|
|
|
|
emit changed( false );
|
2008-11-25 01:42:30 +00:00
|
|
|
}
|
2007-09-20 13:21:49 +00:00
|
|
|
|
2007-12-30 14:07:38 +00:00
|
|
|
void KWinCompositingConfig::saveGeneralTab()
|
2008-11-25 01:42:30 +00:00
|
|
|
{
|
2008-12-08 05:08:31 +00:00
|
|
|
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;
|
2007-09-18 19:00:23 +00:00
|
|
|
|
2007-07-19 16:20:05 +00:00
|
|
|
config.writeEntry("Enabled", ui.useCompositing->isChecked());
|
2008-08-30 07:25:54 +00:00
|
|
|
config.writeEntry("AnimationSpeed", ui.animationSpeedCombo->currentIndex());
|
2007-07-19 16:20:05 +00:00
|
|
|
|
2009-04-18 10:07:16 +00:00
|
|
|
// disable the compositing state if compositing was turned off
|
|
|
|
if( !ui.useCompositing->isChecked() )
|
|
|
|
setupCompositingState( false, false );
|
|
|
|
|
2007-07-21 20:54:50 +00:00
|
|
|
// Save effects
|
2008-12-08 05:08:31 +00:00
|
|
|
KConfigGroup effectconfig(mTmpConfig, "Plugins");
|
2007-09-20 13:21:49 +00:00
|
|
|
#define WRITE_EFFECT_CONFIG(effectname, widget) effectconfig.writeEntry("kwin4_effect_" effectname "Enabled", widget->isChecked())
|
2008-11-25 01:45:09 +00:00
|
|
|
if (ui.effectWinManagement->checkState() != Qt::PartiallyChecked)
|
|
|
|
{
|
2007-12-10 19:04:21 +00:00
|
|
|
WRITE_EFFECT_CONFIG("presentwindows", ui.effectWinManagement);
|
|
|
|
WRITE_EFFECT_CONFIG("desktopgrid", ui.effectWinManagement);
|
|
|
|
WRITE_EFFECT_CONFIG("dialogparent", ui.effectWinManagement);
|
2008-11-25 01:45:09 +00:00
|
|
|
}
|
2007-07-21 20:54:50 +00:00
|
|
|
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
|
|
|
|
WRITE_EFFECT_CONFIG("minimizeanimation", ui.effectAnimations);
|
|
|
|
#undef WRITE_EFFECT_CONFIG
|
2008-08-26 07:31:57 +00:00
|
|
|
|
|
|
|
int windowSwitcher = ui.windowSwitchingCombo->currentIndex();
|
2009-09-13 11:36:45 +00:00
|
|
|
bool boxSwitch = false;
|
2008-08-26 07:31:57 +00:00
|
|
|
bool presentWindowSwitching = false;
|
2009-09-13 11:36:45 +00:00
|
|
|
bool coverSwitch = false;
|
|
|
|
bool flipSwitch = false;
|
2008-08-26 07:31:57 +00:00
|
|
|
switch( windowSwitcher )
|
|
|
|
{
|
|
|
|
case 1:
|
2009-09-13 11:36:45 +00:00
|
|
|
boxSwitch = true;
|
2008-08-26 07:31:57 +00:00
|
|
|
break;
|
|
|
|
case 2:
|
|
|
|
presentWindowSwitching = true;
|
|
|
|
break;
|
|
|
|
case 3:
|
2009-09-13 11:36:45 +00:00
|
|
|
coverSwitch = true;
|
2008-08-26 07:31:57 +00:00
|
|
|
break;
|
|
|
|
case 4:
|
2009-07-21 10:18:48 +00:00
|
|
|
flipSwitch = true;
|
2008-08-26 07:31:57 +00:00
|
|
|
break;
|
2009-09-13 11:36:45 +00:00
|
|
|
default:
|
|
|
|
break; // nothing
|
2008-08-26 07:31:57 +00:00
|
|
|
}
|
2009-09-13 11:36:45 +00:00
|
|
|
// activate effects if not active
|
|
|
|
if( boxSwitch )
|
|
|
|
effectconfig.writeEntry("kwin4_effect_boxswitchEnabled", true);
|
|
|
|
if( presentWindowSwitching )
|
|
|
|
effectconfig.writeEntry("kwin4_effect_presentwindowsEnabled", true);
|
|
|
|
if( coverSwitch )
|
|
|
|
effectconfig.writeEntry("kwin4_effect_coverswitchEnabled", true);
|
|
|
|
if( flipSwitch )
|
|
|
|
effectconfig.writeEntry("kwin4_effect_flipswitchEnabled", true);
|
|
|
|
KConfigGroup boxswitchconfig( mKWinConfig, "Effect-BoxSwitch" );
|
|
|
|
boxswitchconfig.writeEntry( "TabBox", boxSwitch );
|
|
|
|
boxswitchconfig.sync();
|
|
|
|
KConfigGroup presentwindowsconfig( mKWinConfig, "Effect-PresentWindows" );
|
|
|
|
presentwindowsconfig.writeEntry( "TabBox", presentWindowSwitching );
|
|
|
|
presentwindowsconfig.sync();
|
|
|
|
KConfigGroup coverswitchconfig( mKWinConfig, "Effect-CoverSwitch" );
|
|
|
|
coverswitchconfig.writeEntry( "TabBox", coverSwitch );
|
|
|
|
coverswitchconfig.sync();
|
|
|
|
KConfigGroup flipswitchconfig( mKWinConfig, "Effect-FlipSwitch" );
|
|
|
|
flipswitchconfig.writeEntry( "TabBox", flipSwitch );
|
|
|
|
flipswitchconfig.sync();
|
2008-08-26 07:31:57 +00:00
|
|
|
|
|
|
|
int desktopSwitcher = ui.desktopSwitchingCombo->currentIndex();
|
|
|
|
switch( desktopSwitcher )
|
|
|
|
{
|
|
|
|
case 0:
|
|
|
|
// no effect
|
|
|
|
effectconfig.writeEntry("kwin4_effect_slideEnabled", false);
|
2009-02-06 18:53:16 +00:00
|
|
|
effectconfig.writeEntry("kwin4_effect_cubeslideEnabled", false);
|
2009-01-15 09:55:15 +00:00
|
|
|
effectconfig.writeEntry("kwin4_effect_fadedesktopEnabled", false);
|
2008-08-26 07:31:57 +00:00
|
|
|
break;
|
|
|
|
case 1:
|
|
|
|
// slide
|
|
|
|
effectconfig.writeEntry("kwin4_effect_slideEnabled", true);
|
2009-02-06 18:53:16 +00:00
|
|
|
effectconfig.writeEntry("kwin4_effect_cubeslideEnabled", false);
|
2009-01-15 09:55:15 +00:00
|
|
|
effectconfig.writeEntry("kwin4_effect_fadedesktopEnabled", false);
|
2008-08-26 07:31:57 +00:00
|
|
|
break;
|
|
|
|
case 2:
|
|
|
|
// cube
|
|
|
|
effectconfig.writeEntry("kwin4_effect_slideEnabled", false);
|
2009-02-06 18:53:16 +00:00
|
|
|
effectconfig.writeEntry("kwin4_effect_cubeslideEnabled", true);
|
2009-01-15 09:55:15 +00:00
|
|
|
effectconfig.writeEntry("kwin4_effect_fadedesktopEnabled", false);
|
|
|
|
break;
|
|
|
|
case 3:
|
|
|
|
// fadedesktop
|
|
|
|
effectconfig.writeEntry("kwin4_effect_slideEnabled", false);
|
2009-02-06 18:53:16 +00:00
|
|
|
effectconfig.writeEntry("kwin4_effect_cubeslideEnabled", false);
|
2009-01-15 09:55:15 +00:00
|
|
|
effectconfig.writeEntry("kwin4_effect_fadedesktopEnabled", true);
|
2008-08-26 07:31:57 +00:00
|
|
|
break;
|
|
|
|
}
|
2008-11-25 01:42:30 +00:00
|
|
|
}
|
2007-09-20 13:21:49 +00:00
|
|
|
|
|
|
|
void KWinCompositingConfig::saveEffectsTab()
|
2008-11-25 01:45:09 +00:00
|
|
|
{
|
2007-09-18 10:09:07 +00:00
|
|
|
ui.effectSelector->save();
|
2008-11-25 01:45:09 +00:00
|
|
|
}
|
2007-09-20 13:21:49 +00:00
|
|
|
|
2008-12-08 05:08:31 +00:00
|
|
|
bool KWinCompositingConfig::saveAdvancedTab()
|
2008-11-25 01:42:30 +00:00
|
|
|
{
|
2008-12-08 05:08:31 +00:00
|
|
|
bool advancedChanged = false;
|
2008-11-14 13:18:03 +00:00
|
|
|
static const int hps[] = { 6 /*always*/, 5 /*shown*/, 4 /*never*/ };
|
2008-11-14 12:36:59 +00:00
|
|
|
|
2008-12-08 05:08:31 +00:00
|
|
|
KConfigGroup config(mKWinConfig, "Compositing");
|
2008-11-14 12:36:59 +00:00
|
|
|
QString glModes[] = { "TFP", "SHM", "Fallback" };
|
|
|
|
|
2008-12-08 05:08:31 +00:00
|
|
|
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;
|
|
|
|
|
2008-12-08 11:00:01 +00:00
|
|
|
config.writeEntry("Backend", (ui.compositingType->currentIndex() == OPENGL_INDEX) ? "OpenGL" : "XRender");
|
2008-11-14 12:36:59 +00:00
|
|
|
config.writeEntry("HiddenPreviews", hps[ ui.windowThumbnails->currentIndex() ] );
|
|
|
|
config.writeEntry("DisableChecks", ui.disableChecks->isChecked());
|
|
|
|
|
|
|
|
config.writeEntry("GLMode", glModes[ui.glMode->currentIndex()]);
|
|
|
|
config.writeEntry("GLTextureFilter", ui.glTextureFilter->currentIndex());
|
|
|
|
config.writeEntry("GLDirect", ui.glDirect->isChecked());
|
|
|
|
config.writeEntry("GLVSync", ui.glVSync->isChecked());
|
|
|
|
|
|
|
|
config.writeEntry("XRenderSmoothScale", ui.xrenderSmoothScale->isChecked());
|
2008-12-08 05:08:31 +00:00
|
|
|
|
|
|
|
return advancedChanged;
|
2008-11-25 01:42:30 +00:00
|
|
|
}
|
2008-11-14 12:36:59 +00:00
|
|
|
|
2007-09-20 13:21:49 +00:00
|
|
|
void KWinCompositingConfig::save()
|
2008-11-25 01:42:30 +00:00
|
|
|
{
|
2008-12-08 05:08:31 +00:00
|
|
|
// Save current config. We'll use this for restoring in case something goes wrong.
|
|
|
|
KConfigGroup config(mKWinConfig, "Compositing");
|
|
|
|
mPreviousConfig = config.entryMap();
|
|
|
|
|
2007-12-30 14:34:04 +00:00
|
|
|
// bah; tab content being dependent on the other is really bad; and
|
2009-02-07 01:12:28 +00:00
|
|
|
// deprecated in the HIG for a reason. It is confusing!
|
2007-12-30 14:34:04 +00:00
|
|
|
// Make sure we only call save on each tab once; as they are stateful due to the revert concept
|
2008-11-25 01:45:09 +00:00
|
|
|
if ( ui.tabWidget->currentIndex() == 0 ) // "General" tab was active
|
|
|
|
{
|
2007-12-30 14:34:04 +00:00
|
|
|
saveGeneralTab();
|
|
|
|
loadEffectsTab();
|
|
|
|
saveEffectsTab();
|
2008-11-25 01:45:09 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2007-12-30 14:34:04 +00:00
|
|
|
saveEffectsTab();
|
|
|
|
loadGeneralTab();
|
|
|
|
saveGeneralTab();
|
2008-11-25 01:42:30 +00:00
|
|
|
}
|
2008-12-08 05:08:31 +00:00
|
|
|
bool advancedChanged = saveAdvancedTab();
|
2007-09-18 10:09:07 +00:00
|
|
|
|
2008-12-08 05:08:31 +00:00
|
|
|
// 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());
|
2007-07-19 16:20:05 +00:00
|
|
|
|
2008-11-25 01:42:30 +00:00
|
|
|
emit changed( false );
|
2007-09-18 19:00:23 +00:00
|
|
|
|
2008-12-08 05:08:31 +00:00
|
|
|
configChanged(advancedChanged);
|
|
|
|
|
2009-06-26 15:29:00 +00:00
|
|
|
// This assumes that this KCM is running with the same environment variables as KWin
|
|
|
|
// TODO: Detect KWIN_COMPOSE=N as well
|
2009-10-30 08:10:35 +00:00
|
|
|
if( !qgetenv( "KDE_FAILSAFE" ).isNull() && ui.useCompositing->isChecked() )
|
2009-06-26 15:29:00 +00:00
|
|
|
{
|
|
|
|
KMessageBox::sorry( this, i18n(
|
2009-09-29 20:17:36 +00:00
|
|
|
"Your settings have been saved but as KDE is currently running in failsafe "
|
2009-06-26 15:29:00 +00:00
|
|
|
"mode desktop effects cannot be enabled at this time.\n\n"
|
|
|
|
"Please exit failsafe mode to enable desktop effects." ));
|
|
|
|
m_showConfirmDialog = false; // Dangerous but there is no way to test if failsafe mode
|
|
|
|
}
|
|
|
|
|
2008-12-08 05:08:31 +00:00
|
|
|
if(m_showConfirmDialog)
|
|
|
|
{
|
|
|
|
m_showConfirmDialog = false;
|
|
|
|
showConfirmDialog(advancedChanged);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-09-11 21:03:24 +00:00
|
|
|
void KWinCompositingConfig::checkLoadedEffects()
|
2008-12-08 05:08:31 +00:00
|
|
|
{
|
2009-04-01 16:24:40 +00:00
|
|
|
// check for effects not supported by Backend or hardware
|
|
|
|
// such effects are enabled but not returned by DBus method loadedEffects
|
2009-09-11 21:03:24 +00:00
|
|
|
QDBusMessage message = QDBusMessage::createMethodCall( "org.kde.kwin", "/KWin", "org.kde.KWin", "loadedEffects" );
|
2009-04-01 16:24:40 +00:00
|
|
|
QDBusMessage reply = QDBusConnection::sessionBus().call( message );
|
2009-09-11 21:03:24 +00:00
|
|
|
KConfigGroup effectConfig = KConfigGroup( mKWinConfig, "Compositing" );
|
|
|
|
bool enabledAfter = effectConfig.readEntry( "Enabled", mDefaultPrefs.enableCompositing() );
|
|
|
|
|
2009-06-26 15:29:00 +00:00
|
|
|
if( reply.type() == QDBusMessage::ReplyMessage && enabledAfter && !getenv( "KDE_FAILSAFE" ))
|
2009-04-01 16:24:40 +00:00
|
|
|
{
|
2009-09-11 21:03:24 +00:00
|
|
|
effectConfig = KConfigGroup( mKWinConfig, "Plugins" );
|
2009-04-01 16:24:40 +00:00
|
|
|
QStringList loadedEffects = reply.arguments()[0].toStringList();
|
|
|
|
QStringList effects = effectConfig.keyList();
|
|
|
|
QStringList disabledEffects = QStringList();
|
2009-10-30 06:51:59 +00:00
|
|
|
foreach( QString effect, effects ) // krazy:exclude=foreach
|
2009-04-01 16:24:40 +00:00
|
|
|
{
|
|
|
|
QString temp = effect.mid( 13, effect.length() - 13 - 7 );
|
|
|
|
effect.truncate( effect.length() - 7 );
|
|
|
|
if( effectEnabled( temp, effectConfig ) && !loadedEffects.contains( effect ) )
|
|
|
|
{
|
|
|
|
disabledEffects << effect;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if( !disabledEffects.isEmpty() )
|
|
|
|
{
|
|
|
|
KServiceTypeTrader* trader = KServiceTypeTrader::self();
|
|
|
|
KService::List services;
|
|
|
|
QString message = i18n( "The following effects could not be activated:" );
|
|
|
|
message.append( "<ul>" );
|
2009-04-11 11:11:50 +00:00
|
|
|
foreach( const QString &effect, disabledEffects )
|
2009-04-01 16:24:40 +00:00
|
|
|
{
|
2009-10-30 06:51:59 +00:00
|
|
|
services = trader->query("KWin/Effect", "[X-KDE-PluginInfo-Name] == '" + effect + '\'');
|
2009-04-01 16:24:40 +00:00
|
|
|
message.append( "<li>" );
|
|
|
|
if( !services.isEmpty() )
|
|
|
|
message.append( services.first()->name() );
|
|
|
|
else
|
|
|
|
message.append( effect);
|
|
|
|
message.append( "</li>" );
|
|
|
|
}
|
|
|
|
message.append( "</ul>" );
|
2009-04-06 11:53:58 +00:00
|
|
|
KNotification::event( "effectsnotsupported", message, QPixmap(), NULL, KNotification::CloseOnTimeout, KComponentData( "kwin" ) );
|
2009-04-01 16:24:40 +00:00
|
|
|
}
|
|
|
|
}
|
2009-09-11 21:03:24 +00:00
|
|
|
}
|
2009-04-01 16:24:40 +00:00
|
|
|
|
2009-09-11 21:03:24 +00:00
|
|
|
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);
|
|
|
|
|
|
|
|
// HACK: We can't just do this here, due to the asynchronous nature of signals.
|
|
|
|
// We also can't change reinitCompositing into a message (which would allow
|
|
|
|
// callWithCallbac() to do this neater) due to multiple kwin instances.
|
|
|
|
if( !m_showConfirmDialog )
|
|
|
|
QTimer::singleShot(1000, this, SLOT(checkLoadedEffects()));
|
2007-09-18 19:00:23 +00:00
|
|
|
}
|
2007-07-19 16:20:05 +00:00
|
|
|
|
2008-12-08 05:08:31 +00:00
|
|
|
|
2007-07-19 16:20:05 +00:00
|
|
|
void KWinCompositingConfig::defaults()
|
2008-11-25 01:45:09 +00:00
|
|
|
{
|
2008-07-20 12:59:23 +00:00
|
|
|
ui.tabWidget->setCurrentIndex(0);
|
|
|
|
|
2007-09-18 14:32:37 +00:00
|
|
|
ui.useCompositing->setChecked(mDefaultPrefs.enableCompositing());
|
2007-07-21 20:54:50 +00:00
|
|
|
ui.effectWinManagement->setChecked(true);
|
|
|
|
ui.effectShadows->setChecked(true);
|
|
|
|
ui.effectAnimations->setChecked(true);
|
2007-09-18 10:09:07 +00:00
|
|
|
|
2008-08-26 07:31:57 +00:00
|
|
|
ui.windowSwitchingCombo->setCurrentIndex( 1 );
|
|
|
|
ui.desktopSwitchingCombo->setCurrentIndex( 1 );
|
2008-08-30 07:25:54 +00:00
|
|
|
ui.animationSpeedCombo->setCurrentIndex( 3 );
|
2008-08-26 07:31:57 +00:00
|
|
|
|
2007-09-18 10:09:07 +00:00
|
|
|
ui.effectSelector->defaults();
|
2008-11-06 10:42:36 +00:00
|
|
|
|
2008-11-14 12:36:59 +00:00
|
|
|
ui.compositingType->setCurrentIndex( 0 );
|
|
|
|
ui.windowThumbnails->setCurrentIndex( 1 );
|
|
|
|
ui.disableChecks->setChecked( false );
|
|
|
|
ui.glMode->setCurrentIndex( 0 );
|
|
|
|
ui.glTextureFilter->setCurrentIndex( 1 );
|
|
|
|
ui.glDirect->setChecked( mDefaultPrefs.enableDirectRendering() );
|
|
|
|
ui.glVSync->setChecked( mDefaultPrefs.enableVSync() );
|
|
|
|
ui.xrenderSmoothScale->setChecked( false );
|
2008-11-25 01:45:09 +00:00
|
|
|
}
|
2007-07-19 16:20:05 +00:00
|
|
|
|
|
|
|
QString KWinCompositingConfig::quickHelp() const
|
2008-11-25 01:45:09 +00:00
|
|
|
{
|
2007-07-21 20:54:50 +00:00
|
|
|
return i18n("<h1>Desktop Effects</h1>");
|
2008-11-25 01:45:09 +00:00
|
|
|
}
|
2007-07-19 16:20:05 +00:00
|
|
|
|
2008-11-06 10:42:36 +00:00
|
|
|
} // namespace
|
2008-11-25 01:45:09 +00:00
|
|
|
|
2007-07-19 16:20:05 +00:00
|
|
|
#include "main.moc"
|