Merge lp:~compiz-team/compiz-grid-plugin/compiz-grid-plugin-oneiric.fix_862260 into lp:~compiz-team/compiz-grid-plugin/oneiric

Proposed by Sam Spilsbury
Status: Merged
Merged at revision: 90
Proposed branch: lp:~compiz-team/compiz-grid-plugin/compiz-grid-plugin-oneiric.fix_862260
Merge into: lp:~compiz-team/compiz-grid-plugin/oneiric
Diff against target: 304 lines (+85/-51)
3 files modified
CMakeLists.txt (+2/-0)
src/grid.cpp (+80/-49)
src/grid.h (+3/-2)
To merge this branch: bzr merge lp:~compiz-team/compiz-grid-plugin/compiz-grid-plugin-oneiric.fix_862260
Reviewer Review Type Date Requested Status
Neil J. Patel (community) Approve
Review via email: mp+77505@code.launchpad.net

Description of the change

Fix LP Bug 862260

To post a comment you must log in.
Revision history for this message
Neil J. Patel (njpatel) wrote :

Looks good.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'CMakeLists.txt'
2--- CMakeLists.txt 2009-12-17 12:22:47 +0000
3+++ CMakeLists.txt 2011-09-29 11:23:07 +0000
4@@ -2,4 +2,6 @@
5
6 include (CompizPlugin)
7
8+set (CMAKE_CXX_FLAGS -std=c++0x)
9+
10 compiz_plugin(grid PLUGINDEPS composite opengl)
11
12=== modified file 'src/grid.cpp'
13--- src/grid.cpp 2011-09-28 16:58:29 +0000
14+++ src/grid.cpp 2011-09-29 11:23:07 +0000
15@@ -26,24 +26,7 @@
16
17 using namespace GridWindowType;
18
19-static const GridProps gridProps[] =
20-{
21- {0,1, 1,1},
22-
23- {0,1, 2,2},
24- {0,1, 1,2},
25- {1,1, 2,2},
26-
27- {0,0, 2,1},
28- {0,0, 1,1},
29- {1,0, 2,1},
30-
31- {0,0, 2,2},
32- {0,0, 1,2},
33- {1,0, 2,2},
34-
35- {0,0, 1,1},
36-};
37+static std::map <unsigned int, GridProps> gridProps;
38
39 void
40 GridScreen::handleCompizEvent(const char* plugin,
41@@ -102,7 +85,7 @@
42 void
43 GridScreen::getPaintRectangle (CompRect &cRect)
44 {
45- if (edgeToGridType () != GridUnknown && optionGetDrawIndicator ())
46+ if (typeToMask (edgeToGridType ()) != GridUnknown && optionGetDrawIndicator ())
47 cRect = desiredSlot;
48 else
49 cRect.setGeometry (0, 0, 0, 0);
50@@ -137,7 +120,7 @@
51 GridScreen::initiateCommon (CompAction *action,
52 CompAction::State state,
53 CompOption::Vector &option,
54- GridType where,
55+ unsigned int where,
56 bool resize,
57 bool key)
58 {
59@@ -162,12 +145,12 @@
60 if (maximizeV && !(cw->actions () & CompWindowActionMaximizeVertMask))
61 return false;
62
63- if (where == GridUnknown)
64+ if (where & GridUnknown)
65 return false;
66
67 GRID_WINDOW (cw);
68
69- if (gw->lastTarget != where)
70+ if (gw->lastTarget & ~(where))
71 gw->resizeCount = 0;
72 else if (!key)
73 return false;
74@@ -197,7 +180,7 @@
75 cw->maximize (0);
76 }
77
78- if (where == GridMaximize && resize)
79+ if ((where & GridMaximize) && resize)
80 {
81 /* move the window to the correct output */
82 if (cw == mGrabWindow)
83@@ -239,7 +222,7 @@
84
85 if (desiredRect.y () == currentRect.y () &&
86 desiredRect.height () == currentRect.height () &&
87- where != GridMaximize && gw->lastTarget == where)
88+ where & ~(GridMaximize) && gw->lastTarget & where)
89 {
90 int slotWidth25 = workarea.width () / 4;
91 int slotWidth33 = (workarea.width () / 3) + cw->border ().left;
92@@ -358,7 +341,7 @@
93
94 /* Special case for left and right, actually vertically maximize
95 * the window */
96- if (where == GridLeft || where == GridRight)
97+ if (where & GridLeft || where & GridRight)
98 {
99 /* First restore the window to its original size */
100 XWindowChanges rwc;
101@@ -375,6 +358,7 @@
102
103 gw->lastBorder = cw->border ();
104 /* Maximize the window */
105+ printf ("maximizing window\n");
106 cw->maximize (CompWindowStateMaximizedVertMask);
107 }
108 else
109@@ -533,39 +517,72 @@
110 return status;
111 }
112
113-GridType
114+unsigned int
115+GridScreen::typeToMask (int t)
116+{
117+ typedef struct {
118+ unsigned int mask;
119+ int type;
120+ } GridTypeMask;
121+
122+ std::vector <GridTypeMask> type =
123+ {
124+ { GridWindowType::GridUnknown, 0 },
125+ { GridWindowType::GridBottomLeft, 1 },
126+ { GridWindowType::GridBottom, 2 },
127+ { GridWindowType::GridBottomRight, 3 },
128+ { GridWindowType::GridLeft, 4 },
129+ { GridWindowType::GridCenter, 5 },
130+ { GridWindowType::GridRight, 6 },
131+ { GridWindowType::GridTopLeft, 7 },
132+ { GridWindowType::GridTop, 8 },
133+ { GridWindowType::GridTopRight, 9 },
134+ { GridWindowType::GridMaximize, 10 }
135+ };
136+
137+ for (unsigned int i = 0; i < type.size (); i++)
138+ {
139+ GridTypeMask &tm = type[i];
140+ if (tm.type == t)
141+ return tm.mask;
142+ }
143+
144+ return GridWindowType::GridUnknown;
145+}
146+
147+int
148 GridScreen::edgeToGridType ()
149 {
150- GridType ret;
151+ int ret;
152
153 switch (edge) {
154 case Left:
155- ret = (GridType) optionGetLeftEdgeAction ();
156+ ret = (int) optionGetLeftEdgeAction ();
157 break;
158 case Right:
159- ret = (GridType) optionGetRightEdgeAction ();
160+ ret = (int) optionGetRightEdgeAction ();
161 break;
162 case Top:
163- ret = (GridType) optionGetTopEdgeAction ();
164+ ret = (int) optionGetTopEdgeAction ();
165 break;
166 case Bottom:
167- ret = (GridType) optionGetBottomEdgeAction ();
168+ ret = (int) optionGetBottomEdgeAction ();
169 break;
170 case TopLeft:
171- ret = (GridType) optionGetTopLeftCornerAction ();
172+ ret = (int) optionGetTopLeftCornerAction ();
173 break;
174 case TopRight:
175- ret = (GridType) optionGetTopRightCornerAction ();
176+ ret = (int) optionGetTopRightCornerAction ();
177 break;
178 case BottomLeft:
179- ret = (GridType) optionGetBottomLeftCornerAction ();
180+ ret = (int) optionGetBottomLeftCornerAction ();
181 break;
182 case BottomRight:
183- ret = (GridType) optionGetBottomRightCornerAction ();
184+ ret = (int) optionGetBottomRightCornerAction ();
185 break;
186 case NoEdge:
187 default:
188- ret = GridUnknown;
189+ ret = -1;
190 break;
191 }
192
193@@ -631,7 +648,7 @@
194 if (cScreen)
195 cScreen->damageRegion (desiredSlot);
196
197- initiateCommon (0, 0, o, edgeToGridType (), false, false);
198+ initiateCommon (0, 0, o, typeToMask (edgeToGridType ()), false, false);
199
200 if (cScreen)
201 cScreen->damageRegion (desiredSlot);
202@@ -649,7 +666,7 @@
203 if (cScreen)
204 cScreen->damageRegion (desiredSlot);
205
206- check = initiateCommon (0, 0, o, edgeToGridType (), false, false);
207+ check = initiateCommon (NULL, 0, o, typeToMask (edgeToGridType ()), false, false);
208
209 if (cScreen)
210 cScreen->damageRegion (desiredSlot);
211@@ -736,7 +753,7 @@
212 if (window == gScreen->mGrabWindow)
213 {
214 gScreen->initiateCommon
215- (0, 0, gScreen->o, gScreen->edgeToGridType (), true,
216+ (NULL, 0, gScreen->o, gScreen->typeToMask (gScreen->edgeToGridType ()), true,
217 gScreen->edge != gScreen->lastResizeEdge);
218
219 screen->handleEventSetEnabled (gScreen, false);
220@@ -770,6 +787,8 @@
221 dx = currentSize.x () - window->geometry ().x ();
222 dy = currentSize.y () - window->geometry ().y ();
223
224+ printf ("offset move\n");
225+
226 window->move (dx, dy);
227 }
228 }
229@@ -859,6 +878,7 @@
230 xwc.height = gw->originalSize.height ();
231 cw->maximize (0);
232 gw->currentSize = CompRect ();
233+ printf ("attempting snapBack\n");
234 cw->configureXWindow (CWX | CWY | CWWidth | CWHeight, &xwc);
235 gw->pointerBufDx = 0;
236 gw->pointerBufDy = 0;
237@@ -977,6 +997,17 @@
238 edge = lastEdge = lastResizeEdge = NoEdge;
239 currentWorkarea = lastWorkarea = screen->getWorkareaForOutput
240 (screen->outputDeviceForPoint (pointerX, pointerY));
241+ gridProps[GridUnknown] = GridProps {0,1, 1,1};
242+ gridProps[GridBottomLeft] = GridProps {0,1, 2,2};
243+ gridProps[GridBottom] = GridProps {0,1, 1,2};
244+ gridProps[GridBottomRight] = GridProps {1,1, 2,2};
245+ gridProps[GridLeft] = GridProps {0,0, 2,1};
246+ gridProps[GridCenter] = GridProps{0,0, 1,1};
247+ gridProps[GridRight] = GridProps {1,0, 2,1};
248+ gridProps[GridTopLeft] = GridProps{0,0, 2,2};
249+ gridProps[GridTop] = GridProps {0,0, 1,2};
250+ gridProps[GridTopRight] = GridProps {0,0, 1,2};
251+ gridProps[GridMaximize] = GridProps {0,0, 1,1};
252
253 animations.clear ();
254
255@@ -984,16 +1015,16 @@
256 optionSet##opt##Initiate (boost::bind (&GridScreen::initiateCommon, this, \
257 _1, _2, _3, where, resize, key))
258
259- GRIDSET (PutCenterKey, GridCenter, true, true);
260- GRIDSET (PutLeftKey, GridLeft, true, true);
261- GRIDSET (PutRightKey, GridRight, true, true);
262- GRIDSET (PutTopKey, GridTop, true, true);
263- GRIDSET (PutBottomKey, GridBottom, true, true);
264- GRIDSET (PutTopleftKey, GridTopLeft, true, true);
265- GRIDSET (PutToprightKey, GridTopRight, true, true);
266- GRIDSET (PutBottomleftKey, GridBottomLeft, true, true);
267- GRIDSET (PutBottomrightKey, GridBottomRight, true, true);
268- GRIDSET (PutMaximizeKey, GridMaximize, true, true);
269+ GRIDSET (PutCenterKey, GridWindowType::GridCenter, true, true);
270+ GRIDSET (PutLeftKey, GridWindowType::GridLeft, true, true);
271+ GRIDSET (PutRightKey, GridWindowType::GridRight, true, true);
272+ GRIDSET (PutTopKey, GridWindowType::GridTop, true, true);
273+ GRIDSET (PutBottomKey, GridWindowType::GridBottom, true, true);
274+ GRIDSET (PutTopleftKey, GridWindowType::GridTopLeft, true, true);
275+ GRIDSET (PutToprightKey, GridWindowType::GridTopRight, true, true);
276+ GRIDSET (PutBottomleftKey, GridWindowType::GridBottomLeft, true, true);
277+ GRIDSET (PutBottomrightKey, GridWindowType::GridBottomRight, true, true);
278+ GRIDSET (PutMaximizeKey, GridWindowType::GridMaximize, true, true);
279
280 #undef GRIDSET
281
282
283=== modified file 'src/grid.h'
284--- src/grid.h 2011-09-28 16:58:29 +0000
285+++ src/grid.h 2011-09-29 11:23:07 +0000
286@@ -114,7 +114,7 @@
287 void setCurrentRect (Animation&);
288
289 bool initiateCommon (CompAction*, CompAction::State,
290- CompOption::Vector&, GridType, bool, bool);
291+ CompOption::Vector&, unsigned int, bool, bool);
292
293 void glPaintRectangle (const GLScreenPaintAttrib&,
294 const GLMatrix&, CompOutput *);
295@@ -128,7 +128,8 @@
296
297 std::vector <Animation> animations;
298
299- GridType edgeToGridType ();
300+ int edgeToGridType ();
301+ unsigned int typeToMask (int);
302
303 void handleEvent (XEvent *event);
304 void handleCompizEvent (const char *plugin, const char *event, CompOption::Vector &options);

Subscribers

People subscribed via source and target branches

to all changes: