summaryrefslogtreecommitdiff
path: root/plugins/compiztoolbox
diff options
context:
space:
mode:
authorSam Spilsbury <SmSpillaz@gmail.com>2010-06-12 15:43:36 +0800
committerSam Spilsbury <SmSpillaz@gmail.com>2010-06-12 15:43:36 +0800
commitad81a6e7b48ce68e893b4c0b13080b198f37634c (patch)
tree24f4887e8d7169563af96224d9b6990cfe651913 /plugins/compiztoolbox
parenta9e34d283827f5bd956ae45339ac95a96e9f64ae (diff)
downloadcompiz-with-glib-mainloop-ad81a6e7b48ce68e893b4c0b13080b198f37634c.tar.gz
compiz-with-glib-mainloop-ad81a6e7b48ce68e893b4c0b13080b198f37634c.tar.bz2
A few big changes:
* Rewrite PropertyWriter, move it out of compiztoolbox * Added CompPluginStateWriter, a serialization interface, which plugins inherit, and specify how to serialize their class members, which will be automatically unloaded and reloaded as plugins unload and reload. * Currently there are bugs with this interface, so it is disabled by default (mostly bugs to do with boost and libdl) * Depend on libboost-serialization * A few bugfixes
Diffstat (limited to 'plugins/compiztoolbox')
-rw-r--r--plugins/compiztoolbox/include/compiztoolbox/compiztoolbox.h25
-rw-r--r--plugins/compiztoolbox/src/compiztoolbox.cpp155
2 files changed, 9 insertions, 171 deletions
diff --git a/plugins/compiztoolbox/include/compiztoolbox/compiztoolbox.h b/plugins/compiztoolbox/include/compiztoolbox/compiztoolbox.h
index 46a0b6d..976bd47 100644
--- a/plugins/compiztoolbox/include/compiztoolbox/compiztoolbox.h
+++ b/plugins/compiztoolbox/include/compiztoolbox/compiztoolbox.h
@@ -30,6 +30,7 @@
#include <core/core.h>
#include <core/atoms.h>
#include <core/countedlist.h>
+#include <core/propertywriter.h>
#include <composite/composite.h>
#include <opengl/opengl.h>
@@ -37,9 +38,10 @@
#include <X11/Xatom.h>
#include <X11/extensions/Xrender.h>
+#include <sstream>
#include <fstream>
-#define COMPIZ_COMPIZTOOLBOX_ABI 1
+#define COMPIZ_COMPIZTOOLBOX_ABI 2
typedef enum
{
@@ -62,26 +64,7 @@ typedef enum
AllViewports,
Panels,
Group
-} SwitchWindowSelection;
-
-class PropertyWriter
-{
- public:
-
- PropertyWriter ();
- PropertyWriter (CompString propName,
- CompOption::Vector &readTemplate);
-
- bool updateProperty (Window, CompOption::Vector &, bool, int);
- CompOption::Vector readProperty (Window);
- void setReadTemplate (const CompOption::Vector &);
- CompOption::Vector getReadTemplate ();
-
- private:
-
- CompOption::Vector mPropertyValues;
- Atom mAtom;
-};
+} SwitchWindowSelection;
class BaseSwitchScreen
{
diff --git a/plugins/compiztoolbox/src/compiztoolbox.cpp b/plugins/compiztoolbox/src/compiztoolbox.cpp
index 50dc733..68fbd2a 100644
--- a/plugins/compiztoolbox/src/compiztoolbox.cpp
+++ b/plugins/compiztoolbox/src/compiztoolbox.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright © 2005 Novell, Inc.
+ * Copyright © 2005 Novell, Inc.
*
* Permission to use, copy, modify, distribute, and sell this software
* and its documentation for any purpose is hereby granted without
@@ -24,10 +24,11 @@
*/
#include <core/core.h>
-
+#include <core/propertywriter.h>
#include <compiztoolbox/compiztoolbox.h>
#include "compiztoolbox_options.h"
+
bool openGLAvailable;
class CompizToolboxScreen :
@@ -45,152 +46,6 @@ class CompizToolboxPluginVTable :
void fini ();
};
-PropertyWriter::PropertyWriter ()
-{
-}
-
-PropertyWriter::PropertyWriter (CompString propName,
- CompOption::Vector &readTemplate)
-{
- mPropertyValues = readTemplate;
- mAtom = XInternAtom (screen->dpy (), propName.c_str (), 0);
-}
-
-void
-PropertyWriter::setReadTemplate (const CompOption::Vector &readTemplate)
-{
- mPropertyValues = readTemplate;
-}
-
-CompOption::Vector
-PropertyWriter::getReadTemplate ()
-{
- return mPropertyValues;
-}
-
-bool
-PropertyWriter::updateProperty (Window id,
- CompOption::Vector &propertyData,
- bool remove,
- int type)
-{
- int count = 0;
- long int data[propertyData.size ()];
-
- if (remove)
- {
- XDeleteProperty (screen->dpy (), id, mAtom);
- return true;
- }
- else
- {
- mPropertyValues = propertyData;
-
- foreach (CompOption &o, propertyData)
- {
- switch (o.type ())
- {
- case CompOption::TypeBool:
- data[count] = o.value ().b ();
- break;
- case CompOption::TypeInt:
- data[count] = o.value ().i ();
- break;
- case CompOption::TypeFloat:
- data[count] = o.value ().f ();
- break;
- default:
- data[count] = 0;
- break;
- }
-
- count++;
- }
-
- XChangeProperty (screen->dpy (), id,
- mAtom, type, 32,
- PropModeReplace, (unsigned char *)data, 5);
- }
-
- return true;
-}
-
-CompOption::Vector
-PropertyWriter::readProperty (Window id)
-{
- Atom type;
- int retval, fmt;
- unsigned long nitems, exbyte;
- long int *data;
- int count = 0;
- CompOption::Vector propertyValues;
-
- propertyValues.clear ();
-
- if (mPropertyValues.empty ())
- return propertyValues;
-
- retval = XGetWindowProperty (screen->dpy (), id, mAtom, 0,
- mPropertyValues.size (), False, XA_CARDINAL,
- &type, &fmt, &nitems, &exbyte,
- (unsigned char **)&data);
-
- if (retval == Success && !mPropertyValues.empty ())
- {
- if (type == XA_CARDINAL && fmt == 32 &&
- nitems == mPropertyValues.size ())
- {
- propertyValues.resize (nitems);
-
- foreach (CompOption &o, propertyValues)
- {
- CompString tmpName;
- CompOption::Value tmpVal;
- char buf[64];
- snprintf (buf, 64, "%i", count);
- tmpName = CompString(buf);
- switch (mPropertyValues.at (count).type ())
- {
- case CompOption::TypeBool:
- tmpVal = CompOption::Value ((bool) data[count]);
- o.setName (tmpName, CompOption::TypeBool);
- o.set (tmpVal);
- break;
- case CompOption::TypeInt:
- tmpVal = CompOption::Value ((int) data[count]);
- o.setName (tmpName, CompOption::TypeInt);
- o.set (tmpVal);
- break;
- case CompOption::TypeFloat:
- tmpVal = CompOption::Value ((float) data[count]);
- o.setName (tmpName, CompOption::TypeFloat);
- o.set (tmpVal);
- break;
- default:
- tmpVal = CompOption::Value (CompOption::Value (0));
- o.setName (tmpName, CompOption::TypeInt);
- o.set (tmpVal);
- break;
- }
-
- count++;
- }
-
- XFree (data);
- }
- else if (fmt != 0)
- {
- XFree (data);
- }
- }
- else
- {
- return propertyValues;
- }
-
- return propertyValues;
-}
-
COMPIZ_PLUGIN_20090315 (compiztoolbox, CompizToolboxPluginVTable);
CompString
@@ -280,7 +135,7 @@ BaseSwitchScreen::setSelectedWindowHint ()
opts = selectWinAtom.getReadTemplate ();
opts.at (0).set (v);
- selectWinAtom.updateProperty (popupWindow, opts, false, XA_WINDOW);
+ selectWinAtom.updateProperty (popupWindow, opts, XA_WINDOW);
}
void
@@ -869,7 +724,7 @@ CompizToolboxPluginVTable::init ()
openGLAvailable = false;
CompPrivate p;
- p.uval = COMPIZ_COMPOSITE_ABI;
+ p.uval = COMPIZ_COMPIZTOOLBOX_ABI;
screen->storeValue ("compiztoolbox_ABI", p);
return true;