~mc-return/compiz/compiz.merge-src-screen.cpp-improvements

« back to all changes in this revision

Viewing changes to plugins/decor.h

  • Committer: Dennis kasprzyk
  • Author(s): Dennis Kasprzyk
  • Date: 2009-03-15 05:09:18 UTC
  • Revision ID: git-v1:163f6b6f3c3b7764987cbdf8e03cc355edeaa499
New generalized build system.

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
 
#include <boost/shared_ptr.hpp>
27
 
#include <core/core.h>
28
 
#include <core/privatehandler.h>
29
 
 
30
 
#include <composite/composite.h>
31
 
#include <opengl/opengl.h>
32
 
#include <core/atoms.h>
33
 
 
34
 
#define DECOR_OPTION_SHADOW_RADIUS   0
35
 
#define DECOR_OPTION_SHADOW_OPACITY  1
36
 
#define DECOR_OPTION_SHADOW_COLOR    2
37
 
#define DECOR_OPTION_SHADOW_OFFSET_X 3
38
 
#define DECOR_OPTION_SHADOW_OFFSET_Y 4
39
 
#define DECOR_OPTION_COMMAND         5
40
 
#define DECOR_OPTION_MIPMAP          6
41
 
#define DECOR_OPTION_DECOR_MATCH     7
42
 
#define DECOR_OPTION_SHADOW_MATCH    8
43
 
#define DECOR_OPTION_NUM             9
44
 
 
45
 
#define DECOR_SCREEN(s) DecorScreen *ds = DecorScreen::get(s)
46
 
#define DECOR_WINDOW(w) DecorWindow *dw = DecorWindow::get(w)
47
 
 
48
 
struct Vector {
49
 
    int dx;
50
 
    int dy;
51
 
    int x0;
52
 
    int y0;
53
 
};
54
 
 
55
 
#define DECOR_BARE   0
56
 
#define DECOR_NORMAL 1
57
 
#define DECOR_ACTIVE 2
58
 
#define DECOR_NUM    3
59
 
 
60
 
class DecorTexture {
61
 
 
62
 
    public:
63
 
        DecorTexture (Pixmap pixmap);
64
 
        ~DecorTexture ();
65
 
 
66
 
    public:
67
 
        bool            status;
68
 
        int             refCount;
69
 
        Pixmap          pixmap;
70
 
        Damage          damage;
71
 
        GLTexture::List textures;
72
 
};
73
 
 
74
 
class DecorWindow;
75
 
 
76
 
class Decoration {
77
 
 
78
 
    public:
79
 
        static Decoration * create (Window id, Atom decorAtom);
80
 
        static void release (Decoration *);
81
 
 
82
 
    public:
83
 
        int                       refCount;
84
 
        DecorTexture              *texture;
85
 
        CompWindowExtents         output;
86
 
        CompWindowExtents         input;
87
 
        CompWindowExtents         maxInput;
88
 
        int                       minWidth;
89
 
        int                       minHeight;
90
 
        decor_quad_t              *quad;
91
 
        int                       nQuad;
92
 
        int                       type;
93
 
};
94
 
 
95
 
struct ScaledQuad {
96
 
    GLTexture::Matrix matrix;
97
 
    BoxRec            box;
98
 
    float             sx;
99
 
    float             sy;
100
 
};
101
 
 
102
 
class WindowDecoration {
103
 
    public:
104
 
        static WindowDecoration * create (Decoration *);
105
 
        static void destroy (WindowDecoration *);
106
 
 
107
 
    public:
108
 
        Decoration *decor;
109
 
        ScaledQuad *quad;
110
 
        int        nQuad;
111
 
};
112
 
 
113
 
class DecorWindow;
114
 
 
115
 
class DecorScreen :
116
 
    public ScreenInterface,
117
 
    public PrivateHandler<DecorScreen,CompScreen>
118
 
