summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorSam Spilsbury <sam.spilsbury@canonical.com>2010-12-07 17:00:45 +0800
committerSam Spilsbury <sam.spilsbury@canonical.com>2010-12-07 17:00:45 +0800
commit253706a7784bc6700839af68d3416be6536afb60 (patch)
treeb5042e6979de51931fe7ab08bcdb0e05d6957f10 /src
parentd36ea55afce09c12fcc0a26a628e7e1c91a2043a (diff)
downloadcompiz-with-glib-mainloop-253706a7784bc6700839af68d3416be6536afb60.tar.gz
compiz-with-glib-mainloop-253706a7784bc6700839af68d3416be6536afb60.tar.bz2
Never unload plugins passed to the cmdline
Forward port 27430deae222b4380c0e91da849f930a297afb73 to master
Diffstat (limited to 'src')
-rw-r--r--src/main.cpp4
-rw-r--r--src/privatescreen.h2
-rw-r--r--src/screen.cpp94
3 files changed, 80 insertions, 20 deletions
diff --git a/src/main.cpp b/src/main.cpp
index 94f4dcc..a8e4445 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -57,6 +57,8 @@ bool useDesktopHints = false;
bool debugOutput = false;
bool useCow = true;
+std::list <CompString> initialPlugins;
+
unsigned int pluginClassHandlerIndex = 0;
void
@@ -168,6 +170,8 @@ CompManager::parseArguments (int argc, char **argv)
}
}
+ initialPlugins = plugins;
+
return true;
}
diff --git a/src/privatescreen.h b/src/privatescreen.h
index a62509d..961daf2 100644
--- a/src/privatescreen.h
+++ b/src/privatescreen.h
@@ -56,6 +56,8 @@ extern bool inHandleEvent;
extern CompScreen *targetScreen;
extern CompOutput *targetOutput;
+extern std::list <CompString> initialPlugins;
+
typedef struct _CompDelayedEdgeSettings
{
diff --git a/src/screen.cpp b/src/screen.cpp
index a7f47b9..67f097b 100644
--- a/src/screen.cpp
+++ b/src/screen.cpp
@@ -791,48 +791,102 @@ PrivateScreen::processEvents ()
void
PrivateScreen::updatePlugins ()
{
- CompPlugin *p;
- unsigned int nPop, i, j;
- CompPlugin::List pop;
- bool failedPush;
+ CompPlugin *p;
+ unsigned int nPop, i, j, dupPluginCount;
+ CompOption::Value::Vector pList;
+ CompPlugin::List pop;
+ bool failedPush;
dirtyPluginList = false;
CompOption::Value::Vector &list = optionGetActivePlugins ();
- /* The old plugin list always begins with the core plugin. To make sure
- we don't unnecessarily unload plugins if the new plugin list does not
- contain the core plugin, we have to use an offset */
+ /* Make sure the new plugin list always has core first, then the
+ * initial plugins.... */
- if (list.size () > 0 && list[0].s () != "core")
- i = 0;
- else
- i = 1;
+ dupPluginCount = 0;
+
+ foreach (CompOption::Value &lp, list)
+ {
+ if (lp.s () == "core")
+ dupPluginCount++;
+ else
+ {
+ foreach (CompString &p, initialPlugins)
+ {
+ if (p == lp.s ())
+ {
+ dupPluginCount++;
+ break;
+ }
+ }
+ }
+ }
+
+ pList.resize (1 + initialPlugins.size () + list.size () - dupPluginCount);
+
+ if (pList.empty ())
+ {
+ screen->setOptionForPlugin ("core", "active_plugins", plugin);
+ return;
+ }
+
+ pList.at (0) = "core";
+ j = 1;
+ foreach (CompString &p, initialPlugins)
+ {
+ pList.at (j).set (p);
+ j++;
+ }
+
+ foreach (CompOption::Value &opt, list)
+ {
+ std::list <CompString>::iterator it = initialPlugins.begin ();
+ bool skip = false;
+ if (opt.s () == "core")
+ continue;
+
+ for (; it != initialPlugins.end (); it++)
+ {
+ if ((*it) == opt.s ())
+ {
+ skip = true;
+ break;
+ }
+ }
+
+ if (!skip)
+ pList.at (j++).set (opt.s ());
+ }
+
+ assert (j == pList.size ());
/* j is initialized to 1 to make sure we never pop the core plugin */
- for (j = 1; j < plugin.list ().size () &&
- i < list.size (); i++, j++)
+ for (i = j = 1; j < plugin.list ().size () && i < pList.size (); i++, j++)
{
- if (plugin.list ()[j].s () != list[i].s ())
+ if (plugin.list ().at (j).s () != pList.at (i).s ())
break;
}
nPop = plugin.list ().size () - j;
- for (j = 0; j < nPop; j++)
+ if (nPop)
{
- pop.push_back (CompPlugin::pop ());
- plugin.list ().pop_back ();
+ for (j = 0; j < nPop; j++)
+ {
+ pop.push_back (CompPlugin::pop ());
+ plugin.list ().pop_back ();
+ }
}
- for (; i < list.size (); i++)
+ for (; i < pList.size (); i++)
{
p = NULL;
failedPush = false;
foreach (CompPlugin *pp, pop)
{
- if (list[i]. s () == pp->vTable->name ())
+ if (pList[i]. s () == pp->vTable->name ())
{
if (CompPlugin::push (pp))
{
@@ -853,7 +907,7 @@ PrivateScreen::updatePlugins ()
if (p == 0 && !failedPush)
{
- p = CompPlugin::load (list[i].s ().c_str ());
+ p = CompPlugin::load (pList[i].s ().c_str ());
if (p)
{
if (!CompPlugin::push (p))