summaryrefslogtreecommitdiff
path: root/include/core
diff options
context:
space:
mode:
authorDennis Kasprzyk <onestone@compiz-fusion.org>2008-09-17 21:08:46 +0200
committerDennis Kasprzyk <onestone@compiz-fusion.org>2008-09-17 21:08:46 +0200
commitdddbb16680e4f8ef5101c471766ca7fa00213562 (patch)
treeb5ae90c4d935af656688023d8994530532f26629 /include/core
parent1153a9ee1459576b9a26ccdc0c3d923f7b24019a (diff)
downloadmobileperf-dddbb16680e4f8ef5101c471766ca7fa00213562.tar.gz
mobileperf-dddbb16680e4f8ef5101c471766ca7fa00213562.tar.bz2
Move core headers into core subdirectory.
Diffstat (limited to 'include/core')
-rw-r--r--include/core/action.h136
-rw-r--r--include/core/core.h84
-rw-r--r--include/core/icon.h22
-rw-r--r--include/core/match.h51
-rw-r--r--include/core/metadata.h75
-rw-r--r--include/core/option.h165
-rw-r--r--include/core/output.h34
-rw-r--r--include/core/plugin.h229
-rw-r--r--include/core/privatehandler.h159
-rw-r--r--include/core/screen.h10
-rw-r--r--include/core/session.h28
-rw-r--r--include/core/window.h4
-rw-r--r--include/core/wrapsystem.h160
13 files changed, 1150 insertions, 7 deletions
diff --git a/include/core/action.h b/include/core/action.h
new file mode 100644
index 0000000..e317a25
--- /dev/null
+++ b/include/core/action.h
@@ -0,0 +1,136 @@
+#ifndef _COMPACTION_H
+#define _COMPACTION_H
+
+#include <boost/function.hpp>
+
+#include <X11/Xlib-xcb.h>
+
+#include <core/option.h>
+
+class PrivateAction;
+
+#define CompModAlt 0
+#define CompModMeta 1
+#define CompModSuper 2
+#define CompModHyper 3
+#define CompModModeSwitch 4
+#define CompModNumLock 5
+#define CompModScrollLock 6
+#define CompModNum 7
+
+#define CompAltMask (1 << 16)
+#define CompMetaMask (1 << 17)
+#define CompSuperMask (1 << 18)
+#define CompHyperMask (1 << 19)
+#define CompModeSwitchMask (1 << 20)
+#define CompNumLockMask (1 << 21)
+#define CompScrollLockMask (1 << 22)
+
+#define CompNoMask (1 << 25)
+
+class CompAction {
+ public:
+ typedef enum {
+ StateInitKey = 1 << 0,
+ StateTermKey = 1 << 1,
+ StateInitButton = 1 << 2,
+ StateTermButton = 1 << 3,
+ StateInitBell = 1 << 4,
+ StateInitEdge = 1 << 5,
+ StateTermEdge = 1 << 6,
+ StateInitEdgeDnd = 1 << 7,
+ StateTermEdgeDnd = 1 << 8,
+ StateCommit = 1 << 9,
+ StateCancel = 1 << 10,
+ StateAutoGrab = 1 << 11,
+ StateNoEdgeDelay = 1 << 12
+ } StateEnum;
+
+ typedef enum {
+ BindingTypeNone = 0,
+ BindingTypeKey = 1 << 0,
+ BindingTypeButton = 1 << 1,
+ BindingTypeEdgeButton = 1 << 2
+ } BindingTypeEnum;
+
+ class KeyBinding {
+ public:
+ KeyBinding ();
+ KeyBinding (const KeyBinding&);
+
+ unsigned int modifiers ();
+ int keycode ();
+
+ bool fromString (const CompString str);
+ CompString toString ();
+
+ private:
+ unsigned int mModifiers;
+ int mKeycode;
+ };
+
+ class ButtonBinding {
+ public:
+ ButtonBinding ();
+ ButtonBinding (const ButtonBinding&);
+
+ unsigned int modifiers ();
+ int button ();
+
+ bool fromString (const CompString str);
+ CompString toString ();
+
+ private:
+ unsigned int mModifiers;
+ int mButton;
+ };
+
+ typedef unsigned int State;
+ typedef unsigned int BindingType;
+ typedef boost::function <bool (CompAction *, State, CompOption::Vector &)> CallBack;
+
+ public:
+ CompAction ();
+ CompAction (const CompAction &);
+ ~CompAction ();
+
+ CallBack initiate ();
+ CallBack terminate ();
+
+ void setInitiate (const CallBack &initiate);
+ void setTerminate (const CallBack &terminate);
+
+ State state ();
+ BindingType type ();
+
+ KeyBinding & key ();
+ ButtonBinding & button ();
+
+ unsigned int edgeMask ();
+ void setEdgeMask (unsigned int edge);
+
+ bool bell ();
+ void setBell (bool bell);
+
+ void setState (State state);
+
+ void copyState (const CompAction &action);
+
+ bool operator== (const CompAction& val);
+ CompAction & operator= (const CompAction &action);
+
+ void keyFromString (const CompString str);
+ void buttonFromString (const CompString str);
+ void edgeMaskFromString (const CompString str);
+
+ CompString keyToString ();
+ CompString buttonToString ();
+ CompString edgeMaskToString ();
+
+ static CompString edgeToString (unsigned int edge);
+
+ private:
+ PrivateAction *priv;
+};
+
+#endif
diff --git a/include/core/core.h b/include/core/core.h
new file mode 100644
index 0000000..d8c45ce
--- /dev/null
+++ b/include/core/core.h
@@ -0,0 +1,84 @@
+/*
+ * Copyright © 2007 Novell, Inc.
+ *
+ * Permission to use, copy, modify, distribute, and sell this software
+ * and its documentation for any purpose is hereby granted without
+ * fee, provided that the above copyright notice appear in all copies
+ * and that both that copyright notice and this permission notice
+ * appear in supporting documentation, and that the name of
+ * Novell, Inc. not be used in advertising or publicity pertaining to
+ * distribution of the software without specific, written prior permission.
+ * Novell, Inc. makes no representations about the suitability of this
+ * software for any purpose. It is provided "as is" without express or
+ * implied warranty.
+ *
+ * NOVELL, INC. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN
+ * NO EVENT SHALL NOVELL, INC. BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
+ * OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
+ * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
+ * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ *
+ * Author: David Reveman <davidr@novell.com>
+ */
+
+#ifndef _COMPIZ_CORE_H
+#define _COMPIZ_CORE_H
+
+#define CORE_ABIVERSION 20080618
+
+#include <stdio.h>
+#include <assert.h>
+
+#include <X11/Xlib-xcb.h>
+#include <X11/Xutil.h>
+#include <X11/extensions/Xdamage.h>
+#include <X11/extensions/Xinerama.h>
+#include <X11/extensions/sync.h>
+#include <X11/Xregion.h>
+#include <X11/XKBlib.h>
+
+// X11 Bool defination breaks BOOST_FOREACH. Convert it to a typedef */
+#ifdef Bool
+typedef Bool XBool;
+#undef Bool
+typedef XBool Bool;
+#endif
+
+#include <boost/function.hpp>
+#include <boost/bind.hpp>
+#include <boost/foreach.hpp>
+#define foreach BOOST_FOREACH
+
+/*
+ * WORDS_BIGENDIAN should be defined before including this file for
+ * IMAGE_BYTE_ORDER and BITMAP_BIT_ORDER to be set correctly.
+ */
+#define LSBFirst 0
+#define MSBFirst 1
+
+#ifdef WORDS_BIGENDIAN
+# define IMAGE_BYTE_ORDER MSBFirst
+# define BITMAP_BIT_ORDER MSBFirst
+#else
+# define IMAGE_BYTE_ORDER LSBFirst
+# define BITMAP_BIT_ORDER LSBFirst
+#endif
+
+#include <core/privates.h>
+#include <core/screen.h>
+#include <core/window.h>
+#include <core/plugin.h>
+#include <core/option.h>
+#include <core/metadata.h>
+#include <core/action.h>
+#include <core/icon.h>
+#include <core/match.h>
+#include <core/output.h>
+#include <core/point.h>
+#include <core/rect.h>
+#include <core/session.h>
+#include <core/size.h>
+
+#endif
diff --git a/include/core/icon.h b/include/core/icon.h
new file mode 100644
index 0000000..34cfce8
--- /dev/null
+++ b/include/core/icon.h
@@ -0,0 +1,22 @@
+#ifndef _COMPICON_H
+#define _COMPICON_H
+
+class CompScreen;
+
+class CompIcon {
+ public:
+ CompIcon (CompScreen *screen, unsigned width, unsigned int height);
+ ~CompIcon ();
+
+ unsigned int width ();
+ unsigned int height ();
+ unsigned char* data ();
+
+ private:
+ int mWidth;
+ unsigned int mHeight;
+ unsigned char *mData;
+ bool mUpdateTex;
+};
+
+#endif
diff --git a/include/core/match.h b/include/core/match.h
new file mode 100644
index 0000000..227175e
--- /dev/null
+++ b/include/core/match.h
@@ -0,0 +1,51 @@
+#ifndef _COMPMATCH_H
+#define _COMPMATCH_H
+
+#include <core/core.h>
+
+class PrivateMatch;
+class CompWindow;
+class CompDisplay;
+
+class CompMatch {
+ public:
+
+ class Expression {
+ public:
+ virtual ~Expression () {};
+ virtual bool evaluate (CompWindow *window) = 0;
+ };
+
+ public:
+ CompMatch ();
+ CompMatch (const CompString);
+ CompMatch (const CompMatch &);
+ ~CompMatch ();
+
+ void update ();
+ bool evaluate (CompWindow *window);
+
+ CompString toString ();
+
+ CompMatch & operator= (const CompMatch &);
+ CompMatch & operator&= (const CompMatch &);
+ CompMatch & operator|= (const CompMatch &);
+
+ const CompMatch & operator& (const CompMatch &);
+ const CompMatch & operator| (const CompMatch &);
+ const CompMatch & operator! ();
+
+ CompMatch & operator= (const CompString &);
+ CompMatch & operator&= (const CompString &);
+ CompMatch & operator|= (const CompString &);
+
+ const CompMatch & operator& (const CompString &);
+ const CompMatch & operator| (const CompString &);
+
+ bool operator== (const CompMatch &);
+
+ private:
+ PrivateMatch *priv;
+};
+
+#endif
diff --git a/include/core/metadata.h b/include/core/metadata.h
new file mode 100644
index 0000000..1e2fcf2
--- /dev/null
+++ b/include/core/metadata.h
@@ -0,0 +1,75 @@
+#ifndef _COMPMETADATA_H
+#define _COMPMETADATA_H
+
+#include <vector>
+
+#include <libxml/parser.h>
+
+#include <core/action.h>
+
+#define STRINGIFY(x) #x
+#define TOSTRING(x) STRINGIFY (x)
+#define MINTOSTRING(x) "<min>" TOSTRING (x) "</min>"
+#define MAXTOSTRING(x) "<max>" TOSTRING (x) "</max>"
+#define RESTOSTRING(min, max) MINTOSTRING (min) MAXTOSTRING (max)
+
+class CompMetadata {
+ public:
+ struct OptionInfo {
+ const char *name;
+ const char *type;
+ const char *data;
+ CompAction::CallBack initiate;
+ CompAction::CallBack terminate;
+ };
+ public:
+ CompMetadata ();
+ CompMetadata (CompString plugin,
+ const OptionInfo *optionInfo = NULL,
+ unsigned int nOptionInfo = 0);
+ ~CompMetadata ();
+
+ std::vector<xmlDoc *> &doc ();
+
+ bool addFromFile (CompString file);
+ bool addFromString (CompString string);
+ bool addFromIO (xmlInputReadCallback ioread,
+ xmlInputCloseCallback ioclose,
+ void *ioctx);
+
+ bool initOption (CompOption *option,
+ CompString name);
+
+ bool initOptions (const OptionInfo *info,
+ unsigned int nOptions,
+ CompOption::Vector &options);
+
+
+
+ CompString getShortPluginDescription ();
+
+ CompString getLongPluginDescription ();
+
+ CompString getShortOptionDescription (CompOption *option);
+
+ CompString getLongOptionDescription (CompOption *option);
+
+ CompString getStringFromPath (CompString path);
+
+ static unsigned int readXmlChunk (const char *src,
+ unsigned int *offset,
+ char *buffer,
+ unsigned int length);
+
+ static unsigned int
+ readXmlChunkFromOptionInfo (const CompMetadata::OptionInfo *info,
+ unsigned int *offset,
+ char *buffer,
+ unsigned int length);
+
+ private:
+ CompString mPath;
+ std::vector<xmlDoc *> mDoc;
+};
+
+#endif
diff --git a/include/core/option.h b/include/core/option.h
new file mode 100644
index 0000000..227c156
--- /dev/null
+++ b/include/core/option.h
@@ -0,0 +1,165 @@
+#ifndef _COMPOPTION_H
+#define _COMPOPTION_H
+
+#include <compiz.h>
+
+#include <vector>
+
+class PrivateOption;
+class PrivateValue;
+class PrivateRestriction;
+class CompAction;
+class CompMatch;
+class CompScreen;
+
+class CompOption {
+ public:
+ typedef enum {
+ TypeBool,
+ TypeInt,
+ TypeFloat,
+ TypeString,
+ TypeColor,
+ TypeAction,
+ TypeKey,
+ TypeButton,
+ TypeEdge,
+ TypeBell,
+ TypeMatch,
+ TypeList
+ } Type;
+
+ class Value {
+ public:
+ typedef std::vector<Value> Vector;
+
+ public:
+ Value ();
+ Value (const Value &);
+ Value (const bool b);
+ Value (const int i);
+ Value (const float f);
+ Value (const unsigned short *color);
+ Value (const CompString& s);
+ Value (const char *s);
+ Value (const CompMatch& m);
+ Value (const CompAction& a);
+ Value (Type type, const Vector& l);
+ ~Value ();
+
+ void set (const bool b);
+ void set (const int i);
+ void set (const float f);
+ void set (const unsigned short *color);
+ void set (const CompString& s);
+ void set (const char *s);
+ void set (const CompMatch& m);
+ void set (const CompAction& a);
+ void set (Type type, const Vector& l);
+
+ bool b ();
+ int i ();
+ float f ();
+ unsigned short* c ();
+ CompString s ();
+ CompMatch & match ();
+ CompAction & action ();
+ Type listType ();
+ Vector & list ();
+
+ bool operator== (const Value& val);
+ bool operator!= (const Value& val);
+ Value & operator= (const Value &val);
+
+ private:
+ PrivateValue *priv;
+ };
+
+ class Restriction {
+ public:
+ Restriction ();
+ Restriction (const Restriction &);
+ ~Restriction ();
+
+ int iMin ();
+ int iMax ();
+ float fMin ();
+ float fMax ();
+ float fPrecision ();
+
+ void set (int, int);
+ void set (float, float, float);
+
+ bool inRange (int);
+ bool inRange (float);
+
+ Restriction & operator= (const Restriction &rest);
+ private:
+ PrivateRestriction *priv;
+ };
+
+ typedef std::vector<CompOption> Vector;
+
+ public:
+ CompOption ();
+ CompOption (const CompOption &);
+ CompOption (CompString name, Type type);
+ ~CompOption ();
+
+ void setName (CompString name, Type type);
+
+ CompString name ();
+
+ Type type ();
+ Value & value ();
+ Restriction & rest ();
+
+ bool set (Value &val);
+ bool isAction ();
+
+ CompOption & operator= (const CompOption &option);
+
+ public:
+ static CompOption * findOption (Vector &options, CompString name,
+ unsigned int *index = NULL);
+
+ static bool getBoolOptionNamed (Vector &options, CompString name,
+ bool defaultValue = false);
+
+ static int getIntOptionNamed (Vector &options, CompString name,
+ int defaultValue = 0);
+
+ static float getFloatOptionNamed (Vector &options, CompString name,
+ float defaultValue = 0.0);
+
+ static CompString getStringOptionNamed (Vector &options,
+ CompString name,
+ CompString defaultValue = "");
+
+ static unsigned short * getColorOptionNamed (Vector &options,
+ CompString name,
+ unsigned short *defaultValue);
+
+ static CompMatch & getMatchOptionNamed (Vector &options,
+ CompString name,
+ CompMatch &defaultValue);
+
+ static CompString typeToString (Type type);
+
+ static bool stringToColor (CompString color,
+ unsigned short *rgba);
+
+ static CompString colorToString (unsigned short *rgba);
+
+
+ static bool setOption (CompOption &o, Value &value);
+
+
+
+ private:
+ PrivateOption *priv;
+};
+
+extern CompOption::Vector noOptions;
+
+#endif
diff --git a/include/core/output.h b/include/core/output.h
new file mode 100644
index 0000000..6c1e1dd
--- /dev/null
+++ b/include/core/output.h
@@ -0,0 +1,34 @@
+#ifndef _COMPOUTPUT_H
+#define _COMPOUTPUT_H
+
+#include <core/core.h>
+#include <core/rect.h>
+
+class CompOutput : public CompRect {
+
+ public:
+ CompOutput ();
+
+ CompString name ();
+
+ unsigned int id ();
+
+ XRectangle workArea ();
+
+ void setWorkArea (XRectangle);
+ void setGeometry (int, int, int, int);
+ void setId (CompString, unsigned int);
+
+ typedef std::vector<CompOutput> vector;
+ typedef std::vector<CompOutput *> ptrVector;
+ typedef std::list<CompOutput *> ptrList;
+
+ private:
+
+ CompString mName;
+ unsigned int mId;
+
+ XRectangle mWorkArea;
+};
+
+#endif
diff --git a/include/core/plugin.h b/include/core/plugin.h
new file mode 100644
index 0000000..d78a70f
--- /dev/null
+++ b/include/core/plugin.h
@@ -0,0 +1,229 @@
+/*
+ * Copyright © 2007 Novell, Inc.
+ *
+ * Permission to use, copy, modify, distribute, and sell this software
+ * and its documentation for any purpose is hereby granted without
+ * fee, provided that the above copyright notice appear in all copies
+ * and that both that copyright notice and this permission notice
+ * appear in supporting documentation, and that the name of
+ * Novell, Inc. not be used in advertising or publicity pertaining to
+ * distribution of the software without specific, written prior permission.
+ * Novell, Inc. makes no representations about the suitability of this
+ * software for any purpose. It is provided "as is" without express or
+ * implied warranty.
+ *
+ * NOVELL, INC. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN
+ * NO EVENT SHALL NOVELL, INC. BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
+ * OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
+ * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
+ * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ *
+ * Author: David Reveman <davidr@novell.com>
+ */
+
+#ifndef _COMPIZ_PLUGIN_H
+#define _COMPIZ_PLUGIN_H
+
+#include <compiz.h>
+#include <core/option.h>
+
+#include <map>
+
+class CompMetadata;
+
+#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; \
+}
+
+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 initScreen (CompScreen *screen);
+
+ virtual void finiScreen (CompScreen *screen);
+
+ virtual bool initWindow (CompWindow *window);
+
+ virtual void finiWindow (CompWindow *window);
+
+ virtual CompOption::Vector & getOptions ();
+
+ virtual bool setOption (const char *name,
+ CompOption::Value &value);
+ };
+
+ template <typename T, typename T2>
+ class VTableForScreenAndWindow : public VTable {
+ bool initScreen (CompScreen *screen);
+
+ void finiScreen (CompScreen *screen);
+
+ bool initWindow (CompWindow *window);
+
+ void finiWindow (CompWindow *window);
+ };
+
+ template <typename T>
+ class VTableForScreen : public VTable {
+ bool initScreen (CompScreen *screen);
+
+ void finiScreen (CompScreen *screen);
+ };
+
+ struct cmpStr
+ {
+ bool operator() (const char *a, const char *b) const
+ {
+ return strcmp (a, b) < 0;
+ }
+ };
+
+ typedef std::map<const char *, CompPlugin *, cmpStr> Map;
+ typedef std::list<CompPlugin *> List;
+
+ public:
+ CompPrivate devPrivate;
+ CompString devType;
+ VTable *vTable;
+
+ public:
+
+ static bool screenInitPlugins (CompScreen *s);
+
+ static void screenFiniPlugins (CompScreen *s);
+
+ static bool windowInitPlugins (CompWindow *w);
+
+ static void windowFiniPlugins (CompWindow *w);
+
+ static CompPlugin *find (const char *name);
+
+ static CompPlugin *load (const char *plugin);
+
+ static void unload (CompPlugin *p);
+
+ static bool push (CompPlugin *p);
+
+ 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);
+
+};
+
+template <typename T, typename T2>
+bool CompPlugin::VTableForScreenAndWindow<T,T2>::initScreen (CompScreen *screen)
+{
+ T * ps = new T (screen);
+ if (ps->loadFailed ())
+ {
+ delete ps;
+ return false;
+ }
+ return true;
+}
+
+template <typename T, typename T2>
+void CompPlugin::VTableForScreenAndWindow<T,T2>::finiScreen (CompScreen *screen)
+{
+ T * ps = T::get (screen);
+ delete ps;
+}
+
+template <typename T, typename T2>
+bool CompPlugin::VTableForScreenAndWindow<T,T2>::initWindow (CompWindow *window)
+{
+ T2 * pw = new T2 (window);
+ if (pw->loadFailed ())
+ {
+ delete pw;
+ return false;
+ }
+ return true;
+}
+
+template <typename T, typename T2>
+void CompPlugin::VTableForScreenAndWindow<T,T2>::finiWindow (CompWindow *window)
+{
+ T2 * pw = T2::get (window);
+ delete pw;
+}
+
+template <typename T>
+bool CompPlugin::VTableForScreen<T>::initScreen (CompScreen *screen)
+{
+ T * ps = new T (screen);
+ if (ps->loadFailed ())
+ {
+ delete ps;
+ return false;
+ }
+ return true;
+}
+
+template <typename T>
+void CompPlugin::VTableForScreen<T>::finiScreen (CompScreen *screen)
+{
+ T * ps = T::get (screen);
+ delete ps;
+}
+
+typedef CompPlugin::VTable *(*PluginGetInfoProc) (void);
+
+COMPIZ_BEGIN_DECLS
+
+CompPlugin::VTable *
+getCompPluginInfo20080805 (void);
+
+COMPIZ_END_DECLS
+
+#endif
diff --git a/include/core/privatehandler.h b/include/core/privatehandler.h
new file mode 100644
index 0000000..fc911a2
--- /dev/null
+++ b/include/core/privatehandler.h
@@ -0,0 +1,159 @@
+
+#ifndef _COMPPRIVATEINDEX_
+#define _COMPPRIVATEINDEX_
+class CompPrivateIndex {
+ public:
+ CompPrivateIndex () : index(-1), refCount (0),
+ initiated (false), failed (false) {}
+
+ int index;
+ int refCount;
+ bool initiated;
+ bool failed;
+};
+
+#endif
+
+#if defined(PLUGIN) || !defined(_COMPPRIVATEHANDLER_)
+
+#include <typeinfo>
+#include <boost/preprocessor/cat.hpp>
+
+#include <compiz.h>
+#include <core/screen.h>
+#include <core/privates.h>
+
+#if !defined(PLUGIN)
+#define PLUGIN
+#define _COMPPRIVATEHANDLER_
+#endif
+
+#define INDICESNAME BOOST_PP_CAT(PLUGIN, PrivateIndicies)
+#define CLASSNAME BOOST_PP_CAT(PLUGIN, PrivateHandler)
+
+static CompPrivateIndex INDICESNAME[MAX_PRIVATE_STORAGE];
+
+template<class Tp, class Tb, int ABI = 0>
+class CLASSNAME {
+ public:
+ CLASSNAME (Tb *);
+ ~CLASSNAME ();
+
+ void setFailed () { mFailed = true; };
+ bool loadFailed () { return mFailed; };
+
+ Tb * get () { return mBase; };
+ static Tp * get (Tb *);
+
+ private:
+ static CompString keyName ()
+ {
+ return compPrintf ("%s_index_%lu", typeid (Tp).name (), ABI);
+ }
+
+ private:
+ bool mFailed;
+ bool mPrivFailed;
+ Tb *mBase;
+};
+
+template<class Tp, class Tb, int ABI>
+CLASSNAME<Tp,Tb,ABI>::CLASSNAME (Tb *base) :
+ mFailed (false),
+ mPrivFailed (false),
+ mBase (base)
+{
+ if (mBase->storageIndex () >= MAX_PRIVATE_STORAGE ||
+ INDICESNAME[base->storageIndex ()].failed)
+ {
+ mFailed = true;
+ mPrivFailed = true;
+ }
+ else
+ {
+ if (!INDICESNAME[mBase->storageIndex ()].initiated)
+ {
+ INDICESNAME[mBase->storageIndex ()].index = Tb::allocPrivateIndex ();
+ if (INDICESNAME[mBase->storageIndex ()].index >= 0)
+ {
+ INDICESNAME[mBase->storageIndex ()].initiated = true;
+
+ CompPrivate p;
+ p.val = INDICESNAME[mBase->storageIndex ()].index;
+
+ if (!screen->hasValue (keyName ()))
+ {
+ screen->storeValue (keyName (), p);
+ }
+ else
+ {
+ compLogMessage ("core", CompLogLevelFatal,
+ "Private index value \"%s\" already stored in screen.",
+ keyName ().c_str ());
+ }
+ }
+ else
+ {
+ INDICESNAME[mBase->storageIndex ()].failed = true;
+ mPrivFailed = true;
+ mFailed = true;
+ }
+ }
+
+ if (!INDICESNAME[mBase->storageIndex ()].failed)
+ {
+ INDICESNAME[mBase->storageIndex ()].refCount++;
+ mBase->privates[INDICESNAME[mBase->storageIndex ()].index].ptr =
+ static_cast<Tp *> (this);
+ }
+ }
+}
+
+template<class Tp, class Tb, int ABI>
+CLASSNAME<Tp,Tb,ABI>::~CLASSNAME ()
+{
+ if (!mPrivFailed && !INDICESNAME[mBase->storageIndex ()].failed)
+ {
+ INDICESNAME[mBase->storageIndex ()].refCount--;
+
+ if (INDICESNAME[mBase->storageIndex ()].refCount == 0)
+ {
+ Tb::freePrivateIndex (INDICESNAME[mBase->storageIndex ()].index);
+ INDICESNAME[mBase->storageIndex ()].initiated = false;
+ screen->eraseValue (keyName ());
+ }
+ }
+}
+
+template<class Tp, class Tb, int ABI>
+Tp *
+CLASSNAME<Tp,Tb,ABI>::get (Tb *base)
+{
+ if (INDICESNAME[base->storageIndex ()].initiated)
+ {
+ return static_cast<Tp *>
+ (base->privates[INDICESNAME[base->storageIndex ()].index].ptr);
+ }
+ if (INDICESNAME[base->storageIndex ()].failed)
+ return NULL;
+
+ if (screen->hasValue (keyName ()))
+ {
+ INDICESNAME[base->storageIndex ()].index =
+ screen->getValue (keyName ()).val;
+ INDICESNAME[base->storageIndex ()].initiated = true;
+ INDICESNAME[base->storageIndex ()].refCount = -1;
+ return static_cast<Tp *>
+ (base->privates[INDICESNAME[base->storageIndex ()].index].ptr);
+ }
+ else
+ {
+ INDICESNAME[base->storageIndex ()].failed = true;
+ return NULL;
+ }
+}
+
+#undef INDICESNAME
+#undef CLASSNAME
+#undef PLUGIN
+#endif
diff --git a/include/core/screen.h b/include/core/screen.h
index 52b3fbf..8037d4e 100644
--- a/include/core/screen.h
+++ b/include/core/screen.h
@@ -2,11 +2,11 @@
#define _COMPSCREEN_H
#include <core/window.h>
-#include <compoutput.h>
-#include <compsession.h>
-#include <compmetadata.h>
-#include <compplugin.h>
-#include <compmatch.h>
+#include <core/output.h>
+#include <core/session.h>
+#include <core/metadata.h>
+#include <core/plugin.h>
+#include <core/match.h>
#include <core/privates.h>
class CompScreen;
diff --git a/include/core/session.h b/include/core/session.h
new file mode 100644
index 0000000..b4d5631
--- /dev/null
+++ b/include/core/session.h
@@ -0,0 +1,28 @@
+#ifndef _COMPSESSION_H
+#define _COMPSESSION_H
+
+#define SN_API_NOT_YET_FROZEN
+#include <libsn/sn.h>
+
+namespace CompSession {
+
+ enum Event {
+ EventSaveYourself = 0,
+ EventSaveComplete,
+ EventDie,
+ EventShutdownCancelled
+ };
+
+ enum ClientIdType {
+ ClientId = 0,
+ PrevClientId
+ };
+
+ void initSession (char *smPrevClientId);
+
+ void closeSession (void);
+
+ char *getSessionClientId (ClientIdType type);
+};
+
+#endif
diff --git a/include/core/window.h b/include/core/window.h
index d91642f..b771895 100644
--- a/include/core/window.h
+++ b/include/core/window.h
@@ -9,12 +9,12 @@
#include <X11/extensions/Xdamage.h>
#include <X11/extensions/sync.h>
-#include <compaction.h>
+#include <core/action.h>
#include <core/privates.h>
#include <core/size.h>
#include <core/point.h>
-#include <compwrapsystem.h>
+#include <core/wrapsystem.h>
#include <map>
diff --git a/include/core/wrapsystem.h b/include/core/wrapsystem.h
new file mode 100644
index 0000000..93319b5
--- /dev/null
+++ b/include/core/wrapsystem.h
@@ -0,0 +1,160 @@
+#ifndef _COMPWRAPSYSTEM_H_
+#define _COMPWRAPSYSTEM_H_
+
+#include <stdlib.h>
+#include <vector>
+
+#define WRAPABLE_DEF(func, ...) \
+{ \
+ mHandler-> func ## SetEnabled (this, false); \
+ return mHandler-> func (__VA_ARGS__); \
+}
+
+#define WRAPABLE_HND(num,itype,rtype, func, ...) \
+ rtype func (__VA_ARGS__); \
+ rtype func ## Core (__VA_ARGS__); \
+ void func ## SetEnabled (itype *obj, bool enabled) \
+ { \
+ functionSetEnabled (obj, num, enabled); \
+ } \
+ unsigned int func ## GetCurrentIndex () \
+ { \
+ return mCurrFunction[num]; \
+ } \
+ void func ## SetCurrentIndex (unsigned int index) \
+ { \
+ mCurrFunction[num] = index; \
+ }
+
+#define WRAPABLE_HND_FUNC(num, func, ...) \
+{ \
+ unsigned int curr = mCurrFunction[num]; \
+ while (mCurrFunction[num] < mInterface.size() && \
+ !mInterface[mCurrFunction[num]].enabled[num]) \
+ mCurrFunction[num]++; \
+ if (mCurrFunction[num] < mInterface.size()) \
+ { \
+ mInterface[mCurrFunction[num]++].obj-> func (__VA_ARGS__); \
+ mCurrFunction[num] = curr; \
+ return; \
+ } \
+ mCurrFunction[num] = curr; \
+}
+
+#define WRAPABLE_HND_FUNC_RETURN(num, rtype, func, ...) \
+{ \
+ unsigned int curr = mCurrFunction[num]; \
+ rtype rv; \
+ while (mCurrFunction[num] < mInterface.size() && \
+ !mInterface[mCurrFunction[num]].enabled[num]) \
+ mCurrFunction[num]++; \
+ if (mCurrFunction[num] < mInterface.size()) \
+ { \
+ rv = mInterface[mCurrFunction[num]++].obj-> func (__VA_ARGS__); \
+ mCurrFunction[num] = curr; \
+ return rv; \
+ } \
+ mCurrFunction[num] = curr; \
+}
+
+template <typename T, typename T2>
+class WrapableInterface {
+ protected:
+ WrapableInterface () : mHandler(0) {};
+ virtual ~WrapableInterface ()
+ {
+ if (mHandler)
+ mHandler->unregisterWrap (static_cast<T2*> (this));
+ };
+
+ void setHandler (T *handler)
+ {
+ if (mHandler)
+ mHandler->unregisterWrap (static_cast<T2*> (this));
+ if (handler)
+ handler->registerWrap (static_cast<T2*> (this));
+ mHandler = handler;
+ }
+ T *mHandler;
+};
+
+template <typename T, unsigned int N>
+class WrapableHandler : public T {
+
+ public:
+ void registerWrap (T *);
+ void unregisterWrap (T *);
+
+ unsigned int numWrapClients () { return mInterface.size (); };
+
+ protected:
+
+ class Interface {
+ public:
+ T *obj;
+ bool *enabled;
+ };
+
+ WrapableHandler () : mInterface ()
+ {
+ mCurrFunction = new unsigned int [N];
+ if (!mCurrFunction)
+ abort ();
+ for (unsigned int i = 0; i < N; i++)
+ mCurrFunction[i] = 0;
+ };
+
+ ~WrapableHandler ()
+ {
+ typename std::vector<Interface>::iterator it;
+ for (it = mInterface.begin(); it != mInterface.end(); it++)
+ delete (*it).enabled;
+ mInterface.clear ();
+ delete [] mCurrFunction;
+ };
+
+ void functionSetEnabled (T *, unsigned int, bool);
+
+ unsigned int *mCurrFunction;
+ std::vector<Interface> mInterface;
+};
+
+template <typename T, unsigned int N>
+void WrapableHandler<T,N>::registerWrap (T *obj)
+{
+ typename WrapableHandler<T,N>::Interface in;
+ in.obj = obj;
+ in.enabled = new bool [N];
+ if (!in.enabled)
+ return;
+ for (unsigned int i = 0; i < N; i++)
+ in.enabled[i] = true;
+ mInterface.insert (mInterface.begin(), in);
+};
+
+template <typename T, unsigned int N>
+void WrapableHandler<T,N>::unregisterWrap (T *obj)
+{
+ typename std::vector<Interface>::iterator it;
+ for (it = mInterface.begin(); it != mInterface.end(); it++)
+ if ((*it).obj == obj)
+ {
+ delete [] (*it).enabled;
+ mInterface.erase (it);
+ break;
+ }
+}
+
+template <typename T, unsigned int N>
+void WrapableHandler<T,N>::functionSetEnabled (T *obj, unsigned int num,
+ bool enabled)
+{
+ for (unsigned int i = 0; i < mInterface.size(); i++)
+ if (mInterface[i].obj == obj)
+ {
+ mInterface[i].enabled[num] = enabled;
+ break;
+ }
+}
+
+#endif