summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/compiz-core.h61
-rw-r--r--include/compiz.h3
-rw-r--r--include/compobject.h2
-rw-r--r--include/compplugin.h101
-rw-r--r--src/core.cpp10
-rw-r--r--src/display.cpp18
-rw-r--r--src/event.cpp21
-rw-r--r--src/match.cpp6
-rw-r--r--src/plugin.cpp299
-rw-r--r--src/screen.cpp4
-rw-r--r--src/window.cpp4
11 files changed, 228 insertions, 301 deletions
diff --git a/include/compiz-core.h b/include/compiz-core.h
index 822a398..bf57a8b 100644
--- a/include/compiz-core.h
+++ b/include/compiz-core.h
@@ -241,68 +241,7 @@ eventTerminates (CompDisplay *display,
/* plugin.c */
-#define HOME_PLUGINDIR ".compiz/plugins"
-typedef CompPluginVTable *(*PluginGetInfoProc) (void);
-
-typedef Bool (*LoadPluginProc) (CompPlugin *p,
- const char *path,
- const char *name);
-
-typedef void (*UnloadPluginProc) (CompPlugin *p);
-
-typedef char **(*ListPluginsProc) (const char *path,
- int *n);
-
-extern LoadPluginProc loaderLoadPlugin;
-extern UnloadPluginProc loaderUnloadPlugin;
-extern ListPluginsProc loaderListPlugins;
-
-struct _CompPlugin {
- CompPlugin *next;
- CompPrivate devPrivate;
- char *devType;
- CompPluginVTable *vTable;
-};
-
-bool
-objectInitPlugins (CompObject *o);
-
-void
-objectFiniPlugins (CompObject *o);
-
-CompPlugin *
-findActivePlugin (const char *name);
-
-CompPlugin *
-loadPlugin (const char *plugin);
-
-void
-unloadPlugin (CompPlugin *p);
-
-Bool
-pushPlugin (CompPlugin *p);
-
-CompPlugin *
-popPlugin (void);
-
-CompPlugin *
-getPlugins (void);
-
-char **
-availablePlugins (int *n);
-
-int
-getPluginABI (const char *name);
-
-Bool
-checkPluginABI (const char *name,
- int abi);
-
-Bool
-getPluginDisplayIndex (CompDisplay *d,
- const char *name,
- int *index);
/* fragment.c */
diff --git a/include/compiz.h b/include/compiz.h
index 9e033d3..353bbba 100644
--- a/include/compiz.h
+++ b/include/compiz.h
@@ -33,14 +33,13 @@
#include <list>
typedef std::string CompString;
+typedef std::list<CompString> CompStringList;
typedef int CompBool;
typedef int CompTimeoutHandle;
typedef int CompWatchFdHandle;
-typedef struct _CompPlugin CompPlugin;
-
class CompCore;
class CompDisplay;
diff --git a/include/compobject.h b/include/compobject.h
index 9ff1cde..13f14ad 100644
--- a/include/compobject.h
+++ b/include/compobject.h
@@ -20,7 +20,7 @@ typedef bool (*ObjectCallBackProc) (CompObject *object,
(sizeof (array) / sizeof (array[0]))
#define DISPATCH_CHECK(object, dispTab, tabSize) \
- ((object)->type () < (tabSize) && (dispTab)[(object)->type ()])
+ ((object)->type () < (int) (tabSize) && (dispTab)[(object)->type ()])
#define DISPATCH(object, dispTab, tabSize, args) \
if (DISPATCH_CHECK (object, dispTab, tabSize)) \
diff --git a/include/compplugin.h b/include/compplugin.h
index 0e2d0c9..39f2e67 100644
--- a/include/compplugin.h
+++ b/include/compplugin.h
@@ -37,40 +37,97 @@ typedef bool (*SetPluginObjectOptionProc) (CompObject *object,
const char *name,
CompOption::Value &value);
-class CompPluginVTable {
+#define HOME_PLUGINDIR ".compiz/plugins"
+
+class CompPlugin;
+
+typedef bool (*LoadPluginProc) (CompPlugin *p,
+ const char *path,
+ const char *name);
+
+typedef void (*UnloadPluginProc) (CompPlugin *p);
+
+typedef CompStringList (*ListPluginsProc) (const char *path);
+
+extern LoadPluginProc loaderLoadPlugin;
+extern UnloadPluginProc loaderUnloadPlugin;
+extern ListPluginsProc loaderListPlugins;
+
+class CompPlugin {
+ public:
+ class VTable {
+ public:
+ virtual ~VTable ();
+
+ virtual const char * name () = 0;
+
+ virtual CompMetadata *
+ getMetadata ();
+
+ virtual bool
+ init () = 0;
+
+ virtual void
+ fini () = 0;
+
+ virtual bool
+ initObject (CompObject *object);
+
+ virtual void
+ finiObject (CompObject *object);
+
+ virtual CompOption::Vector &
+ getObjectOptions (CompObject *object);
+
+ virtual bool
+ setObjectOption (CompObject *object,
+ const char *name,
+ CompOption::Value &value);
+ };
+
+ typedef std::list<CompPlugin *> List;
+
+ public:
+ CompPrivate devPrivate;
+ CompString devType;
+ VTable *vTable;
public:
- virtual ~CompPluginVTable ();
-
- virtual const char * name () = 0;
- virtual CompMetadata *
- getMetadata ();
+ static bool objectInitPlugins (CompObject *o);
+
+ static void objectFiniPlugins (CompObject *o);
+
+ static CompPlugin *find (const char *name);
- virtual bool
- init () = 0;
+ static CompPlugin *load (const char *plugin);
- virtual void
- fini () = 0;
+ static void unload (CompPlugin *p);
- virtual bool
- initObject (CompObject *object);
+ static bool push (CompPlugin *p);
- virtual void
- finiObject (CompObject *object);
-
- virtual CompOption::Vector &
- getObjectOptions (CompObject *object);
+ static CompPlugin *pop (void);
+
+ static List & getPlugins ();
+
+ static std::list<CompString> availablePlugins ();
+
+ static int getPluginABI (const char *name);
+
+ static bool checkPluginABI (const char *name,
+ int abi);
+
+ static bool getPluginDisplayIndex (CompDisplay *d,
+ const char *name,
+ int *index);
- virtual bool
- setObjectOption (CompObject *object,
- const char *name,
- CompOption::Value &value);
};
+typedef CompPlugin::VTable *(*PluginGetInfoProc) (void);
+
COMPIZ_BEGIN_DECLS
-CompPluginVTable *
+CompPlugin::VTable *
getCompPluginInfo20080805 (void);
COMPIZ_END_DECLS
diff --git a/src/core.cpp b/src/core.cpp
index 90789ef..6fc98ca 100644
--- a/src/core.cpp
+++ b/src/core.cpp
@@ -78,7 +78,7 @@ CompCore::init ()
WRAPABLE_INIT_HND(objectRemove);
WRAPABLE_INIT_HND(sessionEvent);
- CompPlugin *corePlugin = loadPlugin ("core");
+ CompPlugin *corePlugin = CompPlugin::load ("core");
if (!corePlugin)
{
compLogMessage (0, "core", CompLogLevelFatal,
@@ -86,7 +86,7 @@ CompCore::init ()
return false;
}
- if (!pushPlugin (corePlugin))
+ if (!CompPlugin::push (corePlugin))
{
compLogMessage (0, "core", CompLogLevelFatal,
"Couldn't activate core plugin");
@@ -109,8 +109,8 @@ CompCore::~CompCore ()
if (priv->watchPollFds)
free (priv->watchPollFds);
- while ((p = popPlugin ()))
- unloadPlugin (p);
+ while ((p = CompPlugin::pop ()))
+ CompPlugin::unload (p);
}
@@ -454,7 +454,7 @@ CompCore::setOptionForPlugin (CompObject *object,
WRAPABLE_HND_FUNC_RETURN(bool, setOptionForPlugin,
object, plugin, name, value)
- CompPlugin *p = findActivePlugin (plugin);
+ CompPlugin *p = CompPlugin::find (plugin);
if (p)
return p->vTable->setObjectOption (object, name, value);
diff --git a/src/display.cpp b/src/display.cpp
index 312a642..88a2f85 100644
--- a/src/display.cpp
+++ b/src/display.cpp
@@ -731,7 +731,7 @@ CompDisplay::~CompDisplay ()
priv->screens.pop_front ();
}
- objectFiniPlugins (this);
+ CompPlugin::objectFiniPlugins (this);
if (priv->snDisplay)
sn_display_unref (priv->snDisplay);
@@ -892,7 +892,7 @@ CompDisplay::init (const char *name)
core->addChild (this);
/* TODO: bailout properly when objectInitPlugins fails */
- assert (objectInitPlugins (this));
+ assert (CompPlugin::objectInitPlugins (this));
if (onlyCurrentScreen)
{
@@ -1458,10 +1458,10 @@ PrivateDisplay::updatePlugins ()
nPop = plugin.list ().size () - j;
printf("We have to pop %d plugins\n",nPop);
-
+
for (j = 0; j < nPop; j++)
{
- pop.push_back (popPlugin ());
+ pop.push_back (CompPlugin::pop ());
plugin.list ().pop_back ();
}
@@ -1472,7 +1472,7 @@ PrivateDisplay::updatePlugins ()
{
if (o->value ().list ()[i]. s ().compare (pp->vTable->name ()) == 0)
{
- if (pushPlugin (pp))
+ if (CompPlugin::push (pp))
{
p = pp;
pop.erase (std::find (pop.begin (), pop.end (), pp));
@@ -1484,12 +1484,12 @@ PrivateDisplay::updatePlugins ()
if (p == 0)
{
printf("Loading %d \"%s\"\n",i, o->value ().list ()[i].s ().c_str ());
- p = loadPlugin (o->value ().list ()[i].s ().c_str ());
+ p = CompPlugin::load (o->value ().list ()[i].s ().c_str ());
if (p)
{
- if (!pushPlugin (p))
+ if (!CompPlugin::push (p))
{
- unloadPlugin (p);
+ CompPlugin::unload (p);
p = 0;
}
}
@@ -1503,7 +1503,7 @@ PrivateDisplay::updatePlugins ()
foreach (CompPlugin *pp, pop)
{
- unloadPlugin (pp);
+ CompPlugin::unload (pp);
}
core->setOptionForPlugin (display, "core", o->name ().c_str (), plugin);
diff --git a/src/event.cpp b/src/event.cpp
index afe0716..b2dc872 100644
--- a/src/event.cpp
+++ b/src/event.cpp
@@ -618,9 +618,7 @@ triggerAllEdgeEnterBindings (CompDisplay *d,
unsigned int edge,
CompOption::Vector &arguments)
{
- CompPlugin *p;
-
- for (p = getPlugins (); p; p = p->next)
+ foreach (CompPlugin *p, CompPlugin::getPlugins ())
{
CompOption::Vector &options = p->vTable->getObjectOptions (d);
if (triggerEdgeEnterBindings (d, options, state, delayState, edge,
@@ -684,7 +682,6 @@ PrivateDisplay::handleActionEvent (XEvent *event)
{
CompObject *obj = display;
CompOption::Vector o (0);
- CompPlugin *p;
o.push_back (CompOption ("event_window", CompOption::TypeInt));
o.push_back (CompOption ("window", CompOption::TypeInt));
@@ -708,7 +705,7 @@ PrivateDisplay::handleActionEvent (XEvent *event)
o[6].value ().set ((int) event->xbutton.button);
o[7].value ().set ((int) event->xbutton.time);
- for (p = getPlugins (); p; p = p->next)
+ foreach (CompPlugin *p, CompPlugin::getPlugins ())
{
CompOption::Vector &options = p->vTable->getObjectOptions (obj);
if (triggerButtonPressBindings (options, event, o))
@@ -729,7 +726,7 @@ PrivateDisplay::handleActionEvent (XEvent *event)
o[6].value ().set ((int) event->xbutton.button);
o[7].value ().set ((int) event->xbutton.time);
- for (p = getPlugins (); p; p = p->next)
+ foreach (CompPlugin *p, CompPlugin::getPlugins ())
{
CompOption::Vector &options = p->vTable->getObjectOptions (obj);
if (triggerButtonReleaseBindings (options, event, o))
@@ -750,7 +747,7 @@ PrivateDisplay::handleActionEvent (XEvent *event)
o[6].value ().set ((int) event->xkey.keycode);
o[7].value ().set ((int) event->xkey.time);
- for (p = getPlugins (); p; p = p->next)
+ foreach (CompPlugin *p, CompPlugin::getPlugins ())
{
CompOption::Vector &options = p->vTable->getObjectOptions (obj);
if (triggerKeyPressBindings (options, event, o))
@@ -771,7 +768,7 @@ PrivateDisplay::handleActionEvent (XEvent *event)
o[6].value ().set ((int) event->xkey.keycode);
o[7].value ().set ((int) event->xkey.time);
- for (p = getPlugins (); p; p = p->next)
+ foreach (CompPlugin *p, CompPlugin::getPlugins ())
{
CompOption::Vector &options = p->vTable->getObjectOptions (obj);
if (triggerKeyReleaseBindings (options, event, o))
@@ -820,7 +817,7 @@ PrivateDisplay::handleActionEvent (XEvent *event)
o.push_back (CompOption ("time", CompOption::TypeInt));
o[6].value ().set ((int) event->xcrossing.time);
- for (p = getPlugins (); p; p = p->next)
+ foreach (CompPlugin *p, CompPlugin::getPlugins ())
{
CompOption::Vector &options =
p->vTable->getObjectOptions (obj);
@@ -906,7 +903,7 @@ PrivateDisplay::handleActionEvent (XEvent *event)
o[4].value ().set ((int) 0); /* fixme */
o[5].value ().set ((int) root);
- for (p = getPlugins (); p; p = p->next)
+ foreach (CompPlugin *p, CompPlugin::getPlugins ())
{
CompOption::Vector &options =
p->vTable->getObjectOptions (obj);
@@ -980,7 +977,7 @@ PrivateDisplay::handleActionEvent (XEvent *event)
o.resize (4);
- for (p = getPlugins (); p; p = p->next)
+ foreach (CompPlugin *p, CompPlugin::getPlugins ())
{
CompOption::Vector &options =
p->vTable->getObjectOptions (obj);
@@ -998,7 +995,7 @@ PrivateDisplay::handleActionEvent (XEvent *event)
o.resize (3);
- for (p = getPlugins (); p; p = p->next)
+ foreach (CompPlugin *p, CompPlugin::getPlugins ())
{
CompOption::Vector &options =
p->vTable->getObjectOptions (obj);
diff --git a/src/match.cpp b/src/match.cpp
index 60f2747..d6d6bd7 100644
--- a/src/match.cpp
+++ b/src/match.cpp
@@ -135,9 +135,7 @@ CompDisplay::matchExpHandlerChanged ()
{
WRAPABLE_HND_FUNC(matchExpHandlerChanged)
- CompPlugin *p;
-
- for (p = getPlugins (); p; p = p->next)
+ foreach (CompPlugin *p, CompPlugin::getPlugins ())
{
CompOption::Vector &options = p->vTable->getObjectOptions (this);
matchUpdateMatchOptions (options);
@@ -145,7 +143,7 @@ CompDisplay::matchExpHandlerChanged ()
foreach (CompScreen *s, priv->screens)
{
- for (p = getPlugins (); p; p = p->next)
+ foreach (CompPlugin *p, CompPlugin::getPlugins ())
{
CompOption::Vector &options = p->vTable->getObjectOptions (s);
matchUpdateMatchOptions (options);
diff --git a/src/plugin.cpp b/src/plugin.cpp
index 88e0cbf..c46b672 100644
--- a/src/plugin.cpp
+++ b/src/plugin.cpp
@@ -28,13 +28,17 @@
#include <string.h>
#include <dlfcn.h>
#include <dirent.h>
+#include <list>
+
+#include <boost/foreach.hpp>
+#define foreach BOOST_FOREACH
#include <compiz-core.h>
#include <compobject.h>
-CompPlugin *plugins = 0;
+std::list<CompPlugin *> plugins;
-class CorePluginVTable : public CompPluginVTable
+class CorePluginVTable : public CompPlugin::VTable
{
public:
@@ -103,27 +107,25 @@ CorePluginVTable::setObjectOption (CompObject *object,
RETURN_DISPATCH (object, dispTab, ARRAY_SIZE (dispTab), false,
(object, name, value));
}
-
-
-
+//
CorePluginVTable coreVTable;
-static Bool
+static bool
cloaderLoadPlugin (CompPlugin *p,
const char *path,
const char *name)
{
if (path)
- return FALSE;
+ return false;
if (strcmp (name, coreVTable.name ()))
- return FALSE;
+ return false;
p->vTable = &coreVTable;
p->devPrivate.ptr = NULL;
p->devType = "cloader";
- return TRUE;
+ return true;
}
static void
@@ -131,32 +133,20 @@ cloaderUnloadPlugin (CompPlugin *p)
{
}
-static char **
-cloaderListPlugins (const char *path,
- int *n)
+static CompStringList
+cloaderListPlugins (const char *path)
{
- char **list;
+ CompStringList rv;
if (path)
- return 0;
-
- list = (char **) malloc (sizeof (char *));
- if (!list)
- return 0;
-
- *list = strdup (coreVTable.name ());
- if (!*list)
- {
- free (list);
- return 0;
- }
+ return CompStringList ();
- *n = 1;
+ rv.push_back (CompString (coreVTable.name ()));
- return list;
+ return rv;
}
-static Bool
+static bool
dlloaderLoadPlugin (CompPlugin *p,
const char *path,
const char *name)
@@ -166,7 +156,7 @@ dlloaderLoadPlugin (CompPlugin *p,
file = (char *) malloc ((path ? strlen (path) : 0) + strlen (name) + 8);
if (!file)
- return FALSE;
+ return false;
if (path)
sprintf (file, "%s/lib%s.so", path, name);
@@ -205,7 +195,7 @@ dlloaderLoadPlugin (CompPlugin *p,
dlclose (dlhand);
free (file);
- return FALSE;
+ return false;
}
}
else
@@ -213,7 +203,7 @@ dlloaderLoadPlugin (CompPlugin *p,
dlclose (dlhand);
free (file);
- return FALSE;
+ return false;
}
}
else
@@ -228,13 +218,13 @@ dlloaderLoadPlugin (CompPlugin *p,
p->devPrivate.ptr = dlhand;
p->devType = "dlloader";
- return TRUE;
+ return true;
}
static void
dlloaderUnloadPlugin (CompPlugin *p)
{
- if (strcmp (p->devType, "dlloader") == 0)
+ if (p->devType.compare ("dlloader") == 0)
dlclose (p->devPrivate.ptr);
else
cloaderUnloadPlugin (p);
@@ -255,54 +245,33 @@ dlloaderFilter (const struct dirent *name)
return 1;
}
-static char **
-dlloaderListPlugins (const char *path,
- int *n)
+static CompStringList
+dlloaderListPlugins (const char *path)
{
struct dirent **nameList;
- char **list, **cList;
- char *name;
- int length, nFile, i, j = 0;
+ char name[1024];
+ int length, nFile, i;
- cList = cloaderListPlugins (path, n);
- if (cList)
- j = *n;
+ CompStringList rv = cloaderListPlugins (path);
if (!path)
path = ".";
nFile = scandir (path, &nameList, dlloaderFilter, alphasort);
if (!nFile)
- return cList;
-
- list = (char **) realloc (cList, (j + nFile) * sizeof (char *));
- if (!list)
- return cList;
+ return rv;
for (i = 0; i < nFile; i++)
{
length = strlen (nameList[i]->d_name);
- name = (char *) malloc ((length - 5) * sizeof (char));
- if (name)
- {
- strncpy (name, nameList[i]->d_name + 3, length - 6);
- name[length - 6] = '\0';
+ strncpy (name, nameList[i]->d_name + 3, length - 6);
+ name[length - 6] = '\0';
- list[j++] = name;
- }
+ rv.push_back (CompString (name));
}
- if (j)
- {
- *n = j;
-
- return list;
- }
-
- free (list);
-
- return NULL;
+ return rv;
}
LoadPluginProc loaderLoadPlugin = dlloaderLoadPlugin;
@@ -423,50 +392,50 @@ finiPlugin (CompPlugin *p)
}
bool
-objectInitPlugins (CompObject *o)
+CompPlugin::objectInitPlugins (CompObject *o)
{
InitObjectContext ctx;
- CompPlugin *p;
- int i, j = 0;
- ctx.object = NULL;
+ CompPlugin::List::reverse_iterator rit = plugins.rbegin ();
- for (p = plugins; p; p = p->next)
- j++;
+ ctx.object = NULL;
- while (j--)
+ while (rit != plugins.rend ())
{
- i = 0;
- for (p = plugins; i < j; p = p->next)
- i++;
- ctx.plugin = p;
+ ctx.plugin = (*rit);
if (!initObjectTree (o, (void *) &ctx))
{
- for (p = p->next; p; p = p->next)
+ if (rit == plugins.rbegin ())
+ return false;
+ --rit;
+ for (; rit != plugins.rbegin (); --rit)
{
- ctx.plugin = p;
+ ctx.plugin = (*rit);
finiObjectTree (o, (void *) &ctx);
}
+ ctx.plugin = (*rit);
+
+ finiObjectTree (o, (void *) &ctx);
return false;
}
+ rit++;
}
return true;
}
void
-objectFiniPlugins (CompObject *o)
+CompPlugin::objectFiniPlugins (CompObject *o)
{
InitObjectContext ctx;
- CompPlugin *p;
ctx.object = NULL;
- for (p = plugins; p; p = p->next)
+ foreach (CompPlugin *p, plugins)
{
ctx.plugin = p;
@@ -475,40 +444,37 @@ objectFiniPlugins (CompObject *o)
}
CompPlugin *
-findActivePlugin (const char *name)
+CompPlugin::find (const char *name)
{
- CompPlugin *p;
-
- for (p = plugins; p; p = p->next)
+ foreach (CompPlugin *p, plugins)
{
if (strcmp (p->vTable->name (), name) == 0)
return p;
}
- return 0;
+ return NULL;
}
void
-unloadPlugin (CompPlugin *p)
+CompPlugin::unload (CompPlugin *p)
{
(*loaderUnloadPlugin) (p);
- free (p);
+ delete p;
}
CompPlugin *
-loadPlugin (const char *name)
+CompPlugin::load (const char *name)
{
CompPlugin *p;
char *home, *plugindir;
Bool status;
- p = (CompPlugin *) malloc (sizeof (CompPlugin));
+ p = new CompPlugin ();
if (!p)
return 0;
- p->next = 0;
p->devPrivate.uval = 0;
- p->devType = NULL;
+ p->devType = "";
p->vTable = 0;
home = getenv ("HOME");
@@ -540,75 +506,70 @@ loadPlugin (const char *name)
return 0;
}
-Bool
-pushPlugin (CompPlugin *p)
+bool
+CompPlugin::push (CompPlugin *p)
{
- if (findActivePlugin (p->vTable->name ()))
+ if (find (p->vTable->name ()))
{
compLogMessage (NULL, "core", CompLogLevelWarn,
"Plugin '%s' already active",
p->vTable->name ());
- return FALSE;
+ return false;
}
- p->next = plugins;
- plugins = p;
+ plugins.push_front (p);
if (!initPlugin (p))
{
compLogMessage (NULL, "core", CompLogLevelError,
"Couldn't activate plugin '%s'", p->vTable->name ());
- plugins = p->next;
- return FALSE;
+ plugins.pop_front ();
+
+ return false;
}
- return TRUE;
+ return true;
}
CompPlugin *
-popPlugin (void)
+CompPlugin::pop (void)
{
- CompPlugin *p = plugins;
+ CompPlugin *p = plugins.front ();
if (!p)
return 0;
finiPlugin (p);
- plugins = p->next;
+ plugins.pop_front ();
return p;
}
-CompPlugin *
-getPlugins (void)
+CompPlugin::List &
+CompPlugin::getPlugins (void)
{
return plugins;
}
-static Bool
-stringExist (char **list,
- int nList,
- char *s)
+static bool
+stringExist (CompStringList &list,
+ CompString s)
{
- int i;
-
- for (i = 0; i < nList; i++)
- if (strcmp (list[i], s) == 0)
- return TRUE;
+ foreach (CompString &l, list)
+ if (s.compare (l) == 0)
+ return true;
- return FALSE;
+ return false;
}
-char **
-availablePlugins (int *n)
+CompStringList
+CompPlugin::availablePlugins ()
{
char *home, *plugindir;
- char **list, **currentList, **pluginList, **homeList = NULL;
- int nCurrentList, nPluginList, nHomeList;
- int count, i, j;
+ CompStringList list, currentList, pluginList, homeList;
home = getenv ("HOME");
if (home)
@@ -617,66 +578,42 @@ availablePlugins (int *n)
if (plugindir)
{
sprintf (plugindir, "%s/%s", home, HOME_PLUGINDIR);
- homeList = (*loaderListPlugins) (plugindir, &nHomeList);
+ homeList = (*loaderListPlugins) (plugindir);
free (plugindir);
}
}
- pluginList = (*loaderListPlugins) (PLUGINDIR, &nPluginList);
- currentList = (*loaderListPlugins) (NULL, &nCurrentList);
+ pluginList = (*loaderListPlugins) (PLUGINDIR);
+ currentList = (*loaderListPlugins) (NULL);
- count = 0;
- if (homeList)
- count += nHomeList;
- if (pluginList)
- count += nPluginList;
- if (currentList)
- count += nCurrentList;
-
- if (!count)
- return NULL;
-
- list = (char **) malloc (count * sizeof (char *));
- if (!list)
- return NULL;
-
- j = 0;
- if (homeList)
+ if (!homeList.empty ())
{
- for (i = 0; i < nHomeList; i++)
- if (!stringExist (list, j, homeList[i]))
- list[j++] = homeList[i];
-
- free (homeList);
+ foreach (CompString &s, homeList)
+ if (!stringExist (list, s))
+ list.push_back (s);
}
- if (pluginList)
+ if (!pluginList.empty ())
{
- for (i = 0; i < nPluginList; i++)
- if (!stringExist (list, j, pluginList[i]))
- list[j++] = pluginList[i];
-
- free (pluginList);
+ foreach (CompString &s, pluginList)
+ if (!stringExist (list, s))
+ list.push_back (s);
}
- if (currentList)
+ if (!currentList.empty ())
{
- for (i = 0; i < nCurrentList; i++)
- if (!stringExist (list, j, currentList[i]))
- list[j++] = currentList[i];
-
- free (currentList);
+ foreach (CompString &s, currentList)
+ if (!stringExist (list, s))
+ list.push_back (s);
}
- *n = j;
-
return list;
}
int
-getPluginABI (const char *name)
+CompPlugin::getPluginABI (const char *name)
{
- CompPlugin *p = findActivePlugin (name);
+ CompPlugin *p = find (name);
if (!p)
return 0;
@@ -688,9 +625,9 @@ getPluginABI (const char *name)
return CompOption::getIntOptionNamed (options, "abi");
}
-Bool
-checkPluginABI (const char *name,
- int abi)
+bool
+CompPlugin::checkPluginABI (const char *name,
+ int abi)
{
int pluginABI;
@@ -699,7 +636,7 @@ checkPluginABI (const char *name,
{
compLogMessage (NULL, "core", CompLogLevelError,
"Plugin '%s' not loaded.\n", name);
- return FALSE;
+ return false;
}
else if (pluginABI != abi)
{
@@ -707,65 +644,65 @@ checkPluginABI (const char *name,
"Plugin '%s' has ABI version '%d', expected "
"ABI version '%d'.\n",
name, pluginABI, abi);
- return FALSE;
+ return false;
}
- return TRUE;
+ return true;
}
-Bool
-getPluginDisplayIndex (CompDisplay *d,
- const char *name,
- int *index)
+bool
+CompPlugin::getPluginDisplayIndex (CompDisplay *d,
+ const char *name,
+ int *index)
{
- CompPlugin *p = findActivePlugin (name);
+ CompPlugin *p = find (name);
int value;
if (!p)
- return FALSE;
+ return false;
CompOption::Vector &options = p->vTable->getObjectOptions (d);
value = CompOption::getIntOptionNamed (options, "index", -1);
if (value < 0)
- return FALSE;
+ return false;
*index = value;
- return TRUE;
+ return true;
}
-CompPluginVTable::~CompPluginVTable ()
+CompPlugin::VTable::~VTable ()
{
}
CompMetadata *
-CompPluginVTable::getMetadata ()
+CompPlugin::VTable::getMetadata ()
{
return NULL;
}
bool
-CompPluginVTable::initObject (CompObject *object)
+CompPlugin::VTable::initObject (CompObject *object)
{
return true;
}
void
-CompPluginVTable::finiObject (CompObject *object)
+CompPlugin::VTable::finiObject (CompObject *object)
{
}
CompOption::Vector &
-CompPluginVTable::getObjectOptions (CompObject *object)
+CompPlugin::VTable::getObjectOptions (CompObject *object)
{
return noOptions;
}
bool
-CompPluginVTable::setObjectOption (CompObject *object,
+CompPlugin::VTable::setObjectOption (CompObject *object,
const char *name,
CompOption::Value &value)
{
diff --git a/src/screen.cpp b/src/screen.cpp
index 729bf8b..2dbdbbf 100644
--- a/src/screen.cpp
+++ b/src/screen.cpp
@@ -2154,7 +2154,7 @@ CompScreen::init (CompDisplay *display,
display->addChild (this);
/* TODO: bailout properly when objectInitPlugins fails */
- assert (objectInitPlugins (this));
+ assert (CompPlugin::objectInitPlugins (this));
@@ -2232,7 +2232,7 @@ CompScreen::~CompScreen ()
while (!priv->windows.empty ())
delete priv->windows.front ();
- objectFiniPlugins (this);
+ CompPlugin::objectFiniPlugins (this);
XUngrabKey (priv->display->dpy (), AnyKey, AnyModifier, priv->root);
diff --git a/src/window.cpp b/src/window.cpp
index ab38750..b9d785f 100644
--- a/src/window.cpp
+++ b/src/window.cpp
@@ -5103,7 +5103,7 @@ CompWindow::CompWindow (CompScreen *screen,
screen->addChild (this);
/* TODO: bailout properly when objectInitPlugins fails */
- assert (objectInitPlugins (this));
+ assert (CompPlugin::objectInitPlugins (this));
recalcActions ();
@@ -5175,7 +5175,7 @@ CompWindow::~CompWindow ()
core->objectRemove (priv->screen, this);
- objectFiniPlugins (this);
+ CompPlugin::objectFiniPlugins (this);
release ();