Merge lp:~compiz-team/compiz-grid-plugin/compiz-grid-plugin-oneiric.fix_862260 into lp:~compiz-team/compiz-grid-plugin/oneiric
- compiz-grid-plugin-oneiric.fix_862260
- Merge into 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 | ||||
Related bugs: |
|
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Neil J. Patel (community) | Approve | ||
Review via email: mp+77505@code.launchpad.net |
Commit message
Description of the change
Fix LP Bug 862260
To post a comment you must log in.
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 | 2 | 2 | ||
6 | 3 | include (CompizPlugin) | 3 | include (CompizPlugin) |
7 | 4 | 4 | ||
8 | 5 | set (CMAKE_CXX_FLAGS -std=c++0x) | ||
9 | 6 | |||
10 | 5 | compiz_plugin(grid PLUGINDEPS composite opengl) | 7 | compiz_plugin(grid PLUGINDEPS composite opengl) |
11 | 6 | 8 | ||
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 | 26 | 26 | ||
17 | 27 | using namespace GridWindowType; | 27 | using namespace GridWindowType; |
18 | 28 | 28 | ||
37 | 29 | static const GridProps gridProps[] = | 29 | static std::map <unsigned int, GridProps> gridProps; |
20 | 30 | { | ||
21 | 31 | {0,1, 1,1}, | ||
22 | 32 | |||
23 | 33 | {0,1, 2,2}, | ||
24 | 34 | {0,1, 1,2}, | ||
25 | 35 | {1,1, 2,2}, | ||
26 | 36 | |||
27 | 37 | {0,0, 2,1}, | ||
28 | 38 | {0,0, 1,1}, | ||
29 | 39 | {1,0, 2,1}, | ||
30 | 40 | |||
31 | 41 | {0,0, 2,2}, | ||
32 | 42 | {0,0, 1,2}, | ||
33 | 43 | {1,0, 2,2}, | ||
34 | 44 | |||
35 | 45 | {0,0, 1,1}, | ||
36 | 46 | }; | ||
38 | 47 | 30 | ||
39 | 48 | void | 31 | void |
40 | 49 | GridScreen::handleCompizEvent(const char* plugin, | 32 | GridScreen::handleCompizEvent(const char* plugin, |
41 | @@ -102,7 +85,7 @@ | |||
42 | 102 | void | 85 | void |
43 | 103 | GridScreen::getPaintRectangle (CompRect &cRect) | 86 | GridScreen::getPaintRectangle (CompRect &cRect) |
44 | 104 | { | 87 | { |
46 | 105 | if (edgeToGridType () != GridUnknown && optionGetDrawIndicator ()) | 88 | if (typeToMask (edgeToGridType ()) != GridUnknown && optionGetDrawIndicator ()) |
47 | 106 | cRect = desiredSlot; | 89 | cRect = desiredSlot; |
48 | 107 | else | 90 | else |
49 | 108 | cRect.setGeometry (0, 0, 0, 0); | 91 | cRect.setGeometry (0, 0, 0, 0); |
50 | @@ -137,7 +120,7 @@ | |||
51 | 137 | GridScreen::initiateCommon (CompAction *action, | 120 | GridScreen::initiateCommon (CompAction *action, |
52 | 138 | CompAction::State state, | 121 | CompAction::State state, |
53 | 139 | CompOption::Vector &option, | 122 | CompOption::Vector &option, |
55 | 140 | GridType where, | 123 | unsigned int where, |
56 | 141 | bool resize, | 124 | bool resize, |
57 | 142 | bool key) | 125 | bool key) |
58 | 143 | { | 126 | { |
59 | @@ -162,12 +145,12 @@ | |||
60 | 162 | if (maximizeV && !(cw->actions () & CompWindowActionMaximizeVertMask)) | 145 | if (maximizeV && !(cw->actions () & CompWindowActionMaximizeVertMask)) |
61 | 163 | return false; | 146 | return false; |
62 | 164 | 147 | ||
64 | 165 | if (where == GridUnknown) | 148 | if (where & GridUnknown) |
65 | 166 | return false; | 149 | return false; |
66 | 167 | 150 | ||
67 | 168 | GRID_WINDOW (cw); | 151 | GRID_WINDOW (cw); |
68 | 169 | 152 | ||
70 | 170 | if (gw->lastTarget != where) | 153 | if (gw->lastTarget & ~(where)) |
71 | 171 | gw->resizeCount = 0; | 154 | gw->resizeCount = 0; |
72 | 172 | else if (!key) | 155 | else if (!key) |
73 | 173 | return false; | 156 | return false; |
74 | @@ -197,7 +180,7 @@ | |||
75 | 197 | cw->maximize (0); | 180 | cw->maximize (0); |
76 | 198 | } | 181 | } |
77 | 199 | 182 | ||
79 | 200 | if (where == GridMaximize && resize) | 183 | if ((where & GridMaximize) && resize) |
80 | 201 | { | 184 | { |
81 | 202 | /* move the window to the correct output */ | 185 | /* move the window to the correct output */ |
82 | 203 | if (cw == mGrabWindow) | 186 | if (cw == mGrabWindow) |
83 | @@ -239,7 +222,7 @@ | |||
84 | 239 | 222 | ||
85 | 240 | if (desiredRect.y () == currentRect.y () && | 223 | if (desiredRect.y () == currentRect.y () && |
86 | 241 | desiredRect.height () == currentRect.height () && | 224 | desiredRect.height () == currentRect.height () && |
88 | 242 | where != GridMaximize && gw->lastTarget == where) | 225 | where & ~(GridMaximize) && gw->lastTarget & where) |
89 | 243 | { | 226 | { |
90 | 244 | int slotWidth25 = workarea.width () / 4; | 227 | int slotWidth25 = workarea.width () / 4; |
91 | 245 | int slotWidth33 = (workarea.width () / 3) + cw->border ().left; | 228 | int slotWidth33 = (workarea.width () / 3) + cw->border ().left; |
92 | @@ -358,7 +341,7 @@ | |||
93 | 358 | 341 | ||
94 | 359 | /* Special case for left and right, actually vertically maximize | 342 | /* Special case for left and right, actually vertically maximize |
95 | 360 | * the window */ | 343 | * the window */ |
97 | 361 | if (where == GridLeft || where == GridRight) | 344 | if (where & GridLeft || where & GridRight) |
98 | 362 | { | 345 | { |
99 | 363 | /* First restore the window to its original size */ | 346 | /* First restore the window to its original size */ |
100 | 364 | XWindowChanges rwc; | 347 | XWindowChanges rwc; |
101 | @@ -375,6 +358,7 @@ | |||
102 | 375 | 358 | ||
103 | 376 | gw->lastBorder = cw->border (); | 359 | gw->lastBorder = cw->border (); |
104 | 377 | /* Maximize the window */ | 360 | /* Maximize the window */ |
105 | 361 | printf ("maximizing window\n"); | ||
106 | 378 | cw->maximize (CompWindowStateMaximizedVertMask); | 362 | cw->maximize (CompWindowStateMaximizedVertMask); |
107 | 379 | } | 363 | } |
108 | 380 | else | 364 | else |
109 | @@ -533,39 +517,72 @@ | |||
110 | 533 | return status; | 517 | return status; |
111 | 534 | } | 518 | } |
112 | 535 | 519 | ||
114 | 536 | GridType | 520 | unsigned int |
115 | 521 | GridScreen::typeToMask (int t) | ||
116 | 522 | { | ||
117 | 523 | typedef struct { | ||
118 | 524 | unsigned int mask; | ||
119 | 525 | int type; | ||
120 | 526 | } GridTypeMask; | ||
121 | 527 | |||
122 | 528 | std::vector <GridTypeMask> type = | ||
123 | 529 | { | ||
124 | 530 | { GridWindowType::GridUnknown, 0 }, | ||
125 | 531 | { GridWindowType::GridBottomLeft, 1 }, | ||
126 | 532 | { GridWindowType::GridBottom, 2 }, | ||
127 | 533 | { GridWindowType::GridBottomRight, 3 }, | ||
128 | 534 | { GridWindowType::GridLeft, 4 }, | ||
129 | 535 | { GridWindowType::GridCenter, 5 }, | ||
130 | 536 | { GridWindowType::GridRight, 6 }, | ||
131 | 537 | { GridWindowType::GridTopLeft, 7 }, | ||
132 | 538 | { GridWindowType::GridTop, 8 }, | ||
133 | 539 | { GridWindowType::GridTopRight, 9 }, | ||
134 | 540 | { GridWindowType::GridMaximize, 10 } | ||
135 | 541 | }; | ||
136 | 542 | |||
137 | 543 | for (unsigned int i = 0; i < type.size (); i++) | ||
138 | 544 | { | ||
139 | 545 | GridTypeMask &tm = type[i]; | ||
140 | 546 | if (tm.type == t) | ||
141 | 547 | return tm.mask; | ||
142 | 548 | } | ||
143 | 549 | |||
144 | 550 | return GridWindowType::GridUnknown; | ||
145 | 551 | } | ||
146 | 552 | |||
147 | 553 | int | ||
148 | 537 | GridScreen::edgeToGridType () | 554 | GridScreen::edgeToGridType () |
149 | 538 | { | 555 | { |
151 | 539 | GridType ret; | 556 | int ret; |
152 | 540 | 557 | ||
153 | 541 | switch (edge) { | 558 | switch (edge) { |
154 | 542 | case Left: | 559 | case Left: |
156 | 543 | ret = (GridType) optionGetLeftEdgeAction (); | 560 | ret = (int) optionGetLeftEdgeAction (); |
157 | 544 | break; | 561 | break; |
158 | 545 | case Right: | 562 | case Right: |
160 | 546 | ret = (GridType) optionGetRightEdgeAction (); | 563 | ret = (int) optionGetRightEdgeAction (); |
161 | 547 | break; | 564 | break; |
162 | 548 | case Top: | 565 | case Top: |
164 | 549 | ret = (GridType) optionGetTopEdgeAction (); | 566 | ret = (int) optionGetTopEdgeAction (); |
165 | 550 | break; | 567 | break; |
166 | 551 | case Bottom: | 568 | case Bottom: |
168 | 552 | ret = (GridType) optionGetBottomEdgeAction (); | 569 | ret = (int) optionGetBottomEdgeAction (); |
169 | 553 | break; | 570 | break; |
170 | 554 | case TopLeft: | 571 | case TopLeft: |
172 | 555 | ret = (GridType) optionGetTopLeftCornerAction (); | 572 | ret = (int) optionGetTopLeftCornerAction (); |
173 | 556 | break; | 573 | break; |
174 | 557 | case TopRight: | 574 | case TopRight: |
176 | 558 | ret = (GridType) optionGetTopRightCornerAction (); | 575 | ret = (int) optionGetTopRightCornerAction (); |
177 | 559 | break; | 576 | break; |
178 | 560 | case BottomLeft: | 577 | case BottomLeft: |
180 | 561 | ret = (GridType) optionGetBottomLeftCornerAction (); | 578 | ret = (int) optionGetBottomLeftCornerAction (); |
181 | 562 | break; | 579 | break; |
182 | 563 | case BottomRight: | 580 | case BottomRight: |
184 | 564 | ret = (GridType) optionGetBottomRightCornerAction (); | 581 | ret = (int) optionGetBottomRightCornerAction (); |
185 | 565 | break; | 582 | break; |
186 | 566 | case NoEdge: | 583 | case NoEdge: |
187 | 567 | default: | 584 | default: |
189 | 568 | ret = GridUnknown; | 585 | ret = -1; |
190 | 569 | break; | 586 | break; |
191 | 570 | } | 587 | } |
192 | 571 | 588 | ||
193 | @@ -631,7 +648,7 @@ | |||
194 | 631 | if (cScreen) | 648 | if (cScreen) |
195 | 632 | cScreen->damageRegion (desiredSlot); | 649 | cScreen->damageRegion (desiredSlot); |
196 | 633 | 650 | ||
198 | 634 | initiateCommon (0, 0, o, edgeToGridType (), false, false); | 651 | initiateCommon (0, 0, o, typeToMask (edgeToGridType ()), false, false); |
199 | 635 | 652 | ||
200 | 636 | if (cScreen) | 653 | if (cScreen) |
201 | 637 | cScreen->damageRegion (desiredSlot); | 654 | cScreen->damageRegion (desiredSlot); |
202 | @@ -649,7 +666,7 @@ | |||
203 | 649 | if (cScreen) | 666 | if (cScreen) |
204 | 650 | cScreen->damageRegion (desiredSlot); | 667 | cScreen->damageRegion (desiredSlot); |
205 | 651 | 668 | ||
207 | 652 | check = initiateCommon (0, 0, o, edgeToGridType (), false, false); | 669 | check = initiateCommon (NULL, 0, o, typeToMask (edgeToGridType ()), false, false); |
208 | 653 | 670 | ||
209 | 654 | if (cScreen) | 671 | if (cScreen) |
210 | 655 | cScreen->damageRegion (desiredSlot); | 672 | cScreen->damageRegion (desiredSlot); |
211 | @@ -736,7 +753,7 @@ | |||
212 | 736 | if (window == gScreen->mGrabWindow) | 753 | if (window == gScreen->mGrabWindow) |
213 | 737 | { | 754 | { |
214 | 738 | gScreen->initiateCommon | 755 | gScreen->initiateCommon |
216 | 739 | (0, 0, gScreen->o, gScreen->edgeToGridType (), true, | 756 | (NULL, 0, gScreen->o, gScreen->typeToMask (gScreen->edgeToGridType ()), true, |
217 | 740 | gScreen->edge != gScreen->lastResizeEdge); | 757 | gScreen->edge != gScreen->lastResizeEdge); |
218 | 741 | 758 | ||
219 | 742 | screen->handleEventSetEnabled (gScreen, false); | 759 | screen->handleEventSetEnabled (gScreen, false); |
220 | @@ -770,6 +787,8 @@ | |||
221 | 770 | dx = currentSize.x () - window->geometry ().x (); | 787 | dx = currentSize.x () - window->geometry ().x (); |
222 | 771 | dy = currentSize.y () - window->geometry ().y (); | 788 | dy = currentSize.y () - window->geometry ().y (); |
223 | 772 | 789 | ||
224 | 790 | printf ("offset move\n"); | ||
225 | 791 | |||
226 | 773 | window->move (dx, dy); | 792 | window->move (dx, dy); |
227 | 774 | } | 793 | } |
228 | 775 | } | 794 | } |
229 | @@ -859,6 +878,7 @@ | |||
230 | 859 | xwc.height = gw->originalSize.height (); | 878 | xwc.height = gw->originalSize.height (); |
231 | 860 | cw->maximize (0); | 879 | cw->maximize (0); |
232 | 861 | gw->currentSize = CompRect (); | 880 | gw->currentSize = CompRect (); |
233 | 881 | printf ("attempting snapBack\n"); | ||
234 | 862 | cw->configureXWindow (CWX | CWY | CWWidth | CWHeight, &xwc); | 882 | cw->configureXWindow (CWX | CWY | CWWidth | CWHeight, &xwc); |
235 | 863 | gw->pointerBufDx = 0; | 883 | gw->pointerBufDx = 0; |
236 | 864 | gw->pointerBufDy = 0; | 884 | gw->pointerBufDy = 0; |
237 | @@ -977,6 +997,17 @@ | |||
238 | 977 | edge = lastEdge = lastResizeEdge = NoEdge; | 997 | edge = lastEdge = lastResizeEdge = NoEdge; |
239 | 978 | currentWorkarea = lastWorkarea = screen->getWorkareaForOutput | 998 | currentWorkarea = lastWorkarea = screen->getWorkareaForOutput |
240 | 979 | (screen->outputDeviceForPoint (pointerX, pointerY)); | 999 | (screen->outputDeviceForPoint (pointerX, pointerY)); |
241 | 1000 | gridProps[GridUnknown] = GridProps {0,1, 1,1}; | ||
242 | 1001 | gridProps[GridBottomLeft] = GridProps {0,1, 2,2}; | ||
243 | 1002 | gridProps[GridBottom] = GridProps {0,1, 1,2}; | ||
244 | 1003 | gridProps[GridBottomRight] = GridProps {1,1, 2,2}; | ||
245 | 1004 | gridProps[GridLeft] = GridProps {0,0, 2,1}; | ||
246 | 1005 | gridProps[GridCenter] = GridProps{0,0, 1,1}; | ||
247 | 1006 | gridProps[GridRight] = GridProps {1,0, 2,1}; | ||
248 | 1007 | gridProps[GridTopLeft] = GridProps{0,0, 2,2}; | ||
249 | 1008 | gridProps[GridTop] = GridProps {0,0, 1,2}; | ||
250 | 1009 | gridProps[GridTopRight] = GridProps {0,0, 1,2}; | ||
251 | 1010 | gridProps[GridMaximize] = GridProps {0,0, 1,1}; | ||
252 | 980 | 1011 | ||
253 | 981 | animations.clear (); | 1012 | animations.clear (); |
254 | 982 | 1013 | ||
255 | @@ -984,16 +1015,16 @@ | |||
256 | 984 | optionSet##opt##Initiate (boost::bind (&GridScreen::initiateCommon, this, \ | 1015 | optionSet##opt##Initiate (boost::bind (&GridScreen::initiateCommon, this, \ |
257 | 985 | _1, _2, _3, where, resize, key)) | 1016 | _1, _2, _3, where, resize, key)) |
258 | 986 | 1017 | ||
269 | 987 | GRIDSET (PutCenterKey, GridCenter, true, true); | 1018 | GRIDSET (PutCenterKey, GridWindowType::GridCenter, true, true); |
270 | 988 | GRIDSET (PutLeftKey, GridLeft, true, true); | 1019 | GRIDSET (PutLeftKey, GridWindowType::GridLeft, true, true); |
271 | 989 | GRIDSET (PutRightKey, GridRight, true, true); | 1020 | GRIDSET (PutRightKey, GridWindowType::GridRight, true, true); |
272 | 990 | GRIDSET (PutTopKey, GridTop, true, true); | 1021 | GRIDSET (PutTopKey, GridWindowType::GridTop, true, true); |
273 | 991 | GRIDSET (PutBottomKey, GridBottom, true, true); | 1022 | GRIDSET (PutBottomKey, GridWindowType::GridBottom, true, true); |
274 | 992 | GRIDSET (PutTopleftKey, GridTopLeft, true, true); | 1023 | GRIDSET (PutTopleftKey, GridWindowType::GridTopLeft, true, true); |
275 | 993 | GRIDSET (PutToprightKey, GridTopRight, true, true); | 1024 | GRIDSET (PutToprightKey, GridWindowType::GridTopRight, true, true); |
276 | 994 | GRIDSET (PutBottomleftKey, GridBottomLeft, true, true); | 1025 | GRIDSET (PutBottomleftKey, GridWindowType::GridBottomLeft, true, true); |
277 | 995 | GRIDSET (PutBottomrightKey, GridBottomRight, true, true); | 1026 | GRIDSET (PutBottomrightKey, GridWindowType::GridBottomRight, true, true); |
278 | 996 | GRIDSET (PutMaximizeKey, GridMaximize, true, true); | 1027 | GRIDSET (PutMaximizeKey, GridWindowType::GridMaximize, true, true); |
279 | 997 | 1028 | ||
280 | 998 | #undef GRIDSET | 1029 | #undef GRIDSET |
281 | 999 | 1030 | ||
282 | 1000 | 1031 | ||
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 | 114 | void setCurrentRect (Animation&); | 114 | void setCurrentRect (Animation&); |
288 | 115 | 115 | ||
289 | 116 | bool initiateCommon (CompAction*, CompAction::State, | 116 | bool initiateCommon (CompAction*, CompAction::State, |
291 | 117 | CompOption::Vector&, GridType, bool, bool); | 117 | CompOption::Vector&, unsigned int, bool, bool); |
292 | 118 | 118 | ||
293 | 119 | void glPaintRectangle (const GLScreenPaintAttrib&, | 119 | void glPaintRectangle (const GLScreenPaintAttrib&, |
294 | 120 | const GLMatrix&, CompOutput *); | 120 | const GLMatrix&, CompOutput *); |
295 | @@ -128,7 +128,8 @@ | |||
296 | 128 | 128 | ||
297 | 129 | std::vector <Animation> animations; | 129 | std::vector <Animation> animations; |
298 | 130 | 130 | ||
300 | 131 | GridType edgeToGridType (); | 131 | int edgeToGridType (); |
301 | 132 | unsigned int typeToMask (int); | ||
302 | 132 | 133 | ||
303 | 133 | void handleEvent (XEvent *event); | 134 | void handleEvent (XEvent *event); |
304 | 134 | void handleCompizEvent (const char *plugin, const char *event, CompOption::Vector &options); | 135 | void handleCompizEvent (const char *plugin, const char *event, CompOption::Vector &options); |
Looks good.