{
119
 
    public:
120
 
        DecorScreen (CompScreen *s);
121
 
        ~DecorScreen ();
122
 
 
123
 
        CompOption::Vector & getOptions ();
124
 
        bool setOption (const char *name, CompOption::Value &value);
125
 
 
126
 
        void handleEvent (XEvent *event);
127
 
        void matchPropertyChanged (CompWindow *);
128
 
 
129
 
        DecorTexture * getTexture (Pixmap);
130
 
        void releaseTexture (DecorTexture *);
131
 
 
132
 
        
133
 
        void checkForDm (bool);
134
 
        bool decoratorStartTimeout ();
135
 
 
136
 
    public:
137
 
 
138
 
        CompositeScreen *cScreen;
139
 
 
140
 
        std::list<DecorTexture *> textures;
141
 
 
142
 
        Atom supportingDmCheckAtom;
143
 
        Atom winDecorAtom;
144
 
        Atom decorAtom[DECOR_NUM];
145
 
        Atom inputFrameAtom;
146
 
        Atom outputFrameAtom;
147
 
        Atom decorTypeAtom;
148
 
        Atom decorTypePixmapAtom;
149
 
        Atom decorTypeWindowAtom;
150
 
 
151
 
        Window dmWin;
152
 
        int    dmSupports;
153
 
 
154
 
        Decoration *decor[DECOR_NUM];
155
 
        Decoration windowDefault;
156
 
 
157
 
        bool cmActive;
158
 
 
159
 
        std::map<Window, DecorWindow *> frames;
160
 
 
161
 
        CompOption::Vector opt;
162
 
        
163
 
        CompTimer decoratorStart;
164
 
};
165
 
 
166
 
class DecorWindow :
167
 
    public WindowInterface,
168
 
    public CompositeWindowInterface,
169
 
    public GLWindowInterface,
170
 
    public PrivateHandler<DecorWindow,CompWindow>
171
 
{
172
 
    public:
173
 
        DecorWindow (CompWindow *w);
174
 
        ~DecorWindow ();
175
 
 
176
 
        void getOutputExtents (CompWindowExtents&);
177
 
        void resizeNotify (int, int, int, int);
178
 
        void moveNotify (int, int, bool);
179
 
        void stateChangeNotify (unsigned int);
180
 
        void updateFrameRegion (CompRegion &region);
181
 
 
182
 
        bool damageRect (bool, const CompRect &);
183
 
 
184
 
        bool glDraw (const GLMatrix &, GLFragment::Attrib &,
185
 
                     const CompRegion &, unsigned int);
186
 
 
187
 
        void updateDecoration ();
188
 
 
189
 
        void setDecorationMatrices ();
190
 
 
191
 
        void updateDecorationScale ();
192
 
 
193
 
        void updateFrame ();
194
 
        void updateInputFrame ();
195
 
        void updateOutputFrame ();
196
 
        void updateWindowRegions ();
197
 
 
198
 
        bool checkSize (Decoration *decor);
199
 
 
200
 
        int shiftX ();
201
 
        int shiftY ();
202
 
 
203
 
        bool update (bool);
204
 
 
205
 
        bool resizeTimeout ();
206
 
 
207
 
    public:
208
 
 
209
 
        CompWindow      *window;
210
 
        GLWindow        *gWindow;
211
 
        CompositeWindow *cWindow;
212
 
        DecorScreen     *dScreen;
213
 
        
214
 
        WindowDecoration *wd;
215
 
        Decoration       *decor;
216
 
 
217
 
        CompRegion frameRegion;
218
 
 
219
 
        Window inputFrame;
220
 
        Window outputFrame;
221
 
        Damage frameDamage;
222
 
 
223
 
        int    oldX;
224
 
        int    oldY;
225
 
        int    oldWidth;
226
 
        int    oldHeight;
227
 
 
228
 
        bool pixmapFailed;
229
 
 
230
 
        CompRegion::Vector regions;
231
 
        bool               updateReg;
232
 
 
233
 
        CompTimer resizeUpdate;
234
 
        CompTimer moveUpdate;
235
 
};
236
 
 
237
 
class DecorPluginVTable :
238
 
    public CompPlugin::VTableForScreenAndWindow<DecorScreen, DecorWindow>
239
 
{
240
 
    public:
241
 
 
242
 
        bool init ();
243
 
 
244
 
        PLUGIN_OPTION_HELPER (DecorScreen);
245
 
};
246