~ubuntu-branches/ubuntu/quantal/compiz/quantal

« back to all changes in this revision

Viewing changes to include/core/serialization.h

  • Committer: Package Import Robot
  • Author(s): Didier Roche, Sam Spilsbury, Timo Jyrinki, Didier Roche
  • Date: 2012-09-20 17:39:05 UTC
  • mfrom: (3275.1.32 ubuntu)
  • Revision ID: package-import@ubuntu.com-20120920173905-4k49mzvpywpjl6qa
Tags: 1:0.9.8.2+bzr3377-0ubuntu1
[ Sam Spilsbury ]
* debian/python-compizconfig.install
  - Install compizconfig-python.pc
* debian/patches/100_expo_layout.patch
  - re-add the expo layout that used to be in precise (LP: #1047067)
  - add some testcases

[ Timo Jyrinki ]
* New upstream snapshot.
  - Fix multiple window placement bugs (LP: #974242) (LP: #976032)
  - Don't waste CPU looping through and looking at all the windows if you're
    rendering an output that has no damage on it. (LP: #1014986)
  - Updated convert files to fix some typos in the key names. (LP: #1041631)
  - Fix crash when imgsvg is loaded, due to missing symbol
    (decor_apply_gravity from libdecoration). (LP: #956986)
  - Treat unresolved symbols at link time as an error, rather than letting
    them through and cause strange crashes later. (LP: #1043143)
  - Refactors a little bit of the upgrade code and gets it under test to
    prepare to fix (LP: #1042537)
  - Updated AUTHORS from the full bzr log, and re-sort the list.
    (LP: #1042095)
  - Fixes FTBFS for kde4-window-decorator (LP: #1041310)
  - Fix obvious omissions from the introduction of unminimize_*,
    which were causing the unminimize animation settings to be ignored
    (LP: #1040455)
  - resize plugin: don't crash if resize wasn't initiated externally
    (LP: #1045191)
  - Clean up capitalization (LP: #1045652)
  - Avoid division by zero, if plugins try to deform a window down to size
    zero. (LP: #1045235)
  - Make "Unredirect Fullscreen Windows" more reliable. This fixes the
    problem with unredirection failing to engage at all (LP: #1041066) when
    gtk-window-decorator creates offscreen windows that are stacked on top.
    This also fixes the problem with unredirect hiding all windows,
    because it thinks the desktop window should be stacked on top
    (LP: #980663).
  - Ensure unredirected windows don't stay unredirected if they're no longer
    on top. (LP: #1041047)
  - Fix launching terminal functionality and make show-hud default key 
    visible. Update the defaults to org.compiz.integrated to reflect the
    actual gnome values pre-gnome-3. (LP: #1040081) (LP: #1046199) 
    (LP: #1046190)
  - Fix show-hud, bump COMPIZ_GNOME_INTEGRATED_SETTINGS_LIST_SIZE.
    (LP: #1046212)
  - Fixed: Windows with an alpha-channel, like gnome-terminal, were not
    being considered as possibly covering fullscreen windows. But they most
    certainly can. This ensures such RGBA windows are visible if they're 
    stacked above a fullscreen window. (LP: #1046661)
  - Remove ListToStringList (LP: #1046184)
  - Fix typo causing CMake Error (LP: #1045665)
  - Transitions gtk-window-decorator over to use GSettings. Add a testing 
    framework for the options code. (LP: #1042323)
  - Also need kdeworkspace since kdecorationbridge.h is there
    (LP: #1046770)
  - Implements some cleanup that was suggested on the merge for the original
    port to gsettings. Other issues fixed as well. (LP: #1042323)
  - Fix the case where a new gsettings schema got added for building but
    it wasn't recompiled locally (LP: #1046701)
  - Scale: select the window under the pointer, when the scale animation 
    is over. (LP: #1045127)
  - Fixes the some "Use of uninitialised value" warnings reported by
    valgrind (LP: #1004336))
  - Check if org.gnome.mutter is available before using it (LP: #1048551)
  - We don't need to map our style windows, prevent them from cluttering 
    up the paint queue (LP: #1042552)
  - Migrate profile independent keys separately from the profile 
    dependent keys (LP: #1046190)
  - Don't ever enter the subdir of a plugin that is disabled. (LP: #1049100)
  - Workaround SubBuffer performance regression (LP: #1037411)
  - Changed the default placement of the benchmark window from 0,0 to
    100,50. (LP: #1039406)
  - Ensure window decorations always get rendered after the window, not
    before. This is how it was in compiz 0.9.7, and is required in order 
    to resolve unity panel shadow (LP: #1050704)
  - Fix CMakeLists.txt to bring an xslt file back to compiz-dev
  - Avoid a NULL dereference and give a useful error message instead
    (LP: #944653)
  - Fix (LP: #1050752)
  - Check that pixmaps which aren't managed by us actually exist before
    binding. (LP: #927168)
  - Fix flickering and performance problems with using Unredirect Fullscreen 
    Windows with multiple monitors. (LP: #1050749) (LP: #1051885)
* debian/compiz-dev.install
  - Remove compizconfig-python.pc, now in python-compizconfig.install
* Drop dependency on libgconf2-dev, add gconf2 dependency to the 
  transitional package for migrations
* Add -DUSE_GCONF=OFF to debian/rules
* debian/libdecoration0.symbols
  - Add decor_shadow_options_cmp
* Cherry-pick fixes from trunk:
  - Fix FTBFS with BUILD_GLES
* Restore 'Glide 2' unminimize animation via override

[ Didier Roche ]
* debian/libdecoration0.symbols:
  - update the symbols file
* add and cherry-pick missing ABI breakage bump

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/*
2
 
 * Copyright © 2010 Sam Spilsbury
3
 
 *
4
 
 * Permission to use, copy, modify, distribute, and sell this software
5
 
 * and its documentation for any purpose is hereby granted without
6
 
 * fee, provided that the above copyright notice appear in all copies
7
 
 * and that both that copyright notice and this permission notice
8
 
 * appear in supporting documentation, and that the name of
9
 
 * Dennis Kasprzyk not be used in advertising or publicity pertaining to
10
 
 * distribution of the software without specific, written prior permission.
11
 
 * Dennis Kasprzyk makes no representations about the suitability of this
12
 
 * software for any purpose. It is provided "as is" without express or
13
 
 * implied warranty.
14
 
 *
15
 
 * DENNIS KASPRZYK DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
16
 
 * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN
17
 
 * NO EVENT SHALL DENNIS KASPRZYK BE LIABLE FOR ANY SPECIAL, INDIRECT OR
18
 
 * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
19
 
 * OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
20
 
 * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
21
 
 * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
22
 
 *
23
 
 * Authors: Sam Spilsbury <smspillaz@gmail.com>
24
 
 */
25
 
 
26
 
#ifndef _COMPSERIALIZATION_H
27
 
#define _COMPSERIALIZATION_H
28
 
 
29
 
#include <core/core.h>
30
 
#include <core/timer.h>
31
 
#include <core/propertywriter.h>
32
 
 
33
 
#include <typeinfo>
34
 
#include <boost/preprocessor/cat.hpp>
35
 
 
36
 
#include <boost/archive/text_iarchive.hpp>
37
 
#include <boost/archive/text_oarchive.hpp>
38
 
 
39
 
#include <boost/serialization/export.hpp>
40
 
 
41
 
#include <boost/serialization/list.hpp>
42
 
#include <boost/serialization/vector.hpp>
43
 
 
44
 
#include <sstream>
45
 
#include <fstream>
46
 
 
47
 
 
48
 
template <class T>
49
 
class PluginStateWriter
50
 
{
51
 
    private:
52
 
        PropertyWriter mPw;
53
 
        Window         mResource;
54
 
        T              *mClassPtr;
55
 
        CompTimer      mTimeout;
56
 
 
57
 
        friend class boost::serialization::access;
58
 
 
59
 
        bool
60
 
        checkTimeout ()
61
 
        {
62
 
            if (!screen->shouldSerializePlugins ())
63
 
                return false;
64
 
 
65
 
            CompOption::Vector atomTemplate = mPw.readProperty (mResource);
66
 
 
67
 
            if (atomTemplate.empty ())
68
 
                return false;
69
 
 
70
 
            if (!(atomTemplate.at (0).value ().type () == CompOption::TypeString))
71
 
                return false;
72
 
            
73
 
            std::istringstream iss (atomTemplate.at (0).value ().s ());
74
 
            boost::archive::text_iarchive ia (iss);
75
 
            
76
 
            ia >> *this;
77
 
 
78
 
            postLoad ();
79
 
            
80
 
            /* No need to store this data in XServer anymore, get rid of it */
81
 
            
82
 
            mPw.deleteProperty (mResource);
83
 
            
84
 
            return false;
85
 
        };          
86
 
            
87
 
    public:
88
 
 
89
 
        template <class Archive>
90
 
        void serialize (Archive &ar, const unsigned int version)
91
 
        {
92
 
             ar & *mClassPtr;;
93
 
        };    
94
 
 
95
 
        virtual void postLoad () {};
96
 
        
97
 
        /* Classes get destroyed in the order of:
98
 
         * derived -> this. Because variables might
99
 
         * have thier destructors called, we provide
100
 
         * a method to intercept this process
101
 
         * and immediately serialize data such that it
102
 
         * won't be unintentionally destroyed before the
103
 
         * base CompPluginStateWriter destructor gets called
104
 
         */
105
 
        
106
 
        void writeSerializedData ()
107
 
        {
108
 
            if (!screen->shouldSerializePlugins ())
109
 
                return;
110
 
 
111
 
            CompOption::Vector atomTemplate = mPw.getReadTemplate ();     
112
 
            std::string str;  
113
 
            std::ostringstream oss (str);
114
 
            boost::archive::text_oarchive oa (oss);
115
 
 
116
 
            /* Nothing was initially read from the property, which probably means that
117
 
             * shouldSerializePlugins was turned on in between plugin load and unload
118
 
             * so don't attempt to do anything here */
119
 
            if (!atomTemplate.size ())
120
 
                return;
121
 
 
122
 
            oa << *this;
123
 
            
124
 
            CompOption::Value v (oss.str ().c_str ());
125
 
            atomTemplate.at (0).set (v);
126
 
 
127
 
            mPw.updateProperty (mResource, atomTemplate, XA_STRING);
128
 
        }       
129
 
        
130
 
        PluginStateWriter (T *instance,
131
 
                           Window xid) :
132
 
            mResource (xid),
133
 
            mClassPtr (instance)
134
 
        {
135
 
            if (screen->shouldSerializePlugins ())
136
 
 
137
 
            {
138
 
                CompString atomName = compPrintf ("_COMPIZ_%s_STATE",
139
 
                                                  typeid (T).name ());
140
 
                CompOption::Vector o;
141
 
 
142
 
                o.resize (1);
143
 
                o.at (0).setName ("data", CompOption::TypeString);
144
 
 
145
 
                mPw = PropertyWriter (atomName, o);
146
 
 
147
 
                mTimeout.setCallback (boost::bind (&PluginStateWriter::checkTimeout,
148
 
                                                 this));
149
 
                mTimeout.setTimes (0, 0);
150
 
                mTimeout.start ();
151
 
            }
152
 
        }
153
 
        
154
 
        virtual ~PluginStateWriter () {};
155
 
 
156
 
};
157
 
 
158
 
#endif