summaryrefslogtreecommitdiff
path: root/src/plugin.cpp
diff options
context:
space:
mode:
authorDennis Kasprzyk <onestone@compiz-fusion.org>2008-09-16 01:56:31 +0200
committerDennis Kasprzyk <onestone@compiz-fusion.org>2008-09-16 01:56:31 +0200
commit24111a340996d6ab19b365909aa96c91672b75d1 (patch)
treefc5b642f7aa1c9f3a770c7db4cab510ad9c1e9ad /src/plugin.cpp
parentd5acffa9795add9ebc9c6e6920a5e80581584863 (diff)
downloadmobileperf-24111a340996d6ab19b365909aa96c91672b75d1.tar.gz
mobileperf-24111a340996d6ab19b365909aa96c91672b75d1.tar.bz2
Drop never finished object handling.
Diffstat (limited to 'src/plugin.cpp')
-rw-r--r--src/plugin.cpp254
1 files changed, 111 insertions, 143 deletions
diff --git a/src/plugin.cpp b/src/plugin.cpp
index 60a0d4a..b4ad02f 100644
--- a/src/plugin.cpp
+++ b/src/plugin.cpp
@@ -34,7 +34,7 @@
#define foreach BOOST_FOREACH
#include <compiz-core.h>
-#include <compobject.h>
+#include "privatescreen.h"
CompPlugin::Map pluginsMap;
CompPlugin::List plugins;
@@ -43,25 +43,18 @@ class CorePluginVTable : public CompPlugin::VTable
{
public:
- const char *
- name () { return "core"; };
+ const char * name () { return "core"; };
- CompMetadata *
- getMetadata ();
+ CompMetadata * getMetadata ();
- virtual bool
- init ();
+ bool init ();
- virtual void
- fini ();
+ void fini ();
- CompOption::Vector &
- getObjectOptions (CompObject *object);
+ CompOption::Vector & getOptions ();
- bool
- setObjectOption (CompObject *object,
- const char *name,
- CompOption::Value &value);
+ bool setOption (const char *name,
+ CompOption::Value &value);
};
bool
@@ -82,27 +75,16 @@ CorePluginVTable::getMetadata ()
}
CompOption::Vector &
-CorePluginVTable::getObjectOptions (CompObject *object)
+CorePluginVTable::getOptions ()
{
- static GetPluginObjectOptionsProc dispTab[] = {
- (GetPluginObjectOptionsProc) CompScreen::getOptions
- };
-
- RETURN_DISPATCH (object, dispTab, ARRAY_SIZE (dispTab),
- noOptions, (object));
+ return screen->getOptions ();
}
bool
-CorePluginVTable::setObjectOption (CompObject *object,
- const char *name,
- CompOption::Value &value)
+CorePluginVTable::setOption (const char *name,
+ CompOption::Value &value)
{
- static SetPluginObjectOptionProc dispTab[] = {
- (SetPluginObjectOptionProc) CompScreen::setOption
- };
-
- RETURN_DISPATCH (object, dispTab, ARRAY_SIZE (dispTab), false,
- (object, name, value));
+ return screen->setOption (name, value);
}
CorePluginVTable coreVTable;
@@ -273,148 +255,105 @@ LoadPluginProc loaderLoadPlugin = dlloaderLoadPlugin;
UnloadPluginProc loaderUnloadPlugin = dlloaderUnloadPlugin;
ListPluginsProc loaderListPlugins = dlloaderListPlugins;
-struct InitObjectContext {
- CompPlugin *plugin;
- CompObject *object;
-};
-
-static bool
-initObjectTree (CompObject *object,
- InitObjectContext *pCtx);
-
-static bool
-finiObjectTree (CompObject *object,
- InitObjectContext *pCtx);
static bool
-initObjectTree (CompObject *object,
- InitObjectContext *pCtx)
+initPlugin (CompPlugin *p)
{
- CompPlugin *p = pCtx->plugin;
- InitObjectContext ctx;
-
- pCtx->object = object;
-
-
- if (!p->vTable->initObject (object))
- {
- compLogMessage (p->vTable->name (), CompLogLevelError,
- "InitObject failed");
- return false;
- }
-
- ctx.plugin = pCtx->plugin;
- ctx.object = NULL;
- if (!object->forEachChild (boost::bind (initObjectTree, _1, &ctx)))
+ if (!p->vTable->init ())
{
- object->forEachChild (boost::bind (finiObjectTree, _1, &ctx));
-
+ compLogMessage ("core", CompLogLevelError,
+ "InitPlugin '%s' failed", p->vTable->name ());
return false;
}
- if (!screen->initPluginForObject (p, object))
+ if (screen)
{
- object->forEachChild (boost::bind (finiObjectTree, _1, &ctx));
- p->vTable->finiObject (object);
-
- return false;
+ if (!p->vTable->initScreen (screen))
+ {
+ compLogMessage (p->vTable->name (), CompLogLevelError,
+ "initScreen failed");
+ p->vTable->fini ();
+ return false;
+ }
+ if (!screen->initPluginForScreen (p))
+ {
+ p->vTable->fini ();
+ return false;
+ }
}
return true;
}
-static bool
-finiObjectTree (CompObject *object,
- InitObjectContext *pCtx)
+static void
+finiPlugin (CompPlugin *p)
{
- CompPlugin *p = pCtx->plugin;
- InitObjectContext ctx;
- /* pCtx->object is set to the object that failed to be initialized */
- if (pCtx->object == object)
- return false;
-
- ctx.plugin = p;
- ctx.object = NULL;
-
- object->forEachChild (boost::bind (finiObjectTree, _1, &ctx));
-
- p->vTable->finiObject (object);
-
- screen->finiPluginForObject (p, object);
+ if (screen)
+ {
+ screen->finiPluginForScreen (p);
+ p->vTable->finiScreen (screen);
+ }
- return true;
+ p->vTable->fini ();
}
-static bool
-initPlugin (CompPlugin *p)
+bool
+CompScreen::initPluginForScreen (CompPlugin *p)
{
- InitObjectContext ctx;
+ WRAPABLE_HND_FUNC_RETURN(2, bool, initPluginForScreen, p)
- if (!p->vTable->init ())
+ bool status = true;
+ CompWindowList::iterator it, fail;
+ CompWindow *w;
+
+ it = fail = priv->windows.begin ();
+ for (;it != priv->windows.end (); it++)
{
- compLogMessage ("core", CompLogLevelError,
- "InitPlugin '%s' failed", p->vTable->name ());
- return false;
+ w = *it;
+ if (!p->vTable->initWindow (w))
+ {
+ compLogMessage (p->vTable->name (), CompLogLevelError,
+ "initWindow failed");
+ fail = it;
+ status = false;
+ }
}
- ctx.plugin = p;
- ctx.object = NULL;
-
- if (!initObjectTree (screen, &ctx))
+ it = priv->windows.begin ();
+ for (;it != fail; it++)
{
- p->vTable->fini ();
- return false;
+ w = *it;
+ p->vTable->finiWindow (w);
}
- return true;
+ return status;
}
-static void
-finiPlugin (CompPlugin *p)
+void
+CompScreen::finiPluginForScreen (CompPlugin *p)
{
- InitObjectContext ctx;
-
- ctx.plugin = p;
- ctx.object = NULL;
+ WRAPABLE_HND_FUNC(3, finiPluginForScreen, p)
- finiObjectTree (screen, &ctx);
-
- p->vTable->fini ();
+ foreach (CompWindow *w, priv->windows)
+ p->vTable->finiWindow (w);
}
bool
-CompPlugin::objectInitPlugins (CompObject *o)
+CompPlugin::screenInitPlugins (CompScreen *s)
{
- InitObjectContext ctx;
-
CompPlugin::List::reverse_iterator rit = plugins.rbegin ();
- ctx.object = NULL;
+ CompPlugin *p = NULL;
while (rit != plugins.rend ())
{
+ p = (*rit);
- ctx.plugin = (*rit);
-
- if (!initObjectTree (o, &ctx))
- {
- if (rit == plugins.rbegin ())
- return false;
- --rit;
- for (; rit != plugins.rbegin (); --rit)
- {
- ctx.plugin = (*rit);
-
- finiObjectTree (o, &ctx);
- }
-
- ctx.plugin = (*rit);
-
- finiObjectTree (o, &ctx);
- return false;
- }
+ if (p->vTable->initScreen (s))
+ s->initPluginForScreen (p);
+
rit++;
}
@@ -422,20 +361,39 @@ CompPlugin::objectInitPlugins (CompObject *o)
}
void
-CompPlugin::objectFiniPlugins (CompObject *o)
+CompPlugin::screenFiniPlugins (CompScreen *s)
{
- InitObjectContext ctx;
+ foreach (CompPlugin *p, plugins)
+ {
+ s->finiPluginForScreen (p);
+ p->vTable->finiScreen (s);
+ }
+
+}
- ctx.object = NULL;
+bool
+CompPlugin::windowInitPlugins (CompWindow *w)
+{
+ bool status = true;
foreach (CompPlugin *p, plugins)
{
- ctx.plugin = p;
+ p->vTable->finiWindow (w);
+ }
+
+ return status;
+}
- finiObjectTree (o, &ctx);
+void
+CompPlugin::windowFiniPlugins (CompWindow *w)
+{
+ foreach (CompPlugin *p, plugins)
+ {
+ p->vTable->finiWindow (w);
}
}
+
CompPlugin *
CompPlugin::find (const char *name)
{
@@ -667,26 +625,36 @@ CompPlugin::VTable::getMetadata ()
bool
-CompPlugin::VTable::initObject (CompObject *object)
+CompPlugin::VTable::initScreen (CompScreen *)
+{
+ return true;
+}
+
+void
+CompPlugin::VTable::finiScreen (CompScreen *)
+{
+}
+
+bool
+CompPlugin::VTable::initWindow (CompWindow *)
{
return true;
}
void
-CompPlugin::VTable::finiObject (CompObject *object)
+CompPlugin::VTable::finiWindow (CompWindow *)
{
}
CompOption::Vector &
-CompPlugin::VTable::getObjectOptions (CompObject *object)
+CompPlugin::VTable::getOptions ()
{
return noOptions;
}
bool
-CompPlugin::VTable::setObjectOption (CompObject *object,
- const char *name,
- CompOption::Value &value)
+CompPlugin::VTable::setOption (const char *name,
+ CompOption::Value &value)
{
return false;
}