~linaro-maintainers/compiz-plugins-main/overlay-gl

« back to all changes in this revision

Viewing changes to debian/patches/fix-827560.patch

  • Committer: Sam Spilsbury
  • Date: 2011-10-07 16:09:42 UTC
  • Revision ID: sam.spilsbury@canonical.com-20111007160942-9zkw97vowa95galq
Added some new patches

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
=== modified file 'src/grid.cpp'
 
2
Index: compiz-plugins-main-0.9.6/grid/src/grid.cpp
 
3
===================================================================
 
4
--- compiz-plugins-main-0.9.6.orig/grid/src/grid.cpp    2011-09-28 16:58:20.000000000 +0800
 
5
+++ compiz-plugins-main-0.9.6/grid/src/grid.cpp 2011-10-08 00:01:34.156630446 +0800
 
6
@@ -24,6 +24,8 @@
 
7
 
 
8
 #include "grid.h"
 
9
 
 
10
+using namespace GridWindowType;
 
11
+
 
12
 static const GridProps gridProps[] =
 
13
 {
 
14
     {0,1, 1,1},
 
15
@@ -145,12 +147,23 @@
 
16
     xid = CompOption::getIntOptionNamed (option, "window");
 
17
     cw  = screen->findWindow (xid);
 
18
 
 
19
-    if (where == GridUnknown || screen->otherGrabExist ("move", NULL))
 
20
-       return false;
 
21
-
 
22
     if (cw)
 
23
     {
 
24
        XWindowChanges xwc;
 
25
+       bool maximizeH = where & (GridBottom | GridTop | GridMaximize);
 
26
+       bool maximizeV = where & (GridLeft | GridRight | GridMaximize);
 
27
+
 
28
+       if (!(cw->actions () & CompWindowActionResizeMask))
 
29
+           return false;
 
30
+
 
31
+       if (maximizeH && !(cw->actions () & CompWindowActionMaximizeHorzMask))
 
32
+           return false;
 
33
+
 
34
+       if (maximizeV && !(cw->actions () & CompWindowActionMaximizeVertMask))
 
35
+           return false;
 
36
+
 
37
+       if (where == GridUnknown)
 
38
+           return false;
 
39
 
 
40
        GRID_WINDOW (cw);
 
41
 
 
42
@@ -339,13 +352,42 @@
 
43
        /* TODO: animate move+resize */
 
44
        if (resize)
 
45
        {
 
46
-           cw->configureXWindow (CWX | CWY | CWWidth | CWHeight, &xwc);
 
47
-           gw->isGridResized = true;
 
48
-           gw->isGridMaximized = false;
 
49
-               for (unsigned int i = 0; i < animations.size (); i++)
 
50
-                       animations.at (i).fadingOut = true;
 
51
+           unsigned int valueMask = CWX | CWY | CWWidth | CWHeight;
 
52
            gw->lastTarget = where;
 
53
            gw->currentSize = CompRect (wc.x, wc.y, wc.width, wc.height);
 
54
+
 
55
+           /* Special case for left and right, actually vertically maximize
 
56
+            * the window */
 
57
+           if (where == GridLeft || where == GridRight)
 
58
+           {
 
59
+               /* First restore the window to its original size */
 
60
+               XWindowChanges rwc;
 
61
+
 
62
+               rwc.x = gw->originalSize.x ();
 
63
+               rwc.y = gw->originalSize.y ();
 
64
+               rwc.width = gw->originalSize.width ();
 
65
+               rwc.height = gw->originalSize.height ();
 
66
+
 
67
+               cw->configureXWindow (CWX | CWY | CWWidth | CWHeight, &rwc);
 
68
+
 
69
+               gw->isGridMaximized = true;
 
70
+               gw->isGridResized = false;
 
71
+
 
72
+               gw->lastBorder = cw->border ();
 
73
+               /* Maximize the window */
 
74
+               cw->maximize (CompWindowStateMaximizedVertMask);
 
75
+           }
 
76
+           else
 
77
+           {
 
78
+               gw->isGridResized = true;
 
79
+               gw->isGridMaximized = false;
 
80
+           }
 
81
+
 
82
+           /* Make window the size that we want */
 
83
+           cw->configureXWindow (valueMask, &xwc);
 
84
+
 
85
+           for (unsigned int i = 0; i < animations.size (); i++)
 
86
+               animations.at (i).fadingOut = true;
 
87
        }
 
88
 
 
89
        /* This centers a window if it could not be resized to the desired
 
90
@@ -621,20 +663,23 @@
 
91
                        if (edge != NoEdge && check)
 
92
                        {
 
93
                                CompWindow *cw = screen->findWindow (screen->activeWindow ());
 
94
-                               animations.push_back (Animation ());
 
95
-                               int current = animations.size () - 1;
 
96
-                               animations.at (current).fromRect        = cw->serverBorderRect ();
 
97
-                               animations.at (current).currentRect     = cw->serverBorderRect ();
 
98
-                               animations.at (current).timer = animations.at (current).duration;
 
99
-                               animations.at (current).targetRect = desiredSlot;
 
100
-
 
101
-                               if (lastEdge == NoEdge || !animating)
 
102
+                               if (cw)
 
103
                                {
 
104
+                                   animations.push_back (Animation ());
 
105
+                                   int current = animations.size () - 1;
 
106
+                                   animations.at (current).fromRect    = cw->serverBorderRect ();
 
107
+                                   animations.at (current).currentRect = cw->serverBorderRect ();
 
108
+                                   animations.at (current).timer = animations.at (current).duration;
 
109
+                                   animations.at (current).targetRect = desiredSlot;
 
110
+
 
111
+                                   if (lastEdge == NoEdge || !animating)
 
112
+                                   {
 
113
                                        /* Cursor has entered edge region from non-edge region */
 
114
                                        animating = true;
 
115
                                        glScreen->glPaintOutputSetEnabled (this, true);
 
116
                                        cScreen->preparePaintSetEnabled (this, true);
 
117
                                        cScreen->donePaintSetEnabled (this, true);
 
118
+                                   }
 
119
                                }
 
