From 704902720b5404c981045c688f06faf867427410 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Gr=C3=A4=C3=9Flin?= Date: Fri, 13 Apr 2012 09:12:13 +0200 Subject: [PATCH] Perform detection of CompositingPrefs async Detecting CompositingPrefs invokes an external program. Waiting for this can be moved in a second thread. Due to the introduction of the thread the initialization order of KWin is changed: the WindowManager is initialized before the Compositor. Interestingly this makes KWin felt more responsive as the screen is not frozen for several seconds. REVIEW: 104579 --- composite.cpp | 22 +++++++++++++++++++++- workspace.h | 4 ++++ 2 files changed, 25 insertions(+), 1 deletion(-) diff --git a/composite.cpp b/composite.cpp index 2ee9e7703c..abf0e9dbbb 100644 --- a/composite.cpp +++ b/composite.cpp @@ -57,6 +57,8 @@ along with this program. If not, see . #include +#include +#include #include #include #include @@ -90,9 +92,27 @@ void Workspace::setupCompositing() return; } - if (!options->isCompositingInitialized()) + if (!options->isCompositingInitialized()) { +#ifndef KWIN_HAVE_OPENGLES + // options->reloadCompositingSettings(true) initializes the CompositingPrefs which calls an + // external program in turn + // run this in an external thread to make startup faster. + QFutureWatcher *compositingPrefsFuture = new QFutureWatcher(); + connect(compositingPrefsFuture, SIGNAL(finished()), this, SLOT(slotCompositingOptionsInitialized())); + connect(compositingPrefsFuture, SIGNAL(finished()), compositingPrefsFuture, SLOT(deleteLater())); + compositingPrefsFuture->setFuture(QtConcurrent::run(options, &Options::reloadCompositingSettings, true)); +#else + // OpenGL ES does not call the external program, so no need to create a thread options->reloadCompositingSettings(true); + slotCompositingOptionsInitialized(); +#endif + } else { + slotCompositingOptionsInitialized(); + } +} +void Workspace::slotCompositingOptionsInitialized() +{ char selection_name[ 100 ]; sprintf(selection_name, "_NET_WM_CM_S%d", DefaultScreen(display())); cm_selection = new KSelectionOwner(selection_name); diff --git a/workspace.h b/workspace.h index de90110646..0447f45118 100644 --- a/workspace.h +++ b/workspace.h @@ -645,6 +645,10 @@ private slots: void slotBlockShortcuts(int data); void slotReloadConfig(); void setupCompositing(); + /** + * Called from setupCompositing() when the CompositingPrefs are ready. + **/ + void slotCompositingOptionsInitialized(); void finishCompositing(); void fallbackToXRenderCompositing(); void performCompositing();