summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDennis Kasprzyk <onestone@compiz-fusion.org>2009-03-15 16:35:50 +0100
committerDennis kasprzyk <onestone@compiz-fusion.org>2009-03-15 16:35:50 +0100
commite53039517058f27329feb72b237d3f46a9a03d8d (patch)
treeedc02bbeecfb516b7863bb8cf2aca7a2aaf24845
parentf8cf2bc2d5a7fe2d4f90f217aa1b7f6e2d47c345 (diff)
downloadcompiz-with-glib-mainloop-e53039517058f27329feb72b237d3f46a9a03d8d.tar.gz
compiz-with-glib-mainloop-e53039517058f27329feb72b237d3f46a9a03d8d.tar.bz2
Drop CompMetadata from plugin vtable.
Added getOptions and setOption functions to plugin vtable template class.
-rw-r--r--include/core/plugin.h126
-rw-r--r--src/main.cpp2
-rw-r--r--src/plugin.cpp21
3 files changed, 82 insertions, 67 deletions
diff --git a/include/core/plugin.h b/include/core/plugin.h
index 02e35a1..85867b5 100644
--- a/include/core/plugin.h
+++ b/include/core/plugin.h
@@ -28,36 +28,18 @@
#include <compiz.h>
#include <core/option.h>
-#include <core/metadata.h>
-#include <map>
+class CompScreen;
+extern CompScreen *screen;
-class CompMetadata;
+#include <map>
#define HOME_PLUGINDIR ".compiz/plugins"
-#define PLUGIN_OPTION_HELPER(screenName) \
-CompOption::Vector & getOptions () \
-{ \
- screenName *ps = screenName::get (screen); \
- if (ps) \
- return ps->getOptions (); \
- return noOptions; \
-} \
- \
-bool setOption (const char *name, \
- CompOption::Value &value) \
-{ \
- screenName *ps = screenName::get (screen); \
- if (ps) \
- return ps->setOption (name, value); \
- return false; \
-}
-
-#define COMPIZ_PLUGIN_20081216(name, classname) \
+#define COMPIZ_PLUGIN_20090315(name, classname) \
CompPlugin::VTable * name##VTable = NULL; \
extern "C" { \
- CompPlugin::VTable * getCompPluginVTable20081216_##name () \
+ CompPlugin::VTable * getCompPluginVTable20090315_##name () \
{ \
if (!name##VTable) \
{ \
@@ -103,46 +85,51 @@ class CompPlugin {
const CompString name () const;
- CompMetadata * getMetadata () const;
-
virtual bool init () = 0;
virtual void fini ();
- virtual bool initScreen (CompScreen *screen);
+ virtual bool initScreen (CompScreen *s);
- virtual void finiScreen (CompScreen *screen);
+ virtual void finiScreen (CompScreen *s);
- virtual bool initWindow (CompWindow *window);
+ virtual bool initWindow (CompWindow *w);
- virtual void finiWindow (CompWindow *window);
+ virtual void finiWindow (CompWindow *w);
- virtual CompOption::Vector & getOptions ();
+ virtual CompOption::Vector & getOptions () const;
- virtual bool setOption (const char *name,
+ virtual bool setOption (const CompString &name,
CompOption::Value &value);
private:
CompString mName;
- CompMetadata *mMetadata;
VTable **mSelf;
};
template <typename T, typename T2>
class VTableForScreenAndWindow : public VTable {
- bool initScreen (CompScreen *screen);
+ bool initScreen (CompScreen *s);
+
+ void finiScreen (CompScreen *s);
+
+ bool initWindow (CompWindow *w);
- void finiScreen (CompScreen *screen);
+ void finiWindow (CompWindow *w);
- bool initWindow (CompWindow *window);
+ CompOption::Vector & getOptions () const;
- void finiWindow (CompWindow *window);
+ bool setOption (const CompString &name, CompOption::Value &value);
};
template <typename T>
class VTableForScreen : public VTable {
- bool initScreen (CompScreen *screen);
+ bool initScreen (CompScreen *s);
- void finiScreen (CompScreen *screen);
+ void finiScreen (CompScreen *s);
+
+ CompOption::Vector & getOptions () const;
+
+ bool setOption (const CompString &name, CompOption::Value &value);
};
struct cmpStr
@@ -192,10 +179,11 @@ class CompPlugin {
};
+
template <typename T, typename T2>
-bool CompPlugin::VTableForScreenAndWindow<T,T2>::initScreen (CompScreen *screen)
+bool CompPlugin::VTableForScreenAndWindow<T,T2>::initScreen (CompScreen *s)
{
- T * ps = new T (screen);
+ T * ps = new T (s);
if (ps->loadFailed ())
{
delete ps;
@@ -205,16 +193,16 @@ bool CompPlugin::VTableForScreenAndWindow<T,T2>::initScreen (CompScreen *screen)
}
template <typename T, typename T2>
-void CompPlugin::VTableForScreenAndWindow<T,T2>::finiScreen (CompScreen *screen)
+void CompPlugin::VTableForScreenAndWindow<T,T2>::finiScreen (CompScreen *s)
{
- T * ps = T::get (screen);
+ T * ps = T::get (s);
delete ps;
}
template <typename T, typename T2>
-bool CompPlugin::VTableForScreenAndWindow<T,T2>::initWindow (CompWindow *window)
+bool CompPlugin::VTableForScreenAndWindow<T,T2>::initWindow (CompWindow *w)
{
- T2 * pw = new T2 (window);
+ T2 * pw = new T2 (w);
if (pw->loadFailed ())
{
delete pw;
@@ -224,16 +212,35 @@ bool CompPlugin::VTableForScreenAndWindow<T,T2>::initWindow (CompWindow *window)
}
template <typename T, typename T2>
-void CompPlugin::VTableForScreenAndWindow<T,T2>::finiWindow (CompWindow *window)
+void CompPlugin::VTableForScreenAndWindow<T,T2>::finiWindow (CompWindow *w)
{
- T2 * pw = T2::get (window);
+ T2 * pw = T2::get (w);
delete pw;
}
+template <typename T, typename T2>
+CompOption::Vector & CompPlugin::VTableForScreenAndWindow<T,T2>::getOptions () const
+{
+ CompOption::Class *oc = dynamic_cast<CompOption::Class *>(T::get (screen));
+ if (!oc)
+ return noOptions;
+ return oc->getOptions ();
+}
+
+template <typename T, typename T2>
+bool CompPlugin::VTableForScreenAndWindow<T,T2>::setOption (const CompString &name,
+ CompOption::Value &value)
+{
+ CompOption::Class *oc = dynamic_cast<CompOption::Class *>(T::get (screen));
+ if (!oc)
+ return false;
+ return oc->setOption (name, value);
+}
+
template <typename T>
-bool CompPlugin::VTableForScreen<T>::initScreen (CompScreen *screen)
+bool CompPlugin::VTableForScreen<T>::initScreen (CompScreen *s)
{
- T * ps = new T (screen);
+ T * ps = new T (s);
if (ps->loadFailed ())
{
delete ps;
@@ -243,12 +250,31 @@ bool CompPlugin::VTableForScreen<T>::initScreen (CompScreen *screen)
}
template <typename T>
-void CompPlugin::VTableForScreen<T>::finiScreen (CompScreen *screen)
+void CompPlugin::VTableForScreen<T>::finiScreen (CompScreen *s)
{
- T * ps = T::get (screen);
+ T * ps = T::get (s);
delete ps;
}
+template <typename T>
+CompOption::Vector & CompPlugin::VTableForScreen<T>::getOptions () const
+{
+ CompOption::Class *oc = dynamic_cast<CompOption::Class *>(T::get (screen));
+ if (!oc)
+ return noOptions;
+ return oc->getOptions ();
+}
+
+template <typename T>
+bool CompPlugin::VTableForScreen<T>::setOption (const CompString &name,
+ CompOption::Value &value)
+{
+ CompOption::Class *oc = dynamic_cast<CompOption::Class *>(T::get (screen));
+ if (!oc)
+ return false;
+ return oc->setOption (name, value);
+}
+
typedef CompPlugin::VTable *(*PluginGetInfoProc) (void);
#endif
diff --git a/src/main.cpp b/src/main.cpp
index 5071d83..4aa596e 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -263,7 +263,7 @@ main (int argc, char **argv)
LIBXML_TEST_VERSION;
- coreMetadata = getCoreVTable ()->getMetadata ();
+ coreMetadata = new CompMetadata;
if (!coreMetadata->addFromIO (readCoreXmlCallback, NULL, &ctx))
return 1;
diff --git a/src/plugin.cpp b/src/plugin.cpp
index 4b1c3df..fcf27f1 100644
--- a/src/plugin.cpp
+++ b/src/plugin.cpp
@@ -54,13 +54,13 @@ class CorePluginVTable : public CompPlugin::VTable
CompOption::Value &value);
};
-COMPIZ_PLUGIN_20081216 (core, CorePluginVTable)
+COMPIZ_PLUGIN_20090315 (core, CorePluginVTable)
CompPlugin::VTable * getCoreVTable ()
{
if (!coreVTable)
{
- return getCompPluginVTable20081216_core ();
+ return getCompPluginVTable20090315_core ();
}
return coreVTable;
@@ -162,7 +162,7 @@ dlloaderLoadPlugin (CompPlugin *p,
dlerror ();
- snprintf (sym, 1024, "getCompPluginVTable20081216_%s", name);
+ snprintf (sym, 1024, "getCompPluginVTable20090315_%s", name);
getInfo = (PluginGetInfoProc) dlsym (dlhand, sym);
error = dlerror ();
@@ -630,7 +630,6 @@ CompPlugin::checkPluginABI (const char *name,
CompPlugin::VTable::VTable () :
mName (""),
- mMetadata (NULL),
mSelf (NULL)
{
}
@@ -639,8 +638,6 @@ CompPlugin::VTable::~VTable ()
{
if (mSelf)
*mSelf = NULL;
- if (mMetadata)
- delete mMetadata;
}
void
@@ -653,14 +650,6 @@ CompPlugin::VTable::initVTable (CompString name,
mSelf = self;
*mSelf = this;
}
- if (!mMetadata)
- mMetadata = new CompMetadata (name);
-}
-
-CompMetadata *
-CompPlugin::VTable::getMetadata () const
-{
- return mMetadata;
}
const CompString
@@ -697,13 +686,13 @@ CompPlugin::VTable::finiWindow (CompWindow *)
}
CompOption::Vector &
-CompPlugin::VTable::getOptions ()
+CompPlugin::VTable::getOptions () const
{
return noOptions;
}
bool
-CompPlugin::VTable::setOption (const char *name,
+CompPlugin::VTable::setOption (const CompString &name,
CompOption::Value &value)
{
return false;