~hypodermia/ubuntu/oneiric/compiz/fix-for-bug-301174

« back to all changes in this revision

Viewing changes to .pc/01_bzr_fix_grid_on_multimonitor.patch/plugins/grid/src/grid.h

  • Committer: Bazaar Package Importer
  • Author(s): Didier Roche
  • Date: 2011-04-07 18:06:44 UTC
  • mfrom: (0.168.4 upstream)
  • Revision ID: james.westby@ubuntu.com-20110407180644-7xwnirf7k3zotc2w
Tags: 1:0.9.4+bzr20110407-0ubuntu2
* New upstream snapshot:
  - fix unity-window-decorator crashed with SIGSEGV in event_filter_funct
    (LP: #711561)
* debian/patches/086_new_grid_defaults.patch:
  - change threshold to 15 on sides and 20 on top to work well with the new
    animtion
* debian/patches/01_bzr_fix_grid_on_multimonitor.patch,
  01_bzr_fix_resize.patch, 01_bzr_fix_grid_premultiply.patch:
  - from upstream bzr, fix grid on multimonitor and colors handling
* debian/patches/086_new_grid_defaults.patch,
  debian/patches/029_default_options.patch:
  - set the resize grid shadow to orange (LP: #752711)

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * Compiz Fusion Grid plugin
 
3
 *
 
4
 * Copyright (c) 2008 Stephen Kennedy <suasol@gmail.com>
 
5
 * Copyright (c) 2010 Scott Moreau <oreaus@gmail.com>
 
6
 *
 
7
 * This program is free software; you can redistribute it and/or
 
8
 * modify it under the terms of the GNU General Public License
 
9
 * as published by the Free Software Foundation; either version 2
 
10
 * of the License, or (at your option) any later version.
 
11
 *
 
12
 * This program is distributed in the hope that it will be useful,
 
13
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 
14
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
15
 * GNU General Public License for more details.
 
16
 *
 
17
 * Description:
 
18
 *
 
19
 * Plugin to act like winsplit revolution (http://www.winsplit-revolution.com/)
 
20
 * use <Control><Alt>NUMPAD_KEY to move and tile your windows.
 
21
 *
 
22
 * Press the tiling keys several times to cycle through some tiling options.
 
23
 */
 
24
 
 
25
#include <core/core.h>
 
26
#include <core/atoms.h>
 
27
#include <core/pluginclasshandler.h>
 
28
#include <composite/composite.h>
 
29
#include <opengl/opengl.h>
 
30
 
 
31
#include <cmath>
 
32
 
 
33
#include "grid_options.h"
 
34
 
 
35
#define SNAPOFF_THRESHOLD 50
 
36
 
 
37
extern bool compositingActive;
 
38
 
 
39
typedef enum
 
40
{
 
41
    GridUnknown = 0,
 
42
    GridBottomLeft = 1,
 
43
    GridBottom = 2,
 
44
    GridBottomRight = 3,
 
45
    GridLeft = 4,
 
46
    GridCenter = 5,
 
47
    GridRight = 6,
 
48
    GridTopLeft = 7,
 
49
    GridTop = 8,
 
50
    GridTopRight = 9,
 
51
    GridMaximize = 10
 
52
} GridType;
 
53
 
 
54
typedef struct _GridProps
 
55
{
 
56
    int gravityRight;
 
57
    int gravityDown;
 
58
    int numCellsX;
 
59
    int numCellsY;
 
60
} GridProps;
 
61
 
 
62
enum Edges
 
63
{
 
64
    NoEdge = 0,
 
65
    BottomLeft,
 
66
    Bottom,
 
67
    BottomRight,
 
68
    Left,
 
69
    Right,
 
70
    TopLeft,
 
71
    Top,
 
72
    TopRight
 
73
};
 
74
 
 
75
class GridRectangle :
 
76
    public CompRect
 
77
{
 
78
    public:
 
79
 
 
80
        GridRectangle () {};
 
81
        GridRectangle (const CompRect &r) :
 
82
            CompRect::CompRect (r)
 
83
        {
 
84
        };
 
85
 
 
86
        GridRectangle subtractBorders (CompWindow *w) const;
 
87
        GridRectangle addBorders (CompWindow *w) const;
 
88
};
 
89
 
 
90
class Paintable
 
91
{
 
92
    public:
 
93
 
 
94
        Paintable ()
 
95
        {
 
96
        };
 
97
 
 
98
        virtual void paint (const GLMatrix &mat) = 0;
 
99
};
 
100
 
 
101
class AnimatedGridRectangle :
 
102
    public GridRectangle
 
103
{
 
104
    public:
 
105
 
 
106
        AnimatedGridRectangle () :
 
107
            GridRectangle::GridRectangle (),
 
108
            mFrom (CompRect (0, 0, 0, 0)),
 
109
            mProgress (0.0f),
 
110
            mTime (300)
 
111
        {
 
112
        };
 
113
 
 
114
        AnimatedGridRectangle (const GridRectangle &r) :
 
115
            GridRectangle::GridRectangle (r),
 
116
            mFrom (CompRect (0, 0, 0, 0)),
 
117
            mProgress (0.0f),
 
118
            mTime (300)
 
119
        {
 
120
        };
 
121
 
 
122
        AnimatedGridRectangle (const CompRect &r) :
 
123
            GridRectangle::GridRectangle (r),
 
124
            mFrom (CompRect (0, 0, 0, 0)),
 
125
            mProgress (0.0f),
 
126
            mTime (300)
 
127
        {
 
128
        };
 
129
 
 
130
        CompRect current ();
 
131
        float    progress ();
 
132
 
 
133
        void setFrom (CompRect &);
 
134
        void setProgress (float);
 
135
        void reset ();
 
136
        void setTime (unsigned int);
 
137
 
 
138
    private:
 
139
 
 
140
        CompRect mFrom;
 
141
        float    mProgress;
 
142
 
 
143
        unsigned int mTime;
 
144
};
 
145
 
 
146
class PaintableAnimatedGridRectangle :
 
147
    public Paintable,
 
148
    public AnimatedGridRectangle
 
149
{
 
150
    public:
 
151
 
 
152
        PaintableAnimatedGridRectangle () :
 
153
            Paintable::Paintable (),
 
154
            AnimatedGridRectangle::AnimatedGridRectangle ()
 
155
        {
 
156
        };
 
157
 
 
158
        PaintableAnimatedGridRectangle (const GridRectangle &r) :
 
159
            Paintable::Paintable (),
 
160
            AnimatedGridRectangle::AnimatedGridRectangle (r)
 
161
        {
 
162
        };
 
163
 
 
164
        PaintableAnimatedGridRectangle (const CompRect &r) :
 
165
            Paintable::Paintable (),
 
166
            AnimatedGridRectangle::AnimatedGridRectangle (r)
 
167
        {
 
168
        };
 
169
 
 
170
        virtual void paint (const GLMatrix &mat);
 
171
};
 
172
 
 
173
class GridScreen :
 
174
    public ScreenInterface,
 
175
    public CompositeScreenInterface,
 
176
    public GLScreenInterface,
 
177
    public PluginClassHandler <GridScreen, CompScreen>,
 
178
    public GridOptions
 
179
{
 
180
    public:
 
181
 
 
182
        GridScreen (CompScreen *);
 
183
        CompositeScreen *cScreen;
 
184
        GLScreen        *glScreen;
 
185
 
 
186
        PaintableAnimatedGridRectangle *desiredSlot;
 
187
        CompRect workarea, currentRect,
 
188
                 desiredRect, lastWorkarea, currentWorkarea;
 
189
        GridProps props;
 
190
        Edges edge, lastEdge;
 
191
        CompWindow *mGrabWindow;
 
192
 
 
193
        void getPaintRectangle (CompRect&);
 
194
 
 
195
        bool initiateCommon (CompAction*, CompAction::State,
 
196
                             CompOption::Vector&, GridType, bool);
 
197
 
 
198
        bool glPaintOutput (const GLScreenPaintAttrib &,
 
199
                            const GLMatrix &, const CompRegion &,
 
200
                            CompOutput *, unsigned int);
 
201
 
 
202
        GridType edgeToGridType ();
 
203
 
 
204
        void handleEvent (XEvent *event);
 
205
 
 
206
        bool restoreWindow (CompAction*,
 
207
                            CompAction::State,
 
208
                            CompOption::Vector&);
 
209
 
 
210
        void
 
211
        snapbackOptionChanged (CompOption *option,
 
212
                                Options    num);
 
213
};
 
214
 
 
215
class GridWindow :
 
216
    public WindowInterface,
 
217
    public GLWindowInterface,
 
218
    public PluginClassHandler <GridWindow, CompWindow>
 
219
{
 
220
    public:
 
221
 
 
222
        GridWindow (CompWindow *);
 
223
        CompWindow *window;
 
224
        GLWindow   *glWindow;
 
225
        GridScreen *gScreen;
 
226
 
 
227
        bool isGridResized;
 
228
        bool isGridMaximized;
 
229
        int pointerBufDx;
 
230
        int pointerBufDy;
 
231
        int resizeCount;
 
232
        CompRect originalSize;
 
233
        GridType lastTarget;
 
234
 
 
235
        bool
 
236
        allowGrid (GridType t);
 
237
 
 
238
        GridRectangle
 
239
        constrainSize (const GridRectangle & slot);
 
240
 
 
241
        bool
 
242
        glDraw (const GLMatrix            &transform,
 
243
                GLFragment::Attrib        &fragment,
 
244
                const CompRegion          &region,
 
245
                unsigned int              mask);
 
246
 
 
247
        void grabNotify (int, int, unsigned int, unsigned int);
 
248
 
 
249
        void ungrabNotify ();
 
250
 
 
251
        void moveNotify (int, int, bool);
 
252
};
 
253
 
 
254
#define GRID_WINDOW(w) \
 
255
    GridWindow *gw = GridWindow::get (w)
 
256
 
 
257
class GridPluginVTable :
 
258
    public CompPlugin::VTableForScreenAndWindow <GridScreen, GridWindow>
 
259
{
 
260
    public:
 
261
 
 
262
        bool init ();
 
263
};
 
264
 
 
265
COMPIZ_PLUGIN_20090315 (grid, GridPluginVTable);
 
266