~smspillaz/compiz-core/compiz-core.fix_929288

« back to all changes in this revision

Viewing changes to plugins/decor/src/pixmap-requests/include/pixmap-requests.h

  • Committer: smspillaz
  • Date: 2012-05-15 18:51:58 UTC
  • mfrom: (3110.1.27 trunk)
  • Revision ID: sam.spilsbury@canonical.com-20120515185158-5wqwe5hvqsohazow
Merged lp:compiz-core

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * Copyright © 2005 Novell, Inc.
 
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
 * Novell, Inc. not be used in advertising or publicity pertaining to
 
10
 * distribution of the software without specific, written prior permission.
 
11
 * Novell, Inc. 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
 * NOVELL, INC. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
 
16
 * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN
 
17
 * NO EVENT SHALL NOVELL, INC. 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
 * Author: David Reveman <davidr@novell.com>
 
24
 */
 
25
 
 
26
#ifndef _COMPIZ_DECOR_PIXMAP_REQUESTS_H
 
27
#define _COMPIZ_DECOR_PIXMAP_REQUESTS_H
 
28
 
 
29
#include <boost/shared_ptr.hpp>
 
30
#include <boost/shared_array.hpp>
 
31
#include <boost/make_shared.hpp>
 
32
#include <decoration.h>
 
33
 
 
34
#include <X11/Xlib.h>
 
35
 
 
36
class DecorPixmapInterface
 
37
{
 
38
    public:
 
39
 
 
40
        typedef boost::shared_ptr <DecorPixmapInterface> Ptr;
 
41
 
 
42
        virtual ~DecorPixmapInterface () {};
 
43
 
 
44
        virtual Pixmap getPixmap () = 0;
 
45
};
 
46
 
 
47
class DecorPixmapReceiverInterface
 
48
{
 
49
    public:
 
50
 
 
51
        virtual ~DecorPixmapReceiverInterface () {}
 
52
 
 
53
        virtual void pending () = 0;
 
54
        virtual void update () = 0;
 
55
};
 
56
 
 
57
/* So far, nothing particularly interesting here
 
58
 * we just need a way to pass around pointers for
 
59
 * testing */
 
60
class DecorationInterface
 
61
{
 
62
    public:
 
63
 
 
64
        typedef boost::shared_ptr <DecorationInterface> Ptr;
 
65
 
 
66
        virtual ~DecorationInterface () {}
 
67
 
 
68
        virtual DecorPixmapReceiverInterface & receiverInterface () = 0;
 
69
        virtual unsigned int getFrameType () const = 0;
 
70
        virtual unsigned int getFrameState () const = 0;
 
71
        virtual unsigned int getFrameActions () const = 0;
 
72
};
 
73
 
 
74
class DecorPixmapDeletionInterface
 
75
{
 
76
    public:
 
77
 
 
78
        typedef boost::shared_ptr <DecorPixmapDeletionInterface> Ptr;
 
79
 
 
80
        virtual ~DecorPixmapDeletionInterface () {}
 
81
 
 
82
        virtual int postDeletePixmap (Pixmap pixmap) = 0;
 
83
};
 
84
 
 
85
class X11PixmapDeletor :
 
86
    public DecorPixmapDeletionInterface
 
87
{
 
88
    public:
 
89
 
 
90
        typedef boost::shared_ptr <X11PixmapDeletor> Ptr;
 
91
 
 
92
        X11PixmapDeletor (Display *dpy) :
 
93
            mDisplay (dpy)
 
94
        {
 
95
        }
 
96
 
 
97
        int postDeletePixmap (Pixmap pixmap) { return decor_post_delete_pixmap (mDisplay, pixmap); }
 
98
 
 
99
    private:
 
100
 
 
101
        Display *mDisplay;
 
102
};
 
103
 
 
104
class DecorPixmap :
 
105
    public DecorPixmapInterface
 
106
{
 
107
    public:
 
108
 
 
109
        typedef boost::shared_ptr <DecorPixmap> Ptr;
 
110
 
 
111
        DecorPixmap (Pixmap p, DecorPixmapDeletionInterface::Ptr deletor);
 
112
        ~DecorPixmap ();
 
113
 
 
114
        Pixmap getPixmap ();
 
115
 
 
116
    private:
 
117
 
 
118
        Pixmap mPixmap;
 
119
        DecorPixmapDeletionInterface::Ptr mDeletor;
 
120
};
 
121
 
 
122
class DecorPixmapRequestorInterface
 
123
{
 
124
    public:
 
125
 
 
126
        virtual ~DecorPixmapRequestorInterface () {}
 
127
 
 
128
        virtual int postGenerateRequest (unsigned int frameType,
 
129
                                         unsigned int frameState,
 
130
                                         unsigned int frameActions) = 0;
 
131
 
 
132
        virtual void handlePending (long *data) = 0;
 
133
};
 
134
 
 
135
class DecorationListFindMatchingInterface
 
136
{
 
137
    public:
 
138
 
 
139
        virtual ~DecorationListFindMatchingInterface () {}
 
140
 
 
141
        virtual DecorationInterface::Ptr findMatchingDecoration (unsigned int frameType,
 
142
                                                                 unsigned int frameState,
 
143
                                                                 unsigned int frameActions) = 0;
 
144
};
 
145
 
 
146
class X11DecorPixmapRequestor :
 
147
    public DecorPixmapRequestorInterface
 
148
{
 
149
    public:
 
150
 
 
151
        X11DecorPixmapRequestor (Display *dpy,
 
152
                                 Window  xid,
 
153
                                 DecorationListFindMatchingInterface *listFinder);
 
154
 
 
155
        int postGenerateRequest (unsigned int frameType,
 
156
                                 unsigned int frameState,
 
157
                                 unsigned int frameActions);
 
158
 
 
159
        void handlePending (long *data);
 
160
 
 
161
    private:
 
162
 
 
163
        Display *mDpy;
 
164
        Window  mWindow;
 
165
        DecorationListFindMatchingInterface *mListFinder;
 
166
};
 
167
 
 
168
class X11DecorPixmapReceiver :
 
169
    public DecorPixmapReceiverInterface
 
170
{
 
171
    public:
 
172
 
 
173
        static const unsigned int UpdateRequested = 1 << 0;
 
174
        static const unsigned int UpdatesPending = 1 << 1;
 
175
 
 
176
        X11DecorPixmapReceiver (DecorPixmapRequestorInterface *,
 
177
                                DecorationInterface *decor);
 
178
 
 
179
        void pending ();
 
180
        void update ();
 
181
    private:
 
182
 
 
183
        unsigned int mUpdateState;
 
184
        DecorPixmapRequestorInterface *mDecorPixmapRequestor;
 
185
        DecorationInterface *mDecoration;
 
186
};
 
187
 
 
188
#endif