Merge lp:~compiz-team/compiz-grid-plugin/oneiric.fix_862339 into lp:compiz-grid-plugin
- oneiric.fix_862339
- Merge into 0.9.5
Proposed by
Sam Spilsbury
Status: | Superseded |
---|---|
Proposed branch: | lp:~compiz-team/compiz-grid-plugin/oneiric.fix_862339 |
Merge into: | lp:compiz-grid-plugin |
Diff against target: |
676 lines (+253/-96) 4 files modified
CMakeLists.txt (+2/-0) grid.xml.in (+14/-14) src/grid.cpp (+212/-67) src/grid.h (+25/-15) |
To merge this branch: | bzr merge lp:~compiz-team/compiz-grid-plugin/oneiric.fix_862339 |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Compiz Maintainers | Pending | ||
Review via email: mp+77516@code.launchpad.net |
This proposal has been superseded by a proposal from 2011-09-29.
Commit message
Description of the change
Fix bug 862339
To post a comment you must log in.
Unmerged revisions
- 91. By Sam Spilsbury
-
Ensure window placement is pixel perfect in the maximization case. Fixes LP#862339
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 12:41:49 +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 'grid.xml.in' | |||
13 | --- grid.xml.in 2010-09-28 22:30:57 +0000 | |||
14 | +++ grid.xml.in 2011-09-29 12:41:49 +0000 | |||
15 | @@ -84,7 +84,7 @@ | |||
16 | 84 | <option name="top_left_corner_action" type="int"> | 84 | <option name="top_left_corner_action" type="int"> |
17 | 85 | <_short>Upper Left Corner</_short> | 85 | <_short>Upper Left Corner</_short> |
18 | 86 | <_long>Action to be performed when window is dropped on the top left corner</_long> | 86 | <_long>Action to be performed when window is dropped on the top left corner</_long> |
20 | 87 | <default>7</default> | 87 | <default>4</default> |
21 | 88 | <min>0</min> | 88 | <min>0</min> |
22 | 89 | <max>10</max> | 89 | <max>10</max> |
23 | 90 | <desc> | 90 | <desc> |
24 | @@ -186,7 +186,7 @@ | |||
25 | 186 | <option name="top_right_corner_action" type="int"> | 186 | <option name="top_right_corner_action" type="int"> |
26 | 187 | <_short>Upper Right Corner</_short> | 187 | <_short>Upper Right Corner</_short> |
27 | 188 | <_long>Action to be performed when window is dropped on the top right corner</_long> | 188 | <_long>Action to be performed when window is dropped on the top right corner</_long> |
29 | 189 | <default>9</default> | 189 | <default>6</default> |
30 | 190 | <min>0</min> | 190 | <min>0</min> |
31 | 191 | <max>10</max> | 191 | <max>10</max> |
32 | 192 | <desc> | 192 | <desc> |
33 | @@ -339,7 +339,7 @@ | |||
34 | 339 | <option name="bottom_left_corner_action" type="int"> | 339 | <option name="bottom_left_corner_action" type="int"> |
35 | 340 | <_short>Bottom Left Corner</_short> | 340 | <_short>Bottom Left Corner</_short> |
36 | 341 | <_long>Action to be performed when window is dropped on the bottom left corner</_long> | 341 | <_long>Action to be performed when window is dropped on the bottom left corner</_long> |
38 | 342 | <default>1</default> | 342 | <default>4</default> |
39 | 343 | <min>0</min> | 343 | <min>0</min> |
40 | 344 | <max>10</max> | 344 | <max>10</max> |
41 | 345 | <desc> | 345 | <desc> |
42 | @@ -390,7 +390,7 @@ | |||
43 | 390 | <option name="bottom_edge_action" type="int"> | 390 | <option name="bottom_edge_action" type="int"> |
44 | 391 | <_short>Bottom Edge</_short> | 391 | <_short>Bottom Edge</_short> |
45 | 392 | <_long>Action to be performed when window is dropped on the bottom edge</_long> | 392 | <_long>Action to be performed when window is dropped on the bottom edge</_long> |
47 | 393 | <default>2</default> | 393 | <default>0</default> |
48 | 394 | <min>0</min> | 394 | <min>0</min> |
49 | 395 | <max>10</max> | 395 | <max>10</max> |
50 | 396 | <desc> | 396 | <desc> |
51 | @@ -441,7 +441,7 @@ | |||
52 | 441 | <option name="bottom_right_corner_action" type="int"> | 441 | <option name="bottom_right_corner_action" type="int"> |
53 | 442 | <_short>Bottom Right Corner</_short> | 442 | <_short>Bottom Right Corner</_short> |
54 | 443 | <_long>Action to be performed when window is dropped on the bottom right corner</_long> | 443 | <_long>Action to be performed when window is dropped on the bottom right corner</_long> |
56 | 444 | <default>3</default> | 444 | <default>6</default> |
57 | 445 | <min>0</min> | 445 | <min>0</min> |
58 | 446 | <max>10</max> | 446 | <max>10</max> |
59 | 447 | <desc> | 447 | <desc> |
60 | @@ -505,21 +505,21 @@ | |||
61 | 505 | <option name="left_edge_threshold" type="int"> | 505 | <option name="left_edge_threshold" type="int"> |
62 | 506 | <_short>Left Edge</_short> | 506 | <_short>Left Edge</_short> |
63 | 507 | <_long>Maximum number of pixels from the left edge a window can be dropped</_long> | 507 | <_long>Maximum number of pixels from the left edge a window can be dropped</_long> |
65 | 508 | <default>5</default> | 508 | <default>15</default> |
66 | 509 | <min>0</min> | 509 | <min>0</min> |
67 | 510 | <max>500</max> | 510 | <max>500</max> |
68 | 511 | </option> | 511 | </option> |
69 | 512 | <option name="right_edge_threshold" type="int"> | 512 | <option name="right_edge_threshold" type="int"> |
70 | 513 | <_short>Right Edge</_short> | 513 | <_short>Right Edge</_short> |
71 | 514 | <_long>Maximum number of pixels from the right edge a window can be dropped</_long> | 514 | <_long>Maximum number of pixels from the right edge a window can be dropped</_long> |
73 | 515 | <default>5</default> | 515 | <default>15</default> |
74 | 516 | <min>0</min> | 516 | <min>0</min> |
75 | 517 | <max>500</max> | 517 | <max>500</max> |
76 | 518 | </option> | 518 | </option> |
77 | 519 | <option name="top_edge_threshold" type="int"> | 519 | <option name="top_edge_threshold" type="int"> |
78 | 520 | <_short>Top Edge</_short> | 520 | <_short>Top Edge</_short> |
79 | 521 | <_long>Maximum number of pixels from the top edge a window can be dropped</_long> | 521 | <_long>Maximum number of pixels from the top edge a window can be dropped</_long> |
81 | 522 | <default>5</default> | 522 | <default>20</default> |
82 | 523 | <min>0</min> | 523 | <min>0</min> |
83 | 524 | <max>500</max> | 524 | <max>500</max> |
84 | 525 | </option> | 525 | </option> |
85 | @@ -543,9 +543,9 @@ | |||
86 | 543 | <_short>Outline Color</_short> | 543 | <_short>Outline Color</_short> |
87 | 544 | <_long>Color of the resize indicator outline</_long> | 544 | <_long>Color of the resize indicator outline</_long> |
88 | 545 | <default> | 545 | <default> |
92 | 546 | <red>0x2f2f</red> | 546 | <red>0xfbfb</red> |
93 | 547 | <green>0x2f2f</green> | 547 | <green>0x8b8b</green> |
94 | 548 | <blue>0x4f4f</blue> | 548 | <blue>0x0</blue> |
95 | 549 | <alpha>0x9f9f</alpha> | 549 | <alpha>0x9f9f</alpha> |
96 | 550 | </default> | 550 | </default> |
97 | 551 | </option> | 551 | </option> |
98 | @@ -553,9 +553,9 @@ | |||
99 | 553 | <_short>Fill Color</_short> | 553 | <_short>Fill Color</_short> |
100 | 554 | <_long>Fill color of the resize indicator</_long> | 554 | <_long>Fill color of the resize indicator</_long> |
101 | 555 | <default> | 555 | <default> |
105 | 556 | <red>0x2f2f</red> | 556 | <red>0xfbfb</red> |
106 | 557 | <green>0x2f2f</green> | 557 | <green>0x8b8b</green> |
107 | 558 | <blue>0x4f4f</blue> | 558 | <blue>0x0</blue> |
108 | 559 | <alpha>0x4f4f</alpha> | 559 | <alpha>0x4f4f</alpha> |
109 | 560 | </default> | 560 | </default> |
110 | 561 | </option> | 561 | </option> |
111 | 562 | 562 | ||
112 | === modified file 'src/grid.cpp' | |||
113 | --- src/grid.cpp 2011-09-24 06:59:55 +0000 | |||
114 | +++ src/grid.cpp 2011-09-29 12:41:49 +0000 | |||
115 | @@ -24,24 +24,26 @@ | |||
116 | 24 | 24 | ||
117 | 25 | #include "grid.h" | 25 | #include "grid.h" |
118 | 26 | 26 | ||
120 | 27 | static const GridProps gridProps[] = | 27 | using namespace GridWindowType; |
121 | 28 | |||
122 | 29 | static std::map <unsigned int, GridProps> gridProps; | ||
123 | 30 | |||
124 | 31 | void | ||
125 | 32 | GridScreen::handleCompizEvent(const char* plugin, | ||
126 | 33 | const char* event, | ||
127 | 34 | CompOption::Vector& o) | ||
128 | 28 | { | 35 | { |
145 | 29 | {0,1, 1,1}, | 36 | if (strcmp(event, "start_viewport_switch") == 0) |
146 | 30 | 37 | { | |
147 | 31 | {0,1, 2,2}, | 38 | mSwitchingVp = true; |
148 | 32 | {0,1, 1,2}, | 39 | } |
149 | 33 | {1,1, 2,2}, | 40 | else if (strcmp(event, "end_viewport_switch") == 0) |
150 | 34 | 41 | { | |
151 | 35 | {0,0, 2,1}, | 42 | mSwitchingVp = false; |
152 | 36 | {0,0, 1,1}, | 43 | } |
153 | 37 | {1,0, 2,1}, | 44 | |
154 | 38 | 45 | screen->handleCompizEvent(plugin, event, o); | |
155 | 39 | {0,0, 2,2}, | 46 | } |
140 | 40 | {0,0, 1,2}, | ||
141 | 41 | {1,0, 2,2}, | ||
142 | 42 | |||
143 | 43 | {0,0, 1,1}, | ||
144 | 44 | }; | ||
156 | 45 | 47 | ||
157 | 46 | CompRect | 48 | CompRect |
158 | 47 | GridScreen::slotToRect (CompWindow *w, | 49 | GridScreen::slotToRect (CompWindow *w, |
159 | @@ -83,7 +85,7 @@ | |||
160 | 83 | void | 85 | void |
161 | 84 | GridScreen::getPaintRectangle (CompRect &cRect) | 86 | GridScreen::getPaintRectangle (CompRect &cRect) |
162 | 85 | { | 87 | { |
164 | 86 | if (edgeToGridType () != GridUnknown && optionGetDrawIndicator ()) | 88 | if (typeToMask (edgeToGridType ()) != GridUnknown && optionGetDrawIndicator ()) |
165 | 87 | cRect = desiredSlot; | 89 | cRect = desiredSlot; |
166 | 88 | else | 90 | else |
167 | 89 | cRect.setGeometry (0, 0, 0, 0); | 91 | cRect.setGeometry (0, 0, 0, 0); |
168 | @@ -118,7 +120,7 @@ | |||
169 | 118 | GridScreen::initiateCommon (CompAction *action, | 120 | GridScreen::initiateCommon (CompAction *action, |
170 | 119 | CompAction::State state, | 121 | CompAction::State state, |
171 | 120 | CompOption::Vector &option, | 122 | CompOption::Vector &option, |
173 | 121 | GridType where, | 123 | unsigned int where, |
174 | 122 | bool resize, | 124 | bool resize, |
175 | 123 | bool key) | 125 | bool key) |
176 | 124 | { | 126 | { |
177 | @@ -128,16 +130,27 @@ | |||
178 | 128 | xid = CompOption::getIntOptionNamed (option, "window"); | 130 | xid = CompOption::getIntOptionNamed (option, "window"); |
179 | 129 | cw = screen->findWindow (xid); | 131 | cw = screen->findWindow (xid); |
180 | 130 | 132 | ||
181 | 131 | if (where == GridUnknown || screen->otherGrabExist ("move", NULL)) | ||
182 | 132 | return false; | ||
183 | 133 | |||
184 | 134 | if (cw) | 133 | if (cw) |
185 | 135 | { | 134 | { |
186 | 136 | XWindowChanges xwc; | 135 | XWindowChanges xwc; |
187 | 136 | bool maximizeH = where & (GridBottom | GridTop | GridMaximize); | ||
188 | 137 | bool maximizeV = where & (GridLeft | GridRight | GridMaximize); | ||
189 | 138 | |||
190 | 139 | if (!(cw->actions () & CompWindowActionResizeMask)) | ||
191 | 140 | return false; | ||
192 | 141 | |||
193 | 142 | if (maximizeH && !(cw->actions () & CompWindowActionMaximizeHorzMask)) | ||
194 | 143 | return false; | ||
195 | 144 | |||
196 | 145 | if (maximizeV && !(cw->actions () & CompWindowActionMaximizeVertMask)) | ||
197 | 146 | return false; | ||
198 | 147 | |||
199 | 148 | if (where & GridUnknown) | ||
200 | 149 | return false; | ||
201 | 137 | 150 | ||
202 | 138 | GRID_WINDOW (cw); | 151 | GRID_WINDOW (cw); |
203 | 139 | 152 | ||
205 | 140 | if (gw->lastTarget != where) | 153 | if (gw->lastTarget & ~(where)) |
206 | 141 | gw->resizeCount = 0; | 154 | gw->resizeCount = 0; |
207 | 142 | else if (!key) | 155 | else if (!key) |
208 | 143 | return false; | 156 | return false; |
209 | @@ -167,7 +180,7 @@ | |||
210 | 167 | cw->maximize (0); | 180 | cw->maximize (0); |
211 | 168 | } | 181 | } |
212 | 169 | 182 | ||
214 | 170 | if (where == GridMaximize && resize) | 183 | if ((where & GridMaximize) && resize) |
215 | 171 | { | 184 | { |
216 | 172 | /* move the window to the correct output */ | 185 | /* move the window to the correct output */ |
217 | 173 | if (cw == mGrabWindow) | 186 | if (cw == mGrabWindow) |
218 | @@ -209,7 +222,7 @@ | |||
219 | 209 | 222 | ||
220 | 210 | if (desiredRect.y () == currentRect.y () && | 223 | if (desiredRect.y () == currentRect.y () && |
221 | 211 | desiredRect.height () == currentRect.height () && | 224 | desiredRect.height () == currentRect.height () && |
223 | 212 | where != GridMaximize && gw->lastTarget == where) | 225 | where & ~(GridMaximize) && gw->lastTarget & where) |
224 | 213 | { | 226 | { |
225 | 214 | int slotWidth25 = workarea.width () / 4; | 227 | int slotWidth25 = workarea.width () / 4; |
226 | 215 | int slotWidth33 = (workarea.width () / 3) + cw->border ().left; | 228 | int slotWidth33 = (workarea.width () / 3) + cw->border ().left; |
227 | @@ -322,12 +335,52 @@ | |||
228 | 322 | /* TODO: animate move+resize */ | 335 | /* TODO: animate move+resize */ |
229 | 323 | if (resize) | 336 | if (resize) |
230 | 324 | { | 337 | { |
236 | 325 | cw->configureXWindow (CWX | CWY | CWWidth | CWHeight, &xwc); | 338 | unsigned int valueMask = CWX | CWY | CWWidth | CWHeight; |
232 | 326 | gw->isGridResized = true; | ||
233 | 327 | gw->isGridMaximized = false; | ||
234 | 328 | for (unsigned int i = 0; i < animations.size (); i++) | ||
235 | 329 | animations.at (i).fadingOut = true; | ||
237 | 330 | gw->lastTarget = where; | 339 | gw->lastTarget = where; |
238 | 340 | gw->currentSize = CompRect (wc.x, wc.y, wc.width, wc.height); | ||
239 | 341 | |||
240 | 342 | /* Special case for left and right, actually vertically maximize | ||
241 | 343 | * the window */ | ||
242 | 344 | if (where & GridLeft || where & GridRight) | ||
243 | 345 | { | ||
244 | 346 | /* First restore the window to its original size */ | ||
245 | 347 | XWindowChanges rwc; | ||
246 | 348 | CompWindowExtents lb = gw->lastBorder; | ||
247 | 349 | |||
248 | 350 | rwc.x = gw->originalSize.x (); | ||
249 | 351 | rwc.y = gw->originalSize.y (); | ||
250 | 352 | rwc.width = gw->originalSize.width (); | ||
251 | 353 | rwc.height = gw->originalSize.height (); | ||
252 | 354 | |||
253 | 355 | cw->configureXWindow (CWX | CWY | CWWidth | CWHeight, &rwc); | ||
254 | 356 | |||
255 | 357 | gw->isGridMaximized = true; | ||
256 | 358 | gw->isGridResized = false; | ||
257 | 359 | |||
258 | 360 | gw->lastBorder = cw->border (); | ||
259 | 361 | /* Maximize the window */ | ||
260 | 362 | cw->maximize (CompWindowStateMaximizedVertMask); | ||
261 | 363 | |||
262 | 364 | /* Adjust for any updated border extents */ | ||
263 | 365 | xwc.x -= lb.left - cw->border ().left; | ||
264 | 366 | xwc.y -= lb.top - cw->border ().top; | ||
265 | 367 | xwc.width += (lb.left - cw->border ().left) + (lb.right - cw->border ().right); | ||
266 | 368 | xwc.height += (lb.top - cw->border ().top) + (lb.bottom - cw->border ().bottom); | ||
267 | 369 | |||
268 | 370 | /* Make window the size that we want */ | ||
269 | 371 | cw->configureXWindow (valueMask, &xwc); | ||
270 | 372 | } | ||
271 | 373 | else | ||
272 | 374 | { | ||
273 | 375 | gw->isGridResized = true; | ||
274 | 376 | gw->isGridMaximized = false; | ||
275 | 377 | |||
276 | 378 | /* Make window the size that we want */ | ||
277 | 379 | cw->configureXWindow (valueMask, &xwc); | ||
278 | 380 | } | ||
279 | 381 | |||
280 | 382 | for (unsigned int i = 0; i < animations.size (); i++) | ||
281 | 383 | animations.at (i).fadingOut = true; | ||
282 | 331 | } | 384 | } |
283 | 332 | 385 | ||
284 | 333 | /* This centers a window if it could not be resized to the desired | 386 | /* This centers a window if it could not be resized to the desired |
285 | @@ -473,39 +526,72 @@ | |||
286 | 473 | return status; | 526 | return status; |
287 | 474 | } | 527 | } |
288 | 475 | 528 | ||
290 | 476 | GridType | 529 | unsigned int |
291 | 530 | GridScreen::typeToMask (int t) | ||
292 | 531 | { | ||
293 | 532 | typedef struct { | ||
294 | 533 | unsigned int mask; | ||
295 | 534 | int type; | ||
296 | 535 | } GridTypeMask; | ||
297 | 536 | |||
298 | 537 | std::vector <GridTypeMask> type = | ||
299 | 538 | { | ||
300 | 539 | { GridWindowType::GridUnknown, 0 }, | ||
301 | 540 | { GridWindowType::GridBottomLeft, 1 }, | ||
302 | 541 | { GridWindowType::GridBottom, 2 }, | ||
303 | 542 | { GridWindowType::GridBottomRight, 3 }, | ||
304 | 543 | { GridWindowType::GridLeft, 4 }, | ||
305 | 544 | { GridWindowType::GridCenter, 5 }, | ||
306 | 545 | { GridWindowType::GridRight, 6 }, | ||
307 | 546 | { GridWindowType::GridTopLeft, 7 }, | ||
308 | 547 | { GridWindowType::GridTop, 8 }, | ||
309 | 548 | { GridWindowType::GridTopRight, 9 }, | ||
310 | 549 | { GridWindowType::GridMaximize, 10 } | ||
311 | 550 | }; | ||
312 | 551 | |||
313 | 552 | for (unsigned int i = 0; i < type.size (); i++) | ||
314 | 553 | { | ||
315 | 554 | GridTypeMask &tm = type[i]; | ||
316 | 555 | if (tm.type == t) | ||
317 | 556 | return tm.mask; | ||
318 | 557 | } | ||
319 | 558 | |||
320 | 559 | return GridWindowType::GridUnknown; | ||
321 | 560 | } | ||
322 | 561 | |||
323 | 562 | int | ||
324 | 477 | GridScreen::edgeToGridType () | 563 | GridScreen::edgeToGridType () |
325 | 478 | { | 564 | { |
327 | 479 | GridType ret; | 565 | int ret; |
328 | 480 | 566 | ||
329 | 481 | switch (edge) { | 567 | switch (edge) { |
330 | 482 | case Left: | 568 | case Left: |
332 | 483 | ret = (GridType) optionGetLeftEdgeAction (); | 569 | ret = (int) optionGetLeftEdgeAction (); |
333 | 484 | break; | 570 | break; |
334 | 485 | case Right: | 571 | case Right: |
336 | 486 | ret = (GridType) optionGetRightEdgeAction (); | 572 | ret = (int) optionGetRightEdgeAction (); |
337 | 487 | break; | 573 | break; |
338 | 488 | case Top: | 574 | case Top: |
340 | 489 | ret = (GridType) optionGetTopEdgeAction (); | 575 | ret = (int) optionGetTopEdgeAction (); |
341 | 490 | break; | 576 | break; |
342 | 491 | case Bottom: | 577 | case Bottom: |
344 | 492 | ret = (GridType) optionGetBottomEdgeAction (); | 578 | ret = (int) optionGetBottomEdgeAction (); |
345 | 493 | break; | 579 | break; |
346 | 494 | case TopLeft: | 580 | case TopLeft: |
348 | 495 | ret = (GridType) optionGetTopLeftCornerAction (); | 581 | ret = (int) optionGetTopLeftCornerAction (); |
349 | 496 | break; | 582 | break; |
350 | 497 | case TopRight: | 583 | case TopRight: |
352 | 498 | ret = (GridType) optionGetTopRightCornerAction (); | 584 | ret = (int) optionGetTopRightCornerAction (); |
353 | 499 | break; | 585 | break; |
354 | 500 | case BottomLeft: | 586 | case BottomLeft: |
356 | 501 | ret = (GridType) optionGetBottomLeftCornerAction (); | 587 | ret = (int) optionGetBottomLeftCornerAction (); |
357 | 502 | break; | 588 | break; |
358 | 503 | case BottomRight: | 589 | case BottomRight: |
360 | 504 | ret = (GridType) optionGetBottomRightCornerAction (); | 590 | ret = (int) optionGetBottomRightCornerAction (); |
361 | 505 | break; | 591 | break; |
362 | 506 | case NoEdge: | 592 | case NoEdge: |
363 | 507 | default: | 593 | default: |
365 | 508 | ret = GridUnknown; | 594 | ret = -1; |
366 | 509 | break; | 595 | break; |
367 | 510 | } | 596 | } |
368 | 511 | 597 | ||
369 | @@ -571,7 +657,7 @@ | |||
370 | 571 | if (cScreen) | 657 | if (cScreen) |
371 | 572 | cScreen->damageRegion (desiredSlot); | 658 | cScreen->damageRegion (desiredSlot); |
372 | 573 | 659 | ||
374 | 574 | initiateCommon (0, 0, o, edgeToGridType (), false, false); | 660 | initiateCommon (0, 0, o, typeToMask (edgeToGridType ()), false, false); |
375 | 575 | 661 | ||
376 | 576 | if (cScreen) | 662 | if (cScreen) |
377 | 577 | cScreen->damageRegion (desiredSlot); | 663 | cScreen->damageRegion (desiredSlot); |
378 | @@ -589,7 +675,7 @@ | |||
379 | 589 | if (cScreen) | 675 | if (cScreen) |
380 | 590 | cScreen->damageRegion (desiredSlot); | 676 | cScreen->damageRegion (desiredSlot); |
381 | 591 | 677 | ||
383 | 592 | check = initiateCommon (0, 0, o, edgeToGridType (), false, false); | 678 | check = initiateCommon (NULL, 0, o, typeToMask (edgeToGridType ()), false, false); |
384 | 593 | 679 | ||
385 | 594 | if (cScreen) | 680 | if (cScreen) |
386 | 595 | cScreen->damageRegion (desiredSlot); | 681 | cScreen->damageRegion (desiredSlot); |
387 | @@ -646,21 +732,22 @@ | |||
388 | 646 | unsigned int state, | 732 | unsigned int state, |
389 | 647 | unsigned int mask) | 733 | unsigned int mask) |
390 | 648 | { | 734 | { |
392 | 649 | if (screen->grabExist ("move")) | 735 | if (mask & (CompWindowGrabMoveMask | CompWindowGrabButtonMask)) |
393 | 650 | { | 736 | { |
394 | 651 | gScreen->o[0].value ().set ((int) window->id ()); | 737 | gScreen->o[0].value ().set ((int) window->id ()); |
395 | 652 | 738 | ||
396 | 653 | screen->handleEventSetEnabled (gScreen, true); | 739 | screen->handleEventSetEnabled (gScreen, true); |
397 | 654 | gScreen->mGrabWindow = window; | 740 | gScreen->mGrabWindow = window; |
398 | 655 | pointerBufDx = pointerBufDy = 0; | 741 | pointerBufDx = pointerBufDy = 0; |
399 | 742 | grabMask = mask; | ||
400 | 656 | 743 | ||
402 | 657 | if (!isGridResized && gScreen->optionGetSnapbackWindows ()) | 744 | if (!isGridResized && !isGridMaximized && gScreen->optionGetSnapbackWindows ()) |
403 | 658 | /* Store size not including borders when grabbing with cursor */ | 745 | /* Store size not including borders when grabbing with cursor */ |
404 | 659 | originalSize = gScreen->slotToRect(window, | 746 | originalSize = gScreen->slotToRect(window, |
405 | 660 | window->serverBorderRect ()); | 747 | window->serverBorderRect ()); |
406 | 661 | } | 748 | } |
407 | 662 | 749 | ||
409 | 663 | if (screen->grabExist ("resize")) | 750 | if (mask & CompWindowGrabResizeMask) |
410 | 664 | { | 751 | { |
411 | 665 | isGridResized = false; | 752 | isGridResized = false; |
412 | 666 | resizeCount = 0; | 753 | resizeCount = 0; |
413 | @@ -675,10 +762,11 @@ | |||
414 | 675 | if (window == gScreen->mGrabWindow) | 762 | if (window == gScreen->mGrabWindow) |
415 | 676 | { | 763 | { |
416 | 677 | gScreen->initiateCommon | 764 | gScreen->initiateCommon |
418 | 678 | (0, 0, gScreen->o, gScreen->edgeToGridType (), true, | 765 | (NULL, 0, gScreen->o, gScreen->typeToMask (gScreen->edgeToGridType ()), true, |
419 | 679 | gScreen->edge != gScreen->lastResizeEdge); | 766 | gScreen->edge != gScreen->lastResizeEdge); |
420 | 680 | 767 | ||
421 | 681 | screen->handleEventSetEnabled (gScreen, false); | 768 | screen->handleEventSetEnabled (gScreen, false); |
422 | 769 | grabMask = 0; | ||
423 | 682 | gScreen->mGrabWindow = NULL; | 770 | gScreen->mGrabWindow = NULL; |
424 | 683 | gScreen->o[0].value ().set (0); | 771 | gScreen->o[0].value ().set (0); |
425 | 684 | gScreen->cScreen->damageRegion (gScreen->desiredSlot); | 772 | gScreen->cScreen->damageRegion (gScreen->desiredSlot); |
426 | @@ -695,17 +783,20 @@ | |||
427 | 695 | { | 783 | { |
428 | 696 | window->moveNotify (dx, dy, immediate); | 784 | window->moveNotify (dx, dy, immediate); |
429 | 697 | 785 | ||
431 | 698 | if (isGridResized) | 786 | if (isGridResized && !isGridMaximized && !GridScreen::get (screen)->mSwitchingVp) |
432 | 699 | { | 787 | { |
435 | 700 | pointerBufDx += dx; | 788 | if (window->grabbed () && (grabMask & CompWindowGrabMoveMask)) |
436 | 701 | pointerBufDy += dy; | 789 | { |
437 | 790 | pointerBufDx += dx; | ||
438 | 791 | pointerBufDy += dy; | ||
439 | 792 | } | ||
440 | 702 | 793 | ||
441 | 703 | /* Do not allow the window to be moved while it | 794 | /* Do not allow the window to be moved while it |
442 | 704 | * is resized */ | 795 | * is resized */ |
443 | 796 | dx = currentSize.x () - window->geometry ().x (); | ||
444 | 797 | dy = currentSize.y () - window->geometry ().y (); | ||
445 | 705 | 798 | ||
449 | 706 | window->moveNotifySetEnabled (this, false); | 799 | window->move (dx, dy); |
447 | 707 | window->move (-dx, -dy); | ||
448 | 708 | window->moveNotifySetEnabled (this, true); | ||
450 | 709 | } | 800 | } |
451 | 710 | } | 801 | } |
452 | 711 | 802 | ||
453 | @@ -717,11 +808,50 @@ | |||
454 | 717 | lastTarget = GridUnknown; | 808 | lastTarget = GridUnknown; |
455 | 718 | else if (!(lastState & MAXIMIZE_STATE) && | 809 | else if (!(lastState & MAXIMIZE_STATE) && |
456 | 719 | window->state () & MAXIMIZE_STATE) | 810 | window->state () & MAXIMIZE_STATE) |
457 | 811 | { | ||
458 | 720 | lastTarget = GridMaximize; | 812 | lastTarget = GridMaximize; |
459 | 813 | if (window->grabbed ()) | ||
460 | 814 | { | ||
461 | 815 | originalSize = gScreen->slotToRect (window, | ||
462 | 816 | window->serverBorderRect ()); | ||
463 | 817 | } | ||
464 | 818 | } | ||
465 | 721 | 819 | ||
466 | 722 | window->stateChangeNotify (lastState); | 820 | window->stateChangeNotify (lastState); |
469 | 723 | } | 821 | } |
470 | 724 | 822 | ||
471 | 823 | void | ||
472 | 824 | GridWindow::windowNotify (CompWindowNotify n) | ||
473 | 825 | { | ||
474 | 826 | if (n == CompWindowNotifyFrameUpdate) | ||
475 | 827 | { | ||
476 | 828 | if (isGridMaximized && (window->state () & MAXIMIZE_STATE)) | ||
477 | 829 | { | ||
478 | 830 | unsigned int valueMask = 0; | ||
479 | 831 | XWindowChanges xwc; | ||
480 | 832 | |||
481 | 833 | int dw = (lastBorder.left + lastBorder.right) - | ||
482 | 834 | (window->border ().left + window->border ().right); | ||
483 | 835 | |||
484 | 836 | int dh = (lastBorder.top + lastBorder.bottom) - | ||
485 | 837 | (window->border ().top + window->border ().bottom); | ||
486 | 838 | |||
487 | 839 | if (dw != 0) | ||
488 | 840 | valueMask |= CWWidth; | ||
489 | 841 | if (dh != 0) | ||
490 | 842 | valueMask |= CWHeight; | ||
491 | 843 | |||
492 | 844 | xwc.width = window->serverGeometry ().width () + dw; | ||
493 | 845 | xwc.height = window->serverGeometry ().height () + dh; | ||
494 | 846 | |||
495 | 847 | window->configureXWindow (valueMask, &xwc); | ||
496 | 848 | } | ||
497 | 849 | |||
498 | 850 | lastBorder = window->border (); | ||
499 | 851 | } | ||
500 | 852 | |||
501 | 853 | window->windowNotify (n); | ||
502 | 854 | } | ||
503 | 725 | bool | 855 | bool |
504 | 726 | GridScreen::restoreWindow (CompAction *action, | 856 | GridScreen::restoreWindow (CompAction *action, |
505 | 727 | CompAction::State state, | 857 | CompAction::State state, |
506 | @@ -755,6 +885,7 @@ | |||
507 | 755 | xwc.width = gw->originalSize.width (); | 885 | xwc.width = gw->originalSize.width (); |
508 | 756 | xwc.height = gw->originalSize.height (); | 886 | xwc.height = gw->originalSize.height (); |
509 | 757 | cw->maximize (0); | 887 | cw->maximize (0); |
510 | 888 | gw->currentSize = CompRect (); | ||
511 | 758 | cw->configureXWindow (CWX | CWY | CWWidth | CWHeight, &xwc); | 889 | cw->configureXWindow (CWX | CWY | CWWidth | CWHeight, &xwc); |
512 | 759 | gw->pointerBufDx = 0; | 890 | gw->pointerBufDx = 0; |
513 | 760 | gw->pointerBufDy = 0; | 891 | gw->pointerBufDy = 0; |
514 | @@ -860,17 +991,30 @@ | |||
515 | 860 | glScreen (GLScreen::get (screen)), | 991 | glScreen (GLScreen::get (screen)), |
516 | 861 | centerCheck (false), | 992 | centerCheck (false), |
517 | 862 | mGrabWindow (NULL), | 993 | mGrabWindow (NULL), |
519 | 863 | animating (false) | 994 | animating (false), |
520 | 995 | mSwitchingVp (false) | ||
521 | 864 | { | 996 | { |
522 | 865 | o.push_back (CompOption ("window", CompOption::TypeInt)); | 997 | o.push_back (CompOption ("window", CompOption::TypeInt)); |
523 | 866 | 998 | ||
524 | 867 | ScreenInterface::setHandler (screen, false); | 999 | ScreenInterface::setHandler (screen, false); |
525 | 1000 | screen->handleCompizEventSetEnabled (this, true); | ||
526 | 868 | CompositeScreenInterface::setHandler (cScreen, false); | 1001 | CompositeScreenInterface::setHandler (cScreen, false); |
527 | 869 | GLScreenInterface::setHandler (glScreen, false); | 1002 | GLScreenInterface::setHandler (glScreen, false); |
528 | 870 | 1003 | ||
529 | 871 | edge = lastEdge = lastResizeEdge = NoEdge; | 1004 | edge = lastEdge = lastResizeEdge = NoEdge; |
530 | 872 | currentWorkarea = lastWorkarea = screen->getWorkareaForOutput | 1005 | currentWorkarea = lastWorkarea = screen->getWorkareaForOutput |
531 | 873 | (screen->outputDeviceForPoint (pointerX, pointerY)); | 1006 | (screen->outputDeviceForPoint (pointerX, pointerY)); |
532 | 1007 | gridProps[GridUnknown] = GridProps {0,1, 1,1}; | ||
533 | 1008 | gridProps[GridBottomLeft] = GridProps {0,1, 2,2}; | ||
534 | 1009 | gridProps[GridBottom] = GridProps {0,1, 1,2}; | ||
535 | 1010 | gridProps[GridBottomRight] = GridProps {1,1, 2,2}; | ||
536 | 1011 | gridProps[GridLeft] = GridProps {0,0, 2,1}; | ||
537 | 1012 | gridProps[GridCenter] = GridProps{0,0, 1,1}; | ||
538 | 1013 | gridProps[GridRight] = GridProps {1,0, 2,1}; | ||
539 | 1014 | gridProps[GridTopLeft] = GridProps{0,0, 2,2}; | ||
540 | 1015 | gridProps[GridTop] = GridProps {0,0, 1,2}; | ||
541 | 1016 | gridProps[GridTopRight] = GridProps {0,0, 1,2}; | ||
542 | 1017 | gridProps[GridMaximize] = GridProps {0,0, 1,1}; | ||
543 | 874 | 1018 | ||
544 | 875 | animations.clear (); | 1019 | animations.clear (); |
545 | 876 | 1020 | ||
546 | @@ -878,16 +1022,16 @@ | |||
547 | 878 | optionSet##opt##Initiate (boost::bind (&GridScreen::initiateCommon, this, \ | 1022 | optionSet##opt##Initiate (boost::bind (&GridScreen::initiateCommon, this, \ |
548 | 879 | _1, _2, _3, where, resize, key)) | 1023 | _1, _2, _3, where, resize, key)) |
549 | 880 | 1024 | ||
560 | 881 | GRIDSET (PutCenterKey, GridCenter, true, true); | 1025 | GRIDSET (PutCenterKey, GridWindowType::GridCenter, true, true); |
561 | 882 | GRIDSET (PutLeftKey, GridLeft, true, true); | 1026 | GRIDSET (PutLeftKey, GridWindowType::GridLeft, true, true); |
562 | 883 | GRIDSET (PutRightKey, GridRight, true, true); | 1027 | GRIDSET (PutRightKey, GridWindowType::GridRight, true, true); |
563 | 884 | GRIDSET (PutTopKey, GridTop, true, true); | 1028 | GRIDSET (PutTopKey, GridWindowType::GridTop, true, true); |
564 | 885 | GRIDSET (PutBottomKey, GridBottom, true, true); | 1029 | GRIDSET (PutBottomKey, GridWindowType::GridBottom, true, true); |
565 | 886 | GRIDSET (PutTopleftKey, GridTopLeft, true, true); | 1030 | GRIDSET (PutTopleftKey, GridWindowType::GridTopLeft, true, true); |
566 | 887 | GRIDSET (PutToprightKey, GridTopRight, true, true); | 1031 | GRIDSET (PutToprightKey, GridWindowType::GridTopRight, true, true); |
567 | 888 | GRIDSET (PutBottomleftKey, GridBottomLeft, true, true); | 1032 | GRIDSET (PutBottomleftKey, GridWindowType::GridBottomLeft, true, true); |
568 | 889 | GRIDSET (PutBottomrightKey, GridBottomRight, true, true); | 1033 | GRIDSET (PutBottomrightKey, GridWindowType::GridBottomRight, true, true); |
569 | 890 | GRIDSET (PutMaximizeKey, GridMaximize, true, true); | 1034 | GRIDSET (PutMaximizeKey, GridWindowType::GridMaximize, true, true); |
570 | 891 | 1035 | ||
571 | 892 | #undef GRIDSET | 1036 | #undef GRIDSET |
572 | 893 | 1037 | ||
573 | @@ -905,10 +1049,11 @@ | |||
574 | 905 | gScreen (GridScreen::get (screen)), | 1049 | gScreen (GridScreen::get (screen)), |
575 | 906 | isGridResized (false), | 1050 | isGridResized (false), |
576 | 907 | isGridMaximized (false), | 1051 | isGridMaximized (false), |
577 | 1052 | grabMask (0), | ||
578 | 908 | pointerBufDx (0), | 1053 | pointerBufDx (0), |
579 | 909 | pointerBufDy (0), | 1054 | pointerBufDy (0), |
580 | 910 | resizeCount (0), | 1055 | resizeCount (0), |
582 | 911 | lastTarget (GridUnknown) | 1056 | lastTarget (GridWindowType::GridUnknown) |
583 | 912 | { | 1057 | { |
584 | 913 | WindowInterface::setHandler (window); | 1058 | WindowInterface::setHandler (window); |
585 | 914 | } | 1059 | } |
586 | 915 | 1060 | ||
587 | === modified file 'src/grid.h' | |||
588 | --- src/grid.h 2011-09-24 06:59:55 +0000 | |||
589 | +++ src/grid.h 2011-09-29 12:41:49 +0000 | |||
590 | @@ -32,20 +32,22 @@ | |||
591 | 32 | 32 | ||
592 | 33 | #define SNAPOFF_THRESHOLD 50 | 33 | #define SNAPOFF_THRESHOLD 50 |
593 | 34 | 34 | ||
595 | 35 | typedef enum | 35 | namespace GridWindowType |
596 | 36 | { | 36 | { |
609 | 37 | GridUnknown = 0, | 37 | static const unsigned int GridUnknown = (1 << 0); |
610 | 38 | GridBottomLeft = 1, | 38 | static const unsigned int GridBottomLeft = (1 << 1); |
611 | 39 | GridBottom = 2, | 39 | static const unsigned int GridBottom = (1 << 2); |
612 | 40 | GridBottomRight = 3, | 40 | static const unsigned int GridBottomRight = (1 << 3); |
613 | 41 | GridLeft = 4, | 41 | static const unsigned int GridLeft = (1 << 4); |
614 | 42 | GridCenter = 5, | 42 | static const unsigned int GridCenter = (1 << 5); |
615 | 43 | GridRight = 6, | 43 | static const unsigned int GridRight = (1 << 6); |
616 | 44 | GridTopLeft = 7, | 44 | static const unsigned int GridTopLeft = (1 << 7); |
617 | 45 | GridTop = 8, | 45 | static const unsigned int GridTop = (1 << 8); |
618 | 46 | GridTopRight = 9, | 46 | static const unsigned int GridTopRight = (1 << 9); |
619 | 47 | GridMaximize = 10 | 47 | static const unsigned int GridMaximize = (1 << 10); |
620 | 48 | } GridType; | 48 | }; |
621 | 49 | |||
622 | 50 | typedef unsigned int GridType; | ||
623 | 49 | 51 | ||
624 | 50 | typedef struct _GridProps | 52 | typedef struct _GridProps |
625 | 51 | { | 53 | { |
626 | @@ -106,12 +108,13 @@ | |||
627 | 106 | bool centerCheck; | 108 | bool centerCheck; |
628 | 107 | CompWindow *mGrabWindow; | 109 | CompWindow *mGrabWindow; |
629 | 108 | bool animating; | 110 | bool animating; |
630 | 111 | bool mSwitchingVp; | ||
631 | 109 | 112 | ||
632 | 110 | void getPaintRectangle (CompRect&); | 113 | void getPaintRectangle (CompRect&); |
633 | 111 | void setCurrentRect (Animation&); | 114 | void setCurrentRect (Animation&); |
634 | 112 | 115 | ||
635 | 113 | bool initiateCommon (CompAction*, CompAction::State, | 116 | bool initiateCommon (CompAction*, CompAction::State, |
637 | 114 | CompOption::Vector&, GridType, bool, bool); | 117 | CompOption::Vector&, unsigned int, bool, bool); |
638 | 115 | 118 | ||
639 | 116 | void glPaintRectangle (const GLScreenPaintAttrib&, | 119 | void glPaintRectangle (const GLScreenPaintAttrib&, |
640 | 117 | const GLMatrix&, CompOutput *); | 120 | const GLMatrix&, CompOutput *); |
641 | @@ -125,9 +128,11 @@ | |||
642 | 125 | 128 | ||
643 | 126 | std::vector <Animation> animations; | 129 | std::vector <Animation> animations; |
644 | 127 | 130 | ||
646 | 128 | GridType edgeToGridType (); | 131 | int edgeToGridType (); |
647 | 132 | unsigned int typeToMask (int); | ||
648 | 129 | 133 | ||
649 | 130 | void handleEvent (XEvent *event); | 134 | void handleEvent (XEvent *event); |
650 | 135 | void handleCompizEvent (const char *plugin, const char *event, CompOption::Vector &options); | ||
651 | 131 | 136 | ||
652 | 132 | bool restoreWindow (CompAction*, | 137 | bool restoreWindow (CompAction*, |
653 | 133 | CompAction::State, | 138 | CompAction::State, |
654 | @@ -158,10 +163,13 @@ | |||
655 | 158 | 163 | ||
656 | 159 | bool isGridResized; | 164 | bool isGridResized; |
657 | 160 | bool isGridMaximized; | 165 | bool isGridMaximized; |
658 | 166 | unsigned int grabMask; | ||
659 | 161 | int pointerBufDx; | 167 | int pointerBufDx; |
660 | 162 | int pointerBufDy; | 168 | int pointerBufDy; |
661 | 163 | int resizeCount; | 169 | int resizeCount; |
662 | 170 | CompRect currentSize; | ||
663 | 164 | CompRect originalSize; | 171 | CompRect originalSize; |
664 | 172 | CompWindowExtents lastBorder; | ||
665 | 165 | GridType lastTarget; | 173 | GridType lastTarget; |
666 | 166 | 174 | ||
667 | 167 | void grabNotify (int, int, unsigned int, unsigned int); | 175 | void grabNotify (int, int, unsigned int, unsigned int); |
668 | @@ -171,6 +179,8 @@ | |||
669 | 171 | void moveNotify (int, int, bool); | 179 | void moveNotify (int, int, bool); |
670 | 172 | 180 | ||
671 | 173 | void stateChangeNotify (unsigned int); | 181 | void stateChangeNotify (unsigned int); |
672 | 182 | |||
673 | 183 | void windowNotify (CompWindowNotify n); | ||
674 | 174 | }; | 184 | }; |
675 | 175 | 185 | ||
676 | 176 | #define GRID_WINDOW(w) \ | 186 | #define GRID_WINDOW(w) \ |