summaryrefslogtreecommitdiff
path: root/plugins
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
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')
-rw-r--r--plugins/annotate/src/annotate.cpp42
-rw-r--r--plugins/annotate/src/annotate.h17
-rw-r--r--plugins/compiztoolbox/include/compiztoolbox/compiztoolbox.h25
-rw-r--r--plugins/compiztoolbox/src/compiztoolbox.cpp155
-rw-r--r--plugins/obs/src/obs.cpp19
-rw-r--r--plugins/obs/src/obs.h14
-rw-r--r--plugins/resize/src/resize.cpp5
-rw-r--r--plugins/screenshot/src/screenshot.h4
-rw-r--r--plugins/switcher/src/switcher.h1
9 files changed, 99 insertions, 183 deletions
diff --git a/plugins/annotate/src/annotate.cpp b/plugins/annotate/src/annotate.cpp
index bdbc4dd..0c67723 100644
--- a/plugins/annotate/src/annotate.cpp
+++ b/plugins/annotate/src/annotate.cpp
@@ -79,8 +79,29 @@ AnnoScreen::cairoContext ()
format, w, h);
cairo = cairo_create (surface);
-
- cairoClear (cairo);
+
+ if (cairoBuffer.size ())
+ {
+ cairo_t *cr = cairo_create (surface);
+ int stride = cairo_format_stride_for_width (CAIRO_FORMAT_ARGB32, w);
+ cairo_surface_t *raw_source =
+ cairo_image_surface_create_for_data ((unsigned char *)
+ cairoBuffer.c_str (),
+ CAIRO_FORMAT_ARGB32,
+ w, h, stride);
+
+ if (cr && raw_source)
+ {
+ cairo_set_source_surface (cr, raw_source, 0, 0);
+ cairo_paint (cr);
+
+ cairo_surface_destroy (raw_source);
+ cairo_destroy (cr);
+ cairoBuffer.clear ();
+ }
+ }
+ else
+ cairoClear (cairo);
}
return cairo;
@@ -880,10 +901,23 @@ AnnoScreen::handleEvent (XEvent *event)
screen->handleEvent (event);
}
+void
+AnnoScreen::postLoad ()
+{
+ if (content)
+ {
+ cairoContext ();
+
+ gScreen->glPaintOutputSetEnabled (this, true);
+ }
+}
+
AnnoScreen::AnnoScreen (CompScreen *screen) :
PluginClassHandler <AnnoScreen, CompScreen> (screen),
+ PluginStateWriter <AnnoScreen> (this, "ANNOTATE", screen->root ()),
cScreen (CompositeScreen::get (screen)),
gScreen (GLScreen::get (screen)),
+ grabIndex (0),
pixmap (None),
surface (NULL),
damage (None),
@@ -921,7 +955,9 @@ AnnoScreen::AnnoScreen (CompScreen *screen) :
}
AnnoScreen::~AnnoScreen ()
-{
+{
+ writeSerializedData ();
+
if (cairo)
cairo_destroy (cairo);
if (surface)
diff --git a/plugins/annotate/src/annotate.h b/plugins/annotate/src/annotate.h
index 1f6af17..4ae2b6a 100644
--- a/plugins/annotate/src/annotate.h
+++ b/plugins/annotate/src/annotate.h
@@ -27,6 +27,7 @@
#include <cairo-xlib-xrender.h>
#include <core/core.h>
+#include <core/serialization.h>
#include <opengl/opengl.h>
#include <composite/composite.h>
@@ -57,6 +58,7 @@ enum DrawMode
class AnnoScreen :
public PluginClassHandler <AnnoScreen, CompScreen>,
+ public PluginStateWriter <AnnoScreen>,
public ScreenInterface,
public GLScreenInterface,
public AnnotateOptions
@@ -74,6 +76,7 @@ class AnnoScreen :
GLTexture::List texture;
cairo_surface_t *surface;
cairo_t *cairo;
+ CompString cairoBuffer; // used for serialization
bool content;
Damage damage;
@@ -82,6 +85,20 @@ class AnnoScreen :
CompPoint lineVector;
Ellipse ellipse;
+
+ template <class Archive>
+ void serialize (Archive & ar, const unsigned int count)
+ {
+ /* FIXME:
+ * cairo_surface_get_image_data is broken or something
+ * so serializing cairo bits is next to impossible at the moment
+ *
+ * ar & cairoBuffer;
+ * ar & content;
+ */
+ }
+
+ void postLoad ();
void handleEvent (XEvent *);
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;
diff --git a/plugins/obs/src/obs.cpp b/plugins/obs/src/obs.cpp
index 94269e8..ee32eaf 100644
--- a/plugins/obs/src/obs.cpp
+++ b/plugins/obs/src/obs.cpp
@@ -145,10 +145,10 @@ ObsWindow::glPaint (const GLWindowPaintAttrib& attrib,
return gWindow->glPaint (attrib, transform, region, mask);
}
-/* Note: Normally plugins should wrap into PaintWindow to modify opacity,
- brightness and saturation. As some plugins bypass paintWindow when
+/* Note: Normally plugins should wrap into glPaintWindow to modify opacity,
+ brightness and saturation. As some plugins bypass glPaintWindow when
they draw windows and our custom values always need to be applied,
- we wrap into DrawWindow here */
+ we wrap into glDrawWindow here */
bool
ObsWindow::glDraw (const GLMatrix& transform,
@@ -278,8 +278,19 @@ ObsScreen::setOption (const CompString &name,
return true;
}
+void
+ObsWindow::postLoad ()
+{
+ for (unsigned int i = 0; i < MODIFIER_COUNT; i++)
+ {
+ if (customFactor[i] != 100)
+ modifierChanged (i);
+ }
+}
+
ObsWindow::ObsWindow (CompWindow *w) :
PluginClassHandler<ObsWindow, CompWindow> (w),
+ PluginStateWriter <ObsWindow> (this, "OBS", w->id ()),
window (w),
cWindow (CompositeWindow::get (w)),
gWindow (GLWindow::get (w)),
@@ -302,6 +313,8 @@ ObsWindow::ObsWindow (CompWindow *w) :
ObsWindow::~ObsWindow ()
{
+ writeSerializedData ();
+
updateHandle.stop ();
}
diff --git a/plugins/obs/src/obs.h b/plugins/obs/src/obs.h
index 94ff728..d288ddf 100644
--- a/plugins/obs/src/obs.h
+++ b/plugins/obs/src/obs.h
@@ -25,6 +25,7 @@
#include <core/core.h>
#include <core/pluginclasshandler.h>
+#include <core/serialization.h>
#include <composite/composite.h>
#include <opengl/opengl.h>
@@ -38,7 +39,7 @@
class ObsScreen :
public ScreenInterface,
- public PluginClassHandler<ObsScreen, CompScreen>,
+ public PluginClassHandler <ObsScreen, CompScreen>,
public ObsOptions
{
public:
@@ -56,7 +57,8 @@ class ObsScreen :
class ObsWindow :
public GLWindowInterface,
- public PluginClassHandler<ObsWindow, CompWindow>
+ public PluginClassHandler<ObsWindow, CompWindow>,
+ public PluginStateWriter <ObsWindow>
{
public:
ObsWindow (CompWindow *);
@@ -71,6 +73,14 @@ class ObsWindow :
void updatePaintModifier (unsigned int);
void modifierChanged (unsigned int);
bool updateTimeout ();
+
+ template <class Archive>
+ void serialize (Archive &ar, const unsigned int version)
+ {
+ ar & customFactor;
+ }
+
+ void postLoad ();
private:
CompWindow *window;
diff --git a/plugins/resize/src/resize.cpp b/plugins/resize/src/resize.cpp
index 579f39c..69955cf 100644
--- a/plugins/resize/src/resize.cpp
+++ b/plugins/resize/src/resize.cpp
@@ -170,16 +170,15 @@ ResizeScreen::updateWindowProperty ()
v = geometry.height;
data.at (3).set (v);
- resizeInformationAtom.updateProperty (w->id (), data, false, XA_CARDINAL);
+ resizeInformationAtom.updateProperty (w->id (), data, XA_CARDINAL);
}
void
ResizeScreen::finishResizing ()
{
w->ungrabNotify ();
- CompOption::Vector opts = resizeInformationAtom.getReadTemplate ();
- resizeInformationAtom.updateProperty (w->id (), opts, true, XA_CARDINAL);
+ resizeInformationAtom.deleteProperty (w->id ());
w = NULL;
}
diff --git a/plugins/screenshot/src/screenshot.h b/plugins/screenshot/src/screenshot.h
index 03a9e94..f2c4531 100644
--- a/plugins/screenshot/src/screenshot.h
+++ b/plugins/screenshot/src/screenshot.h
@@ -29,8 +29,10 @@
#include "screenshot_options.h"
-#include <compiztoolbox/compiztoolbox.h>
+#include <core/core.h>
+#include <core/propertywriter.h>
+#include <compiztoolbox/compiztoolbox.h>
#include <composite/composite.h>
#include <opengl/opengl.h>
diff --git a/plugins/switcher/src/switcher.h b/plugins/switcher/src/switcher.h
index e0118d6..91eaad0 100644
--- a/plugins/switcher/src/switcher.h
+++ b/plugins/switcher/src/switcher.h
@@ -33,6 +33,7 @@
#include <compiztoolbox/compiztoolbox.h>
#include <core/pluginclasshandler.h>
+#include <core/propertywriter.h>
#include "switcher_options.h"