120
                        }
 
121
                }
 
122
@@ -664,21 +709,22 @@
 
123
                        unsigned int state,
 
124
                        unsigned int mask)
 
125
 {
 
126
-    if (screen->grabExist ("move"))
 
127
+    if (mask & (CompWindowGrabMoveMask | CompWindowGrabButtonMask))
 
128
     {
 
129
        gScreen->o[0].value ().set ((int) window->id ());
 
130
 
 
131
        screen->handleEventSetEnabled (gScreen, true);
 
132
        gScreen->mGrabWindow = window;
 
133
        pointerBufDx = pointerBufDy = 0;
 
134
+       grabMask = mask;
 
135
 
 
136
-       if (!isGridResized && gScreen->optionGetSnapbackWindows ())
 
137
+       if (!isGridResized && !isGridMaximized && gScreen->optionGetSnapbackWindows ())
 
138
            /* Store size not including borders when grabbing with cursor */
 
139
            originalSize = gScreen->slotToRect(window,
 
140
                                                    window->serverBorderRect ());
 
141
     }
 
142
 
 
143
-    if (screen->grabExist ("resize"))
 
144
+    if (mask & CompWindowGrabResizeMask)
 
145
     {
 
146
        isGridResized = false;
 
147
        resizeCount = 0;
 
148
@@ -697,6 +743,7 @@
 
149
                         gScreen->edge != gScreen->lastResizeEdge);
 
150
 
 
151
        screen->handleEventSetEnabled (gScreen, false);
 
152
+       grabMask = 0;
 
153
        gScreen->mGrabWindow = NULL;
 
154
        gScreen->o[0].value ().set (0);
 
155
        gScreen->cScreen->damageRegion (gScreen->desiredSlot);
 
156
@@ -715,7 +762,7 @@
 
157
 
 
158
     if (isGridResized && !isGridMaximized && !GridScreen::get (screen)->mSwitchingVp)
 
159
     {
 
160
-       if (window->grabbed ())
 
161
+       if (window->grabbed () && (grabMask & CompWindowGrabMoveMask))
 
162
        {
 
163
            pointerBufDx += dx;
 
164
            pointerBufDy += dy;
 
165
@@ -738,11 +785,49 @@
 
166
        lastTarget = GridUnknown;
 
167
     else if (!(lastState & MAXIMIZE_STATE) &&
 
168
             window->state () & MAXIMIZE_STATE)
 
169
+    {
 
170
        lastTarget = GridMaximize;
 
171
+       if (window->grabbed ())
 
172
+       {
 
173
+           originalSize = gScreen->slotToRect (window,
 
174
+                                               window->serverBorderRect ());
 
175
+       }
 
176
+    }
 
177
 
 
178
     window->stateChangeNotify (lastState);
 
179
-} 
 
180
+}
 
181
+
 
182
+void
 
183
+GridWindow::windowNotify (CompWindowNotify n)
 
184
+{
 
185
+    if (n == CompWindowNotifyFrameUpdate)
 
186
+    {
 
187
+       if (isGridMaximized && !((window->state () & MAXIMIZE_STATE) == MAXIMIZE_STATE))
 
188
+       {
 
189
+           unsigned int valueMask = 0;
 
190
+           XWindowChanges xwc;
 
191
+
 
192
+           int dw = (lastBorder.left + lastBorder.right) - 
 
193
+                     (window->border ().left + window->border ().right);
 
194
+                       
 
195
+           int dh = (lastBorder.top + lastBorder.bottom) - 
 
196
+                       (window->border ().top + window->border ().bottom);
 
197
+
 
198
+           if (dw != 0)
 
199
+               valueMask |= CWWidth;
 
200
+           if (dh != 0)
 
201
+               valueMask |= CWHeight;
 
202
+           xwc.width = window->serverGeometry ().width () + dw;
 
203
+           xwc.height = window->serverGeometry ().height () + dh;
 
204
 
 
205
+           window->configureXWindow (valueMask, &xwc);
 
206
+       }
 
207
+
 
208
+       lastBorder = window->border ();
 
209
+    }
 
210
+
 
211
+    window->windowNotify (n);
 
212
+}
 
213
 bool
 
214
 GridScreen::restoreWindow (CompAction         *action,
 
215
                           CompAction::State  state,
 
216
@@ -929,6 +1014,7 @@
 
217
     gScreen (GridScreen::get (screen)),
 
218
     isGridResized (false),
 
219
     isGridMaximized (false),
 
220
+    grabMask (0),
 
221
     pointerBufDx (0),
 
222
     pointerBufDy (0),
 
223
     resizeCount (0),
 
224
Index: compiz-plugins-main-0.9.6/grid/src/grid.h
 
225
===================================================================
 
226
--- compiz-plugins-main-0.9.6.orig/grid/src/grid.h      2011-09-28 16:58:20.000000000 +0800
 
227
+++ compiz-plugins-main-0.9.6/grid/src/grid.h   2011-10-08 00:01:00.668464373 +0800
 
228
@@ -32,20 +32,22 @@
 
229
 
 
230
 #define SNAPOFF_THRESHOLD 50
 
231
 
 
232
-typedef enum
 
233
+namespace GridWindowType
 
234
 {
 
235
-    GridUnknown = 0,
 
236
-    GridBottomLeft = 1,
 
237
-    GridBottom = 2,
 
238
-    GridBottomRight = 3,
 
239
-    GridLeft = 4,
 
240
-    GridCenter = 5,
 
241
-    GridRight = 6,
 
242
-    GridTopLeft = 7,
 
243
-    GridTop = 8,
 
244
-    GridTopRight = 9,
 
245
-    GridMaximize = 10
 
246
-} GridType;
 
247
+    static const unsigned int GridUnknown = (1 << 0);
 
248
+    static const unsigned int GridBottomLeft  = (1 << 1);
 
249
+    static const unsigned int GridBottom  = (1 << 2);
 
250
+    static const unsigned int GridBottomRight = (1 << 3);
 
251
+    static const unsigned int GridLeft  = (1 << 4);
 
252
+    static const unsigned int GridCenter  = (1 << 5);
 
253
+    static const unsigned int GridRight  = (1 << 6);
 
254
+    static const unsigned int GridTopLeft  = (1 << 7);
 
255
+    static const unsigned int GridTop  = (1 << 8);
 
256
+    static const unsigned int GridTopRight  = (1 << 9);
 
257
+    static const unsigned int GridMaximize  = (1 << 10);
 
258
+};
 
259
+
 
260
+typedef unsigned int GridType;
 
261
 
 
262
 typedef struct _GridProps
 
263
 {
 
264
@@ -160,11 +162,13 @@
 
265
 
 
266
        bool isGridResized;
 
267
        bool isGridMaximized;
 
268
+       unsigned int grabMask;
 
269
        int pointerBufDx;
 
270
        int pointerBufDy;
 
271
        int resizeCount;
 
272
        CompRect currentSize;
 
273
        CompRect originalSize;
 
274
+       CompWindowExtents lastBorder;
 
275
        GridType lastTarget;
 
276
 
 
277
        void grabNotify (int, int, unsigned int, unsigned int);
 
278
@@ -174,6 +178,8 @@
 
279
        void moveNotify (int, int, bool);
 
280
 
 
281
        void stateChangeNotify (unsigned int);
 
282
+
 
283
+       void windowNotify (CompWindowNotify n);
 
284
 };
 
285
 
 
286
 #define GRID_WINDOW(w) \