Reparse Configuration at startup asynchronous

Options loading is split into three parts:
* reparse configuration
* loading of non-compositing related options
* loading of composited related options not needing CompositingPrefs

At startup the reparsing of configuration is done through a Thread
to gain a little bit of less waiting.

Before something else accesses the KConfig for the first time we
wait for the thread to finish and perform the other two loading
operations of Options.

The settings depending on CompositingPrefs will only be invoked
if a compositor is going to be needed.

REVIEW: 104562
This commit is contained in:
Martin Gräßlin 2012-04-12 19:42:49 +02:00
parent 818714432f
commit 3ed63d4c45
4 changed files with 59 additions and 24 deletions

View file

@ -302,10 +302,9 @@ Application::Application()
// Reset crashes count if we stay up for more that 15 seconds
QTimer::singleShot(15 * 1000, this, SLOT(resetCrashesCount()));
// If KWin was already running it saved its configuration after loosing the selection -> Reread
config->reparseConfiguration();
initting = true; // Startup...
// first load options - done internally by a different thread
options = new Options;
// Install X11 error handler
XSetErrorHandler(x11ErrorHandler);
@ -321,7 +320,6 @@ Application::Application()
// This tries to detect compositing options and can use GLX. GLX problems
// (X errors) shouldn't cause kwin to abort, so this is out of the
// critical startup section where x errors cause kwin to abort.
options = new Options;
// create workspace.
(void) new Workspace(isSessionRestored());

View file

@ -191,7 +191,6 @@ Options::Options(QObject *parent)
, show_geometry_tip(Options::defaultShowGeometryTip())
, animationSpeed(Options::defaultAnimationSpeed())
{
updateSettings();
}
Options::~Options()
@ -781,7 +780,33 @@ void Options::setElectricBorders(int borders)
emit electricBordersChanged();
}
void Options::reparseConfiguration()
{
KGlobal::config()->reparseConfiguration();
}
unsigned long Options::updateSettings()
{
unsigned long changed = loadConfig();
// 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.
// QToolTip::setGloballyEnabled( d->show_tooltips );
// KDE4 this probably needs to be done manually in clients
// Driver-specific config detection
setCompositingInitialized(false);
reloadCompositingSettings();
emit configChanged();
return changed;
}
unsigned long Options::loadConfig()
{
KSharedConfig::Ptr _config = KGlobal::config();
unsigned long changed = 0;
@ -895,25 +920,10 @@ unsigned long Options::updateSettings()
setMaxFpsInterval(qRound(1000.0 / config.readEntry("MaxFPS", Options::defaultMaxFps())));
setRefreshRate(config.readEntry("RefreshRate", Options::defaultRefreshRate()));
// 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.
// QToolTip::setGloballyEnabled( d->show_tooltips );
// KDE4 this probably needs to be done manually in clients
// Driver-specific config detection
setCompositingInitialized(false);
reloadCompositingSettings();
emit configChanged();
return changed;
}
void Options::reloadCompositingSettings(bool force)
bool Options::loadCompositingConfig (bool force)
{
KSharedConfig::Ptr _config = KGlobal::config();
KConfigGroup config(_config, "Compositing");
@ -954,15 +964,22 @@ void Options::reloadCompositingSettings(bool force)
if (m_compositingMode == NoCompositing) {
setUseCompositing(false);
return; // do not even detect compositing preferences if explicitly disabled
return false; // 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
setUseCompositing(useCompositing || force || config.readEntry("Enabled", Options::defaultUseCompositing()));
if (!m_useCompositing)
return; // not enforced or necessary and not "enabled" by setting
return false; // not enforced or necessary and not "enabled" by settings
return true;
}
void Options::reloadCompositingSettings(bool force)
{
if (!loadCompositingConfig(force)) {
return;
}
// from now on we've an initial setup and don't have to reload settings on compositing activation
// see Workspace::setupCompositing(), composite.cpp
setCompositingInitialized(true);
@ -971,7 +988,9 @@ void Options::reloadCompositingSettings(bool force)
CompositingPrefs prefs;
prefs.detect();
setUseCompositing(config.readEntry("Enabled" , prefs.recommendCompositing()));
KSharedConfig::Ptr _config = KGlobal::config();
KConfigGroup config(_config, "Compositing");
setGlDirect(prefs.enableDirectRendering());
setGlVSync(config.readEntry("GLVSync", prefs.enableVSync()));
setGlSmoothScale(qBound(-1, config.readEntry("GLTextureFilter", Options::defaultGlSmoothScale()), 2));

View file

@ -871,6 +871,17 @@ public:
static int defaultAnimationSpeed() {
return 3;
}
/**
* Performs loading all settings except compositing related.
**/
unsigned long loadConfig();
/**
* Performs loading of compositing settings which do not depend on OpenGL.
**/
bool loadCompositingConfig(bool force);
void reparseConfiguration();
//----------------------
Q_SIGNALS:
void configChanged();

View file

@ -157,6 +157,9 @@ Workspace::Workspace(bool restore)
, m_finishingCompositing(false)
, m_scripting(NULL)
{
// If KWin was already running it saved its configuration after loosing the selection -> Reread
QFuture<void> reparseConfigFuture = QtConcurrent::run(options, &Options::reparseConfiguration);
(void) new KWinAdaptor(this);
QDBusConnection dbus = QDBusConnection::sessionBus();
@ -171,6 +174,10 @@ Workspace::Workspace(bool restore)
desktopGrid_[1] = 0;
_self = this;
// PluginMgr needs access to the config file, so we need to wait for it for finishing
reparseConfigFuture.waitForFinished();
options->loadConfig();
options->loadCompositingConfig(false);
mgr = new PluginMgr;
QX11Info info;
default_colormap = DefaultColormap(display(), info.screen());