~ubuntu-branches/ubuntu/utopic/easystroke/utopic-proposed

« back to all changes in this revision

Viewing changes to gesture.h

  • Committer: Package Import Robot
  • Author(s): Logan Rosen, Logan Rosen, Andrew Starr-Bochicchio
  • Date: 2013-01-08 01:44:02 UTC
  • mfrom: (1.1.11)
  • Revision ID: package-import@ubuntu.com-20130108014402-x27g6mfbl4x4tiff
Tags: 0.5.6-0ubuntu1
[ Logan Rosen ]
* New upstream release. Should fix the following bugs, according to
  Tom Jaeger on Launchpad:
  - Exceptions don't work (LP: #995841).
  - The focus randomly changes between windows if easystroke is in use and
    the evdev driver is built with mtdev (LP: #1048865).
* debian/source/format: Indicate format of 3.0 (quilt).
* debian/control: Bump Standards-Version to 3.9.4.

[ Andrew Starr-Bochicchio ]
* debian/copyright: Update to DEP-5 style.

Show diffs side-by-side

added added

removed removed

Lines of Context:
24
24
#include <boost/serialization/version.hpp>
25
25
#include <boost/serialization/split_member.hpp>
26
26
 
27
 
#include <X11/X.h> // Time
 
27
#include <X11/X.h>
28
28
 
29
29
#define STROKE_SIZE 64
30
30
 
34
34
typedef boost::shared_ptr<Stroke> RStroke;
35
35
typedef boost::shared_ptr<PreStroke> RPreStroke;
36
36
 
37
 
int get_default_button();
38
 
 
39
37
struct Triple {
40
38
        float x;
41
39
        float y;
76
74
        };
77
75
 
78
76
private:
79
 
        Stroke(PreStroke &s, int trigger_, int button_, bool timeout_);
 
77
        Stroke(PreStroke &s, int trigger_, int button_, unsigned int modifiers_, bool timeout_);
80
78
 
81
79
        Glib::RefPtr<Gdk::Pixbuf> draw_(int size, double width = 2.0, bool inv = false) const;
82
80
        mutable Glib::RefPtr<Gdk::Pixbuf> pb[2];
85
83
        static Glib::RefPtr<Gdk::Pixbuf> pbEmpty;
86
84
 
87
85
        BOOST_SERIALIZATION_SPLIT_MEMBER()
88
 
        template<class Archive> void save(Archive & ar, const unsigned int version) const {
89
 
                std::vector<Point> ps;
90
 
                for (unsigned int i = 0; i < size(); i++)
91
 
                        ps.push_back(points(i));
92
 
                ar & ps;
93
 
                ar & button;
94
 
                ar & trigger;
95
 
                ar & timeout;
96
 
        }
97
 
        template<class Archive> void load(Archive & ar, const unsigned int version) {
98
 
                std::vector<Point> ps;
99
 
                ar & ps;
100
 
                if (ps.size()) {
101
 
                        stroke_t *s = stroke_alloc(ps.size());
102
 
                        for (std::vector<Point>::iterator i = ps.begin(); i != ps.end(); ++i)
103
 
                                stroke_add_point(s, i->x, i->y);
104
 
                        stroke_finish(s);
105
 
                        stroke.reset(s, &stroke_free);
106
 
                }
107
 
                if (version == 0) return;
108
 
                ar & button;
109
 
                if (version >= 2)
110
 
                        ar & trigger;
111
 
                if (version < 4 && (!button || trigger == get_default_button()))
112
 
                        trigger = 0;
113
 
                if (version < 3)
114
 
                        return;
115
 
                ar & timeout;
116
 
        }
117
 
 
 
86
        template<class Archive> void load(Archive & ar, const unsigned int version);
 
87
        template<class Archive> void save(Archive & ar, const unsigned int version) const;
118
88
public:
119
89
        int trigger;
120
90
        int button;
 
91
        unsigned int modifiers;
121
92
        bool timeout;
122
93
        boost::shared_ptr<stroke_t> stroke;
123
94
 
124
 
        Stroke() : trigger(0), button(0), timeout(false) {}
125
 
        static RStroke create(PreStroke &s, int trigger_, int button_, bool timeout_) {
126
 
                return RStroke(new Stroke(s, trigger_, button_, timeout_));
 
95
        Stroke() : trigger(0), button(0), modifiers(AnyModifier), timeout(false) {}
 
96
        static RStroke create(PreStroke &s, int trigger_, int button_, unsigned int modifiers_, bool timeout_) {
 
97
                return RStroke(new Stroke(s, trigger_, button_, modifiers_, timeout_));
127
98
        }
128
99
        Glib::RefPtr<Gdk::Pixbuf> draw(int size, double width = 2.0, bool inv = false) const;
129
100
        void draw(Cairo::RefPtr<Cairo::Surface> surface, int x, int y, int w, int h, double width = 2.0, bool inv = false) const;
141
112
        double time(int n) const { return stroke_get_time(stroke.get(), n); }
142
113
        bool is_timeout() const { return timeout; }
143
114
};
144
 
BOOST_CLASS_VERSION(Stroke, 4)
 
115
BOOST_CLASS_VERSION(Stroke, 5)
145
116
BOOST_CLASS_VERSION(Stroke::Point, 1)
146
117
 
147
118
class PreStroke : public std::vector<RTriple> {