summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSam Spilsbury <SmSpillaz@gmail.com>2010-06-12 15:53:28 +0800
committerSam Spilsbury <SmSpillaz@gmail.com>2010-06-12 15:53:28 +0800
commit6608f72e84ec97d9e120216fa8e452d53cbc663a (patch)
treeae7994789a662b717c7eadc483efab70adbfb71f
parent6c5ba5804c442314210de515afc445b8fd67661c (diff)
downloadneg-6608f72e84ec97d9e120216fa8e452d53cbc663a.tar.gz
neg-6608f72e84ec97d9e120216fa8e452d53cbc663a.tar.bz2
Added serialization interface and necessary changes
-rw-r--r--src/neg.cpp74
-rw-r--r--src/neg.h16
2 files changed, 29 insertions, 61 deletions
diff --git a/src/neg.cpp b/src/neg.cpp
index 3775978..0db4282 100644
--- a/src/neg.cpp
+++ b/src/neg.cpp
@@ -29,12 +29,8 @@ COMPIZ_PLUGIN_20090315 (neg, NegPluginVTable);
void
NegWindow::toggle ()
{
- CompOption::Vector opts;
- CompOption::Value toggled;
NEG_SCREEN (screen);
- opts = ns->toggleState.getReadTemplate ();
-
/* toggle window negative flag */
isNeg = !isNeg;
@@ -49,11 +45,6 @@ NegWindow::toggle ()
gWindow->glDrawTextureSetEnabled (this, true);
else
gWindow->glDrawTextureSetEnabled (this, false);
-
- toggled = CompOption::Value (isNeg);
- opts.at (0).set (toggled);
-
- ns->toggleState.updateProperty (window->id (), opts, false, XA_CARDINAL);
}
void
@@ -521,47 +512,6 @@ NegScreen::optionChanged (CompOption *opt,
}
}
-bool
-NegScreen::checkStateTimeout ()
-{
- CompOption::Vector atomTemplate;
- CompOption::Vector currentToggleState;
- CompOption::Value v;
-
- atomTemplate.resize (1);
- atomTemplate.at (0).setName ("toggled", CompOption::TypeBool);
-
- toggleState = PropertyWriter ("_COMPIZ_NEG_TOGGLE_STATE", atomTemplate);
-
- /* Attempt to read the property on the root window
- * from where we may have previously set data
- */
-
- foreach (CompWindow *w, screen->windows ())
- {
- NEG_WINDOW (w);
-
- /* check exclude list */
- if (optionGetExcludeMatch ().evaluate (w))
- continue;
-
- currentToggleState = toggleState.readProperty (w->id ());
-
- if (!currentToggleState.empty ())
- {
- nw->isNeg = currentToggleState.at (0).value ().b ();
-
- if (nw->isNeg)
- {
- nw->cWindow->addDamage ();
- nw->gWindow->glDrawTextureSetEnabled (nw, true);
- }
- }
- }
-
- return false;
-}
-
NegScreen::NegScreen (CompScreen *screen) :
PluginClassHandler <NegScreen, CompScreen> (screen),
NegOptions (),
@@ -570,13 +520,6 @@ NegScreen::NegScreen (CompScreen *screen) :
isNeg (false),
gScreen (GLScreen::get (screen))
{
-
- checkStateTimer.setTimes (0, 0);
- checkStateTimer.setCallback (boost::bind (&NegScreen::checkStateTimeout,
- this));
- checkStateTimer.start ();
-
-
optionSetWindowToggleKeyInitiate (boost::bind (&NegScreen::toggle, this,
_1, _2, _3,
false));
@@ -591,8 +534,20 @@ NegScreen::NegScreen (CompScreen *screen) :
}
+void
+NegWindow::postLoad ()
+{
+ if (isNeg)
+ {
+ cWindow->addDamage ();
+ gWindow->glDrawTextureSetEnabled (this, true);
+ }
+}
+
+
NegWindow::NegWindow (CompWindow *window) :
PluginClassHandler <NegWindow, CompWindow> (window),
+ PluginStateWriter <NegWindow> (this, "NEG", window->id ()),
window (window),
cWindow (CompositeWindow::get (window)),
gWindow (GLWindow::get (window)),
@@ -609,6 +564,11 @@ NegWindow::NegWindow (CompWindow *window) :
toggle ();
}
+NegWindow::~NegWindow ()
+{
+ writeSerializedData ();
+}
+
bool
NegPluginVTable::init ()
{
diff --git a/src/neg.h b/src/neg.h
index 5d52ad8..b25f2fc 100644
--- a/src/neg.h
+++ b/src/neg.h
@@ -23,10 +23,11 @@
#include <core/core.h>
#include <core/pluginclasshandler.h>
+#include <core/serialization.h>
#include <composite/composite.h>
#include <opengl/opengl.h>
-#include <compiztoolbox/compiztoolbox.h>
+
#include "neg_options.h"
@@ -43,9 +44,6 @@ class NegScreen :
bool isNeg;
- PropertyWriter toggleState;
- CompTimer checkStateTimer;
-
bool
checkStateTimeout ();
@@ -71,11 +69,21 @@ class NegScreen :
class NegWindow :
public PluginClassHandler <NegWindow, CompWindow>,
+ public PluginStateWriter <NegWindow>,
public GLWindowInterface
{
public:
+
+ template <class Archive>
+ void serialize (Archive &ar, const unsigned int version)
+ {
+ ar & isNeg;
+ }
+
+ void postLoad ();
NegWindow (CompWindow *);
+ ~NegWindow ();
CompWindow *window;
CompositeWindow *cWindow;