summaryrefslogtreecommitdiff
path: root/src/main.cpp
diff options
context:
space:
mode:
authorDennis Kasprzyk <onestone@compiz-fusion.org>2009-03-15 18:14:41 +0100
committerDennis kasprzyk <onestone@compiz-fusion.org>2009-03-15 18:14:41 +0100
commit8d4371fb4f6711a0150989767a4a3769b556e8c4 (patch)
tree19ff6b2f8fd3611b55b22cbea61f904efec22f5e /src/main.cpp
parent0a706eae7476aed2abd7202f7064550bafbea829 (diff)
downloadunity-window-decorator-8d4371fb4f6711a0150989767a4a3769b556e8c4.tar.gz
unity-window-decorator-8d4371fb4f6711a0150989767a4a3769b556e8c4.tar.bz2
Use bcop in core.
Diffstat (limited to 'src/main.cpp')
-rw-r--r--src/main.cpp113
1 files changed, 22 insertions, 91 deletions
diff --git a/src/main.cpp b/src/main.cpp
index 4aa596e..6e2c5db 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -57,8 +57,6 @@ bool useDesktopHints = false;
bool debugOutput = false;
bool useCow = true;
-CompMetadata *coreMetadata = NULL;
-
unsigned int pluginClassHandlerIndex = 0;
static void
@@ -101,60 +99,14 @@ signalHandler (int sig)
}
}
-typedef struct _CompIOCtx {
- unsigned int offset;
- char *pluginData;
-} CompIOCtx;
-
-static int
-readCoreXmlCallback (void *context,
- char *buffer,
- int length)
-{
- CompIOCtx *ctx = (CompIOCtx *) context;
- unsigned int offset = ctx->offset;
- unsigned int i, j;
-
- i = CompMetadata::readXmlChunk ("<compiz><plugin name=\"core\"><options>",
- &offset, buffer, length);
-
- for (j = 0; j < COMP_OPTION_NUM; j++)
- {
- CompMetadata::OptionInfo info = coreOptionInfo[j];
-
- switch (j) {
- case COMP_OPTION_ACTIVE_PLUGINS:
- if (ctx->pluginData)
- info.data = ctx->pluginData;
- break;
- default:
- break;
- }
-
- i += CompMetadata::readXmlChunkFromOptionInfo (&info, &offset,
- buffer + i, length - i);
- }
-
- i += CompMetadata::readXmlChunk ("</options></plugin></compiz>", &offset,
- buffer + i, length - 1);
-
- if (!offset && length > (int)i)
- buffer[i++] = '\0';
-
- ctx->offset += i;
-
- return i;
-}
-
int
main (int argc, char **argv)
{
- CompIOCtx ctx;
- char *displayName = 0;
- char *plugin[256];
- int i, nPlugin = 0;
- Bool disableSm = FALSE;
- char *clientId = NULL;
+ char *displayName = 0;
+ std::vector<CompString> plugins;
+ int i;
+ Bool disableSm = FALSE;
+ char *clientId = NULL;
programName = argv[0];
programArgc = argc;
@@ -165,8 +117,6 @@ main (int argc, char **argv)
signal (SIGINT, signalHandler);
signal (SIGTERM, signalHandler);
- memset (&ctx, 0, sizeof (ctx));
-
for (i = 1; i < argc; i++)
{
if (!strcmp (argv[i], "--help"))
@@ -196,10 +146,6 @@ main (int argc, char **argv)
{
useDesktopHints = true;
}
- else if (!strcmp (argv[i], "--ignore-desktop-hints"))
- {
- /* backward compatibility */
- }
else if (!strcmp (argv[i], "--use-root-window"))
{
useCow = false;
@@ -233,29 +179,7 @@ main (int argc, char **argv)
}
else
{
- if (nPlugin < 256)
- plugin[nPlugin++] = argv[i];
- }
- }
-
- if (nPlugin)
- {
- int size = 256;
-
- for (i = 0; i < nPlugin; i++)
- size += strlen (plugin[i]) + 16;
-
- ctx.pluginData = (char *) malloc (size);
- if (ctx.pluginData)
- {
- char *ptr = ctx.pluginData;
-
- ptr += sprintf (ptr, "<type>string</type><default>");
-
- for (i = 0; i < nPlugin; i++)
- ptr += sprintf (ptr, "<value>%s</value>", plugin[i]);
-
- ptr += sprintf (ptr, "</default>");
+ plugins.push_back(argv[i]);
}
}
@@ -263,20 +187,28 @@ main (int argc, char **argv)
LIBXML_TEST_VERSION;
- coreMetadata = new CompMetadata;
+ screen = new CompScreen();
- if (!coreMetadata->addFromIO (readCoreXmlCallback, NULL, &ctx))
+ if (!screen)
return 1;
- if (ctx.pluginData)
- free (ctx.pluginData);
+ if (!plugins.empty ())
+ {
+ CompOption::Value::Vector list;
+ CompOption::Value value;
+ CompOption *o = screen->getOption ("active_plugins");
- coreMetadata->addFromFile ("core");
+ foreach (CompString &str, plugins)
+ {
+ value.set (str);
+ list.push_back (value);
+ }
- screen = new CompScreen();
+ value.set (CompOption::TypeString, list);
- if (!screen)
- return 1;
+ if (o)
+ o->set (value);
+ }
if (!screen->init (displayName))
return 1;
@@ -290,7 +222,6 @@ main (int argc, char **argv)
CompSession::close ();
delete screen;
- delete coreMetadata;
xmlCleanupParser ();