unify composite activation, 'Enable' only controls initial state

This commit is contained in:
Thomas Lübking 2011-02-27 23:39:32 +01:00
parent 3529c34934
commit 0c5d47f3ae
8 changed files with 401 additions and 374 deletions

View file

@ -89,39 +89,16 @@ void Workspace::setupCompositing()
#ifdef KWIN_HAVE_COMPOSITING #ifdef KWIN_HAVE_COMPOSITING
if (scene != NULL) if (scene != NULL)
return; return;
if (!options->useCompositing && getenv("KWIN_COMPOSE") == NULL) { if (compositingSuspended) {
kDebug(1212) << "Compositing is turned off in options or disabled";
return;
} else if (compositingSuspended) {
kDebug(1212) << "Compositing is suspended"; kDebug(1212) << "Compositing is suspended";
return; return;
} else if (!CompositingPrefs::compositingPossible()) { } else if (!CompositingPrefs::compositingPossible()) {
kError(1212) << "Compositing is not possible"; kError(1212) << "Compositing is not possible";
return; return;
} }
CompositingType type = options->compositingMode;
if (getenv("KWIN_COMPOSE")) { if (!options->compositingInitialized)
char c = getenv("KWIN_COMPOSE")[ 0 ]; options->reloadCompositingSettings(true);
switch(c) {
case 'O':
kDebug(1212) << "Compositing forced to OpenGL mode by environment variable";
type = OpenGLCompositing;
break;
case 'X':
kDebug(1212) << "Compositing forced to XRender mode by environment variable";
type = XRenderCompositing;
break;
case 'N':
if (getenv("KDE_FAILSAFE"))
kDebug(1212) << "Compositing disabled forcefully by KDE failsafe mode";
else
kDebug(1212) << "Compositing disabled forcefully by environment variable";
return; // Return not break
default:
kDebug(1212) << "Unknown KWIN_COMPOSE mode set, ignoring";
break;
}
}
char selection_name[ 100 ]; char selection_name[ 100 ];
sprintf(selection_name, "_NET_WM_CM_S%d", DefaultScreen(display())); sprintf(selection_name, "_NET_WM_CM_S%d", DefaultScreen(display()));
@ -129,7 +106,7 @@ void Workspace::setupCompositing()
connect(cm_selection, SIGNAL(lostOwnership()), SLOT(lostCMSelection())); connect(cm_selection, SIGNAL(lostOwnership()), SLOT(lostCMSelection()));
cm_selection->claim(true); // force claiming cm_selection->claim(true); // force claiming
switch(type) { switch(options->compositingMode) {
/*case 'B': /*case 'B':
kDebug( 1212 ) << "X compositing"; kDebug( 1212 ) << "X compositing";
scene = new SceneBasic( this ); scene = new SceneBasic( this );
@ -295,7 +272,7 @@ void Workspace::toggleCompositing()
QString shortcut, message; QString shortcut, message;
if (KAction* action = qobject_cast<KAction*>(keys->action("Suspend Compositing"))) if (KAction* action = qobject_cast<KAction*>(keys->action("Suspend Compositing")))
shortcut = action->globalShortcut().primary().toString(QKeySequence::NativeText); shortcut = action->globalShortcut().primary().toString(QKeySequence::NativeText);
if (!shortcut.isEmpty() && options->useCompositing) { if (!shortcut.isEmpty()) {
// display notification only if there is the shortcut // display notification only if there is the shortcut
message = i18n("Desktop effects have been suspended by another application.<br/>" message = i18n("Desktop effects have been suspended by another application.<br/>"
"You can resume using the '%1' shortcut.", shortcut); "You can resume using the '%1' shortcut.", shortcut);

View file

@ -23,6 +23,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include "kwin_interface.h" #include "kwin_interface.h"
#include <kaboutdata.h> #include <kaboutdata.h>
#include <kaction.h>
#include <kactioncollection.h>
#include <kconfig.h> #include <kconfig.h>
#include <kconfiggroup.h> #include <kconfiggroup.h>
#include <kdebug.h> #include <kdebug.h>
@ -74,13 +76,10 @@ KWinCompositingConfig::KWinCompositingConfig(QWidget *parent, const QVariantList
: KCModule(KWinCompositingConfigFactory::componentData(), parent) : KCModule(KWinCompositingConfigFactory::componentData(), parent)
, mKWinConfig(KSharedConfig::openConfig("kwinrc")) , mKWinConfig(KSharedConfig::openConfig("kwinrc"))
, m_showConfirmDialog(false) , m_showConfirmDialog(false)
, kwinInterface(NULL)
{ {
KGlobal::locale()->insertCatalog("kwin_effects"); KGlobal::locale()->insertCatalog("kwin_effects");
ui.setupUi(this); ui.setupUi(this);
layout()->setMargin(0); layout()->setMargin(0);
ui.verticalSpacer->changeSize(20, KDialog::groupSpacingHint());
ui.verticalSpacer_2->changeSize(20, KDialog::groupSpacingHint());
ui.tabWidget->setCurrentIndex(0); ui.tabWidget->setCurrentIndex(0);
ui.statusTitleWidget->hide(); ui.statusTitleWidget->hide();
@ -101,9 +100,6 @@ KWinCompositingConfig::KWinCompositingConfig(QWidget *parent, const QVariantList
#define XRENDER_INDEX -1 #define XRENDER_INDEX -1
#endif #endif
kwinInterface = new OrgKdeKWinInterface("org.kde.kwin", "/KWin", QDBusConnection::sessionBus());
connect(ui.useCompositing, SIGNAL(toggled(bool)), this, SLOT(compositingEnabled(bool)));
connect(ui.tabWidget, SIGNAL(currentChanged(int)), this, SLOT(currentTabChanged(int))); connect(ui.tabWidget, SIGNAL(currentChanged(int)), this, SLOT(currentTabChanged(int)));
connect(ui.useCompositing, SIGNAL(toggled(bool)), this, SLOT(changed())); connect(ui.useCompositing, SIGNAL(toggled(bool)), this, SLOT(changed()));
@ -128,8 +124,6 @@ KWinCompositingConfig::KWinCompositingConfig(QWidget *parent, const QVariantList
connect(ui.glDirect, SIGNAL(toggled(bool)), this, SLOT(changed())); connect(ui.glDirect, SIGNAL(toggled(bool)), this, SLOT(changed()));
connect(ui.glVSync, SIGNAL(toggled(bool)), this, SLOT(changed())); connect(ui.glVSync, SIGNAL(toggled(bool)), this, SLOT(changed()));
connect(ui.compositingStateButton, SIGNAL(clicked(bool)), kwinInterface, SLOT(toggleCompositing()));
connect(kwinInterface, SIGNAL(compositingToggled(bool)), this, SLOT(setupCompositingState(bool)));
// Open the temporary config file // Open the temporary config file
// Temporary conf file is used to synchronize effect checkboxes with effect // Temporary conf file is used to synchronize effect checkboxes with effect
@ -138,6 +132,16 @@ KWinCompositingConfig::KWinCompositingConfig(QWidget *parent, const QVariantList
mTmpConfigFile.open(); mTmpConfigFile.open();
mTmpConfig = KSharedConfig::openConfig(mTmpConfigFile.fileName()); mTmpConfig = KSharedConfig::openConfig(mTmpConfigFile.fileName());
// toggle effects shortcut button stuff - /HAS/ to happen before load!
m_actionCollection = new KActionCollection( this, KComponentData("kwin") );
m_actionCollection->setConfigGroup("Suspend Compositing");
m_actionCollection->setConfigGlobal(true);
KAction* a = static_cast<KAction*>(m_actionCollection->addAction( "Suspend Compositing" ));
a->setProperty("isConfigurationAction", true);
a->setGlobalShortcut( KShortcut( Qt::ALT + Qt::SHIFT + Qt::Key_F12 ));
connect(ui.toggleEffectsShortcut, SIGNAL(keySequenceChanged(const QKeySequence&)), this, SLOT(toggleEffectShortcutChanged(const QKeySequence&)));
// NOTICE: this is intended to workaround broken GL implementations that successfully segfault on glXQuery :-( // NOTICE: this is intended to workaround broken GL implementations that successfully segfault on glXQuery :-(
KConfigGroup unsafeConfig(mKWinConfig, "Compositing"); KConfigGroup unsafeConfig(mKWinConfig, "Compositing");
const bool glUnsafe = unsafeConfig.readEntry("OpenGLIsUnsafe", false); const bool glUnsafe = unsafeConfig.readEntry("OpenGLIsUnsafe", false);
@ -158,7 +162,6 @@ KWinCompositingConfig::KWinCompositingConfig(QWidget *parent, const QVariantList
ui.useCompositing->setEnabled(false); ui.useCompositing->setEnabled(false);
ui.useCompositing->setChecked(false); ui.useCompositing->setChecked(false);
compositingEnabled(false);
QString text = i18n("Desktop effects are not available on this system due to the following technical issues:"); QString text = i18n("Desktop effects are not available on this system due to the following technical issues:");
text += "<br>"; text += "<br>";
@ -166,8 +169,6 @@ KWinCompositingConfig::KWinCompositingConfig(QWidget *parent, const QVariantList
ui.statusTitleWidget->setText(text); ui.statusTitleWidget->setText(text);
ui.statusTitleWidget->setPixmap(KTitleWidget::InfoMessage, KTitleWidget::ImageLeft); ui.statusTitleWidget->setPixmap(KTitleWidget::InfoMessage, KTitleWidget::ImageLeft);
ui.statusTitleWidget->show(); ui.statusTitleWidget->show();
setupCompositingState(false, false);
} }
KAboutData *about = new KAboutData(I18N_NOOP("kcmkwincompositing"), 0, KAboutData *about = new KAboutData(I18N_NOOP("kcmkwincompositing"), 0,
@ -225,14 +226,6 @@ void KWinCompositingConfig::reparseConfiguration(const QByteArray& conf)
KSettings::Dispatcher::reparseConfiguration(conf); KSettings::Dispatcher::reparseConfiguration(conf);
} }
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);
}
void KWinCompositingConfig::showConfirmDialog(bool reinitCompositing) void KWinCompositingConfig::showConfirmDialog(bool reinitCompositing)
{ {
bool revert = false; bool revert = false;
@ -252,7 +245,6 @@ void KWinCompositingConfig::showConfirmDialog(bool reinitCompositing)
revert = true; revert = true;
else { else {
// compositing is enabled now // compositing is enabled now
setupCompositingState(kwinInterface->compositingActive());
checkLoadedEffects(); checkLoadedEffects();
} }
} }
@ -315,6 +307,12 @@ void KWinCompositingConfig::loadGeneralTab()
KConfigGroup config(mKWinConfig, "Compositing"); KConfigGroup config(mKWinConfig, "Compositing");
bool enabled = config.readEntry("Enabled", mDefaultPrefs.recommendCompositing()); bool enabled = config.readEntry("Enabled", mDefaultPrefs.recommendCompositing());
ui.useCompositing->setChecked(enabled); ui.useCompositing->setChecked(enabled);
// this works by global shortcut magics - it will pick the current sc
// but the constructor line that adds the default alt+shift+f12 gsc is IMPORTANT!
if (KAction *a = qobject_cast<KAction*>(m_actionCollection->action("Suspend Compositing")))
ui.toggleEffectsShortcut->setKeySequence(a->globalShortcut().primary());
ui.animationSpeedCombo->setCurrentIndex(config.readEntry("AnimationSpeed", 3)); ui.animationSpeedCombo->setCurrentIndex(config.readEntry("AnimationSpeed", 3));
// Load effect settings // Load effect settings
@ -356,46 +354,8 @@ void KWinCompositingConfig::loadGeneralTab()
ui.desktopSwitchingCombo->setCurrentIndex(2); ui.desktopSwitchingCombo->setCurrentIndex(2);
if (effectEnabled("fadedesktop", effectconfig)) if (effectEnabled("fadedesktop", effectconfig))
ui.desktopSwitchingCombo->setCurrentIndex(3); ui.desktopSwitchingCombo->setCurrentIndex(3);
if (enabled)
setupCompositingState(kwinInterface->compositingActive());
else
setupCompositingState(false, false);
} }
void KWinCompositingConfig::setupCompositingState(bool active, bool enabled)
{
if (!qgetenv("KDE_FAILSAFE").isNull())
enabled = false;
// 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("Desktop effects are active");
stateButtonText = i18n("Suspend Desktop Effects");
} else {
stateIcon = QString("dialog-cancel");
stateText = i18n("Desktop effects are temporarily disabled");
stateButtonText = i18n("Resume Desktop Effects");
}
} else {
// compositing is disabled
stateIcon = QString("dialog-cancel");
stateText = i18n("Desktop effects are disabled");
stateButtonText = i18n("Resume Desktop Effects");
}
const int iconSize = (QApplication::fontMetrics().height() > 24) ? 32 : 22;
ui.compositingStateIcon->setPixmap(KIcon(stateIcon).pixmap(iconSize, iconSize));
ui.compositingStateLabel->setText(stateText);
ui.compositingStateButton->setText(stateButtonText);
ui.compositingStateIcon->setEnabled(enabled);
ui.compositingStateLabel->setEnabled(enabled);
ui.compositingStateButton->setEnabled(enabled);
}
void KWinCompositingConfig::toogleSmoothScaleUi(int compositingType) void KWinCompositingConfig::toogleSmoothScaleUi(int compositingType)
{ {
@ -404,6 +364,13 @@ void KWinCompositingConfig::toogleSmoothScaleUi(int compositingType)
ui.scaleMethodLabel->setBuddy(compositingType == XRENDER_INDEX ? ui.xrScaleFilter : ui.glScaleFilter); ui.scaleMethodLabel->setBuddy(compositingType == XRENDER_INDEX ? ui.xrScaleFilter : ui.glScaleFilter);
} }
void KWinCompositingConfig::toggleEffectShortcutChanged(const QKeySequence &seq)
{
if (KAction *a = qobject_cast<KAction*>(m_actionCollection->action("Suspend Compositing")))
a->setGlobalShortcut(KShortcut(seq), KAction::ActiveShortcut, KAction::NoAutoloading);
m_actionCollection->writeSettings();
}
bool KWinCompositingConfig::effectEnabled(const QString& effect, const KConfigGroup& cfg) const bool KWinCompositingConfig::effectEnabled(const QString& effect, const KConfigGroup& cfg) const
{ {
KService::List services = KServiceTypeTrader::self()->query( KService::List services = KServiceTypeTrader::self()->query(
@ -467,17 +434,9 @@ void KWinCompositingConfig::saveGeneralTab()
{ {
KConfigGroup config(mKWinConfig, "Compositing"); KConfigGroup config(mKWinConfig, "Compositing");
// Check if any critical settings that need confirmation have changed // Check if any critical settings that need confirmation have changed
if (ui.useCompositing->isChecked() &&
ui.useCompositing->isChecked() != config.readEntry("Enabled", mDefaultPrefs.recommendCompositing()))
m_showConfirmDialog = true;
config.writeEntry("Enabled", ui.useCompositing->isChecked()); config.writeEntry("Enabled", ui.useCompositing->isChecked());
config.writeEntry("AnimationSpeed", ui.animationSpeedCombo->currentIndex()); config.writeEntry("AnimationSpeed", ui.animationSpeedCombo->currentIndex());
// disable the compositing state if compositing was turned off
if (!ui.useCompositing->isChecked())
setupCompositingState(false, false);
// Save effects // Save effects
KConfigGroup effectconfig(mTmpConfig, "Plugins"); KConfigGroup effectconfig(mTmpConfig, "Plugins");
#define WRITE_EFFECT_CONFIG(effectname, widget) effectconfig.writeEntry("kwin4_effect_" effectname "Enabled", widget->isChecked()) #define WRITE_EFFECT_CONFIG(effectname, widget) effectconfig.writeEntry("kwin4_effect_" effectname "Enabled", widget->isChecked())

View file

@ -33,6 +33,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include "ktimerdialog.h" #include "ktimerdialog.h"
class KPluginSelector; class KPluginSelector;
class KActionCollection;
class QLabel; class QLabel;
namespace KWin namespace KWin
@ -55,7 +56,6 @@ public:
virtual QString quickHelp() const; virtual QString quickHelp() const;
public slots: public slots:
virtual void compositingEnabled(bool enabled);
virtual void showConfirmDialog(bool reinitCompositing); virtual void showConfirmDialog(bool reinitCompositing);
void currentTabChanged(int tab); void currentTabChanged(int tab);
@ -74,10 +74,10 @@ public slots:
void checkLoadedEffects(); void checkLoadedEffects();
void configChanged(bool reinitCompositing); void configChanged(bool reinitCompositing);
void initEffectSelector(); void initEffectSelector();
void setupCompositingState(bool active, bool enabled = true);
private slots: private slots:
void toogleSmoothScaleUi(int compositingType); void toogleSmoothScaleUi(int compositingType);
void toggleEffectShortcutChanged(const QKeySequence &seq);
private: private:
bool effectEnabled(const QString& effect, const KConfigGroup& cfg) const; bool effectEnabled(const QString& effect, const KConfigGroup& cfg) const;
@ -90,8 +90,7 @@ private:
KTemporaryFile mTmpConfigFile; KTemporaryFile mTmpConfigFile;
KSharedConfigPtr mTmpConfig; KSharedConfigPtr mTmpConfig;
bool m_showConfirmDialog; bool m_showConfirmDialog;
KActionCollection* m_actionCollection;
OrgKdeKWinInterface* kwinInterface;
}; };
} // namespace } // namespace

View file

@ -6,8 +6,8 @@
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>595</width> <width>560</width>
<height>483</height> <height>472</height>
</rect> </rect>
</property> </property>
<layout class="QVBoxLayout"> <layout class="QVBoxLayout">
@ -20,249 +20,323 @@
<attribute name="title"> <attribute name="title">
<string>General</string> <string>General</string>
</attribute> </attribute>
<layout class="QVBoxLayout" name="verticalLayout"> <layout class="QVBoxLayout" name="verticalLayout_4">
<item> <item>
<widget class="KTitleWidget" name="statusTitleWidget"/> <widget class="KTitleWidget" name="statusTitleWidget"/>
</item> </item>
<item> <item>
<widget class="QCheckBox" name="useCompositing"> <layout class="QHBoxLayout" name="horizontalLayout_2">
<property name="text"> <property name="spacing">
<string comment="@option:check">Enable desktop effects</string> <number>0</number>
</property> </property>
<property name="checked"> <item>
<bool>true</bool> <spacer name="horizontalSpacer_6">
</property> <property name="orientation">
</widget> <enum>Qt::Horizontal</enum>
</item> </property>
<item> <property name="sizeHint" stdset="0">
<widget class="QWidget" name="compositingOptionsContainer" native="true"> <size>
<layout class="QGridLayout" name="gridLayout_3"> <width>40</width>
<property name="margin"> <height>20</height>
<number>0</number> </size>
</property> </property>
<item row="1" column="0"> </spacer>
<widget class="QGroupBox" name="groupBox"> </item>
<property name="title"> <item>
<string>Common Settings</string> <widget class="QWidget" name="compositingOptionsContainer" native="true">
</property> <layout class="QVBoxLayout" name="verticalLayout_3">
<layout class="QGridLayout" name="gridLayout"> <item>
<item row="0" column="0" colspan="2"> <widget class="QGroupBox" name="groupBox_2">
<widget class="QCheckBox" name="effectWinManagement"> <property name="title">
<property name="text"> <string>Activation</string>
<string>Improved window management</string> </property>
</property> <property name="flat">
<property name="checked"> <bool>true</bool>
<bool>true</bool> </property>
</property> <layout class="QVBoxLayout" name="verticalLayout">
</widget>
</item>
<item row="1" column="0" colspan="2">
<widget class="QCheckBox" name="effectAnimations">
<property name="text">
<string>Various animations</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item row="6" column="0" colspan="2">
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Fixed</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item row="7" column="0" colspan="2">
<widget class="QLabel" name="label">
<property name="text">
<string>You can find more effects, as well as effect-specific settings, in the &quot;All Effects&quot; tab above.</string>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
</widget>
</item>
<item row="3" column="0">
<widget class="QLabel" name="label_3">
<property name="text">
<string>Effect for window switching:</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
<property name="buddy">
<cstring>windowSwitchingCombo</cstring>
</property>
</widget>
</item>
<item row="3" column="1">
<widget class="KComboBox" name="windowSwitchingCombo">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
</widget>
</item>
<item row="4" column="1">
<widget class="KComboBox" name="desktopSwitchingCombo">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
</widget>
</item>
<item row="2" column="0" colspan="2">
<spacer name="verticalSpacer_2">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Fixed</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item row="5" column="1">
<widget class="KComboBox" name="animationSpeedCombo">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="currentIndex">
<number>3</number>
</property>
<item> <item>
<property name="text"> <widget class="QCheckBox" name="useCompositing">
<string>Instant</string> <property name="text">
</property> <string comment="@option:check">Enable desktop effects at startup</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item> </item>
<item> <item>
<property name="text"> <layout class="QHBoxLayout" name="horizontalLayout">
<string>Very Fast</string> <item>
</property> <spacer name="horizontalSpacer_5">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QLabel" name="label_6">
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Desktop effects can be toggled anytime using this shortcut:</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item>
<widget class="KKeySequenceWidget" name="toggleEffectsShortcut"/>
</item>
<item>
<spacer name="horizontalSpacer_4">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</item> </item>
<item> </layout>
<property name="text"> </widget>
<string>Fast</string> </item>
</property> <item>
<widget class="QGroupBox" name="groupBox">
<property name="title">
<string>Simple effect setup</string>
</property>
<property name="flat">
<bool>true</bool>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0" colspan="3">
<widget class="QCheckBox" name="effectWinManagement">
<property name="text">
<string>Improved window management</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item> </item>
<item> <item row="1" column="0" colspan="3">
<property name="text"> <widget class="QCheckBox" name="effectAnimations">
<string>Normal</string> <property name="text">
</property> <string>Various animations</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item> </item>
<item> <item row="2" column="0">
<property name="text"> <widget class="QLabel" name="label_3">
<string>Slow</string> <property name="text">
</property> <string>Effect for window switching:</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
<property name="buddy">
<cstring>windowSwitchingCombo</cstring>
</property>
</widget>
</item> </item>
<item> <item row="2" column="1">
<property name="text"> <widget class="KComboBox" name="windowSwitchingCombo">
<string>Very Slow</string> <property name="sizePolicy">
</property> <sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
</widget>
</item> </item>
<item> <item row="2" column="2">
<property name="text"> <spacer name="horizontalSpacer_3">
<string>Extremely Slow</string> <property name="orientation">
</property> <enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item> </item>
</widget> <item row="3" column="0">
</item> <widget class="QLabel" name="label_4">
<item row="5" column="0"> <property name="text">
<widget class="QLabel" name="label_5"> <string>Effect for desktop switching:</string>
<property name="text"> </property>
<string>Animation speed:</string> <property name="alignment">
</property> <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
<property name="alignment"> </property>
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set> <property name="buddy">
</property> <cstring>windowSwitchingCombo</cstring>
<property name="buddy"> </property>
<cstring>animationSpeedCombo</cstring> </widget>
</property> </item>
</widget> <item row="3" column="1">
</item> <widget class="KComboBox" name="desktopSwitchingCombo">
<item row="4" column="0"> <property name="sizePolicy">
<widget class="QLabel" name="label_4"> <sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<property name="text"> <horstretch>0</horstretch>
<string>Effect for desktop switching:</string> <verstretch>0</verstretch>
</property> </sizepolicy>
<property name="alignment"> </property>
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set> </widget>
</property> </item>
<property name="buddy"> <item row="3" column="2">
<cstring>windowSwitchingCombo</cstring> <spacer name="horizontalSpacer_2">
</property> <property name="orientation">
</widget> <enum>Qt::Horizontal</enum>
</item> </property>
</layout> <property name="sizeHint" stdset="0">
</widget> <size>
</item> <width>40</width>
<item row="0" column="0"> <height>20</height>
<widget class="QGroupBox" name="groupBox_2"> </size>
<property name="title"> </property>
<string>Compositing State</string> </spacer>
</property> </item>
<layout class="QHBoxLayout" name="horizontalLayout"> <item row="4" column="0">
<item> <widget class="QLabel" name="label_5">
<widget class="QLabel" name="compositingStateIcon"> <property name="text">
<property name="text"> <string>Animation speed:</string>
<string/> </property>
</property> <property name="alignment">
</widget> <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</item> </property>
<item> <property name="buddy">
<widget class="QLabel" name="compositingStateLabel"> <cstring>animationSpeedCombo</cstring>
<property name="text"> </property>
<string/> </widget>
</property> </item>
</widget> <item row="4" column="1">
</item> <widget class="KComboBox" name="animationSpeedCombo">
<item> <property name="sizePolicy">
<spacer name="horizontalSpacer"> <sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<property name="orientation"> <horstretch>0</horstretch>
<enum>Qt::Horizontal</enum> <verstretch>0</verstretch>
</property> </sizepolicy>
<property name="sizeHint" stdset="0"> </property>
<size> <property name="currentIndex">
<width>40</width> <number>3</number>
<height>20</height> </property>
</size> <item>
</property> <property name="text">
</spacer> <string>Instant</string>
</item> </property>
<item> </item>
<widget class="QPushButton" name="compositingStateButton"> <item>
<property name="text"> <property name="text">
<string/> <string>Very Fast</string>
</property> </property>
</widget> </item>
</item> <item>
</layout> <property name="text">
</widget> <string>Fast</string>
</item> </property>
</layout> </item>
</widget> <item>
<property name="text">
<string>Normal</string>
</property>
</item>
<item>
<property name="text">
<string>Slow</string>
</property>
</item>
<item>
<property name="text">
<string>Very Slow</string>
</property>
</item>
<item>
<property name="text">
<string>Extremely Slow</string>
</property>
</item>
</widget>
</item>
<item row="4" column="2">
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item row="5" column="0" colspan="3">
<widget class="Line" name="line">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
<item row="6" column="0" colspan="3">
<widget class="QLabel" name="label">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>You can find more effects, as well as effect-specific settings, in the &quot;All Effects&quot; tab above.</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_7">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</item> </item>
<item> <item>
<spacer> <spacer>
@ -271,8 +345,8 @@
</property> </property>
<property name="sizeHint" stdset="0"> <property name="sizeHint" stdset="0">
<size> <size>
<width>20</width> <width>512</width>
<height>0</height> <height>75</height>
</size> </size>
</property> </property>
</spacer> </spacer>
@ -569,6 +643,11 @@ p, li { white-space: pre-wrap; }
</layout> </layout>
</widget> </widget>
<customwidgets> <customwidgets>
<customwidget>
<class>KKeySequenceWidget</class>
<extends>QWidget</extends>
<header>kkeysequencewidget.h</header>
</customwidget>
<customwidget> <customwidget>
<class>KTitleWidget</class> <class>KTitleWidget</class>
<extends>QWidget</extends> <extends>QWidget</extends>
@ -596,22 +675,5 @@ p, li { white-space: pre-wrap; }
<tabstop>animationSpeedCombo</tabstop> <tabstop>animationSpeedCombo</tabstop>
</tabstops> </tabstops>
<resources/> <resources/>
<connections> <connections/>
<connection>
<sender>useCompositing</sender>
<signal>toggled(bool)</signal>
<receiver>groupBox</receiver>
<slot>setEnabled(bool)</slot>
<hints>
<hint type="sourcelabel">
<x>86</x>
<y>66</y>
</hint>
<hint type="destinationlabel">
<x>102</x>
<y>156</y>
</hint>
</hints>
</connection>
</connections>
</ui> </ui>

View file

@ -98,6 +98,7 @@ Options::Options()
: electric_borders(0) : electric_borders(0)
, electric_border_delay(0) , electric_border_delay(0)
{ {
compositingInitialized = false;
updateSettings(); updateSettings();
} }
@ -264,39 +265,67 @@ FIXME: we have no mac style menu implementation in kwin anymore, so this just br
// KDE4 this probably needs to be done manually in clients // KDE4 this probably needs to be done manually in clients
// Driver-specific config detection // Driver-specific config detection
compositingInitialized = false;
reloadCompositingSettings(); reloadCompositingSettings();
return changed; return changed;
} }
void Options::reloadCompositingSettings() void Options::reloadCompositingSettings(bool force)
{ {
KSharedConfig::Ptr _config = KGlobal::config(); KSharedConfig::Ptr _config = KGlobal::config();
KConfigGroup config(_config, "Compositing"); KConfigGroup config(_config, "Compositing");
// do not even detect compositing preferences if explicitly disabled
bool environmentForce = false;
if (getenv("KWIN_COMPOSE")) {
// if compositing is enforced by the environment variable, the preferences have to be read
const char c = getenv("KWIN_COMPOSE")[ 0 ];
if (c == 'X' || c == 'O')
environmentForce = true;
}
if (config.hasKey("Enabled") && !config.readEntry("Enabled", true) && !environmentForce) {
useCompositing = false;
return;
}
// Compositing settings
CompositingPrefs prefs;
prefs.detect();
useCompositing = config.readEntry("Enabled" , prefs.recommendCompositing());
QString compositingBackend = config.readEntry("Backend", "OpenGL"); QString compositingBackend = config.readEntry("Backend", "OpenGL");
if (compositingBackend == "XRender") if (compositingBackend == "XRender")
compositingMode = XRenderCompositing; compositingMode = XRenderCompositing;
else else
compositingMode = OpenGLCompositing; compositingMode = OpenGLCompositing;
useCompositing = false;
if (const char *c = getenv("KWIN_COMPOSE")) {
switch(c[0]) {
case 'O':
kDebug(1212) << "Compositing forced to OpenGL mode by environment variable";
compositingMode = OpenGLCompositing;
useCompositing = true;
break;
case 'X':
kDebug(1212) << "Compositing forced to XRender mode by environment variable";
compositingMode = XRenderCompositing;
useCompositing = true;
break;
case 'N':
if (getenv("KDE_FAILSAFE"))
kDebug(1212) << "Compositing disabled forcefully by KDE failsafe mode";
else
kDebug(1212) << "Compositing disabled forcefully by environment variable";
compositingMode = NoCompositing;
break;
default:
kDebug(1212) << "Unknown KWIN_COMPOSE mode set, ignoring";
break;
}
}
if (compositingMode == NoCompositing)
return; // do not even detect compositing preferences if explicitly disabled
// it's either enforced by env or by initial resume from "suspend" or we check the settings
useCompositing = useCompositing || force || config.readEntry("Enabled", true);
if (!useCompositing)
return; // not enforced or necessary and not "enabled" by setting
// from now on we've an initial setup and don't have to reload settigns on compositing activation
// see Workspace::setupCompositing(), composite.cpp
compositingInitialized = true;
// Compositing settings
CompositingPrefs prefs;
prefs.detect();
useCompositing = config.readEntry("Enabled" , prefs.recommendCompositing());
disableCompositingChecks = config.readEntry("DisableChecks", false); disableCompositingChecks = config.readEntry("DisableChecks", false);
glDirect = config.readEntry("GLDirect", prefs.enableDirectRendering()); glDirect = config.readEntry("GLDirect", prefs.enableDirectRendering());
glVSync = config.readEntry("GLVSync", prefs.enableVSync()); glVSync = config.readEntry("GLVSync", prefs.enableVSync());

View file

@ -363,9 +363,10 @@ public:
//---------------------- //----------------------
// Compositing settings // Compositing settings
void reloadCompositingSettings(bool force = false);
CompositingType compositingMode; CompositingType compositingMode;
bool useCompositing; // Separate to mode so the user can toggle bool useCompositing; // Separate to mode so the user can toggle
bool compositingInitialized;
// General preferences // General preferences
HiddenPreviews hiddenPreviews; HiddenPreviews hiddenPreviews;
@ -431,7 +432,6 @@ private:
int animationSpeed; // 0 - instant, 5 - very slow int animationSpeed; // 0 - instant, 5 - very slow
MouseCommand wheelToMouseCommand(MouseWheelCommand com, int delta); MouseCommand wheelToMouseCommand(MouseWheelCommand com, int delta);
void reloadCompositingSettings();
}; };
extern Options* options; extern Options* options;

View file

@ -87,7 +87,7 @@ namespace KWin
// Scene // Scene
//**************************************** //****************************************
Scene* scene; Scene* scene = 0;
Scene::Scene(Workspace* ws) Scene::Scene(Workspace* ws)
: wspace(ws) : wspace(ws)

View file

@ -217,6 +217,7 @@ Workspace::Workspace(bool restore)
); );
Extensions::init(); Extensions::init();
compositingSuspended = !options->useCompositing;
setupCompositing(); setupCompositing();
// Compatibility // Compatibility
@ -1100,7 +1101,7 @@ void Workspace::slotReconfigure()
updateCurrentTopMenu(); updateCurrentTopMenu();
} }
if (options->useCompositing && !compositingSuspended) { if (!compositingSuspended) {
setupCompositing(); setupCompositing();
if (effects) // setupCompositing() may fail if (effects) // setupCompositing() may fail
effects->reconfigure(); effects->reconfigure();
@ -1143,7 +1144,6 @@ void Workspace::slotReinitCompositing()
{ {
// Reparse config. Config options will be reloaded by setupCompositing() // Reparse config. Config options will be reloaded by setupCompositing()
KGlobal::config()->reparseConfiguration(); KGlobal::config()->reparseConfiguration();
options->updateSettings();
// Update any settings that can be set in the compositing kcm. // Update any settings that can be set in the compositing kcm.
updateElectricBorders(); updateElectricBorders();
@ -1153,6 +1153,7 @@ void Workspace::slotReinitCompositing()
// resume compositing if suspended // resume compositing if suspended
compositingSuspended = false; compositingSuspended = false;
options->compositingInitialized = false;
setupCompositing(); setupCompositing();
KDecorationFactory* factory = mgr->factory(); KDecorationFactory* factory = mgr->factory();
factory->reset(SettingCompositing); factory->reset(SettingCompositing);