Merge lp:~dbarth/compiz/reworked-fix-744104 into lp:~unity-team/compiz/trunk
- reworked-fix-744104
- Merge into trunk
Proposed by
David Barth
Status: | Merged |
---|---|
Merged at revision: | 2736 |
Proposed branch: | lp:~dbarth/compiz/reworked-fix-744104 |
Merge into: | lp:~unity-team/compiz/trunk |
Diff against target: |
921 lines (+541/-84) 3 files modified
plugins/grid/grid.xml.in (+31/-0) plugins/grid/src/grid.cpp (+416/-80) plugins/grid/src/grid.h (+94/-4) |
To merge this branch: | bzr merge lp:~dbarth/compiz/reworked-fix-744104 |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Unity Team | Pending | ||
Review via email: mp+56583@code.launchpad.net |
Commit message
Description of the change
Re-worked version of sam's original patch, to make it apply to the current trunk
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 'plugins/grid/grid.xml.in' | |||
2 | --- plugins/grid/grid.xml.in 2011-04-05 13:32:45 +0000 | |||
3 | +++ plugins/grid/grid.xml.in 2011-04-06 14:53:28 +0000 | |||
4 | @@ -556,6 +556,37 @@ | |||
5 | 556 | <alpha>0x4f4f</alpha> | 556 | <alpha>0x4f4f</alpha> |
6 | 557 | </default> | 557 | </default> |
7 | 558 | </option> | 558 | </option> |
8 | 559 | <option name="indicator_direction" type="int"> | ||
9 | 560 | <_short>Indicator direction</_short> | ||
10 | 561 | <_long>Where the indicator should come from on-screen</_long> | ||
11 | 562 | <default>0</default> | ||
12 | 563 | <min>0</min> | ||
13 | 564 | <max>1</max> | ||
14 | 565 | <desc> | ||
15 | 566 | <value>0</value> | ||
16 | 567 | <_name>From Window</_name> | ||
17 | 568 | </desc> | ||
18 | 569 | <desc> | ||
19 | 570 | <value>1</value> | ||
20 | 571 | <_name>From Edge</_name> | ||
21 | 572 | </desc> | ||
22 | 573 | </option> | ||
23 | 574 | <option name="indicator_type" type="int"> | ||
24 | 575 | <_short>Indicator type</_short> | ||
25 | 576 | <_long>Appearance of the indicator</_long> | ||
26 | 577 | <default>0</default> | ||
27 | 578 | <min>0</min> | ||
28 | 579 | <max>0</max> | ||
29 | 580 | <desc> | ||
30 | 581 | <value>0</value> | ||
31 | 582 | <_name>Outline</_name> | ||
32 | 583 | </desc> | ||
33 | 584 | </option> | ||
34 | 585 | <option name="behind_window" type="bool"> | ||
35 | 586 | <_short>Behind window</_short> | ||
36 | 587 | <_long>Draw indicator behind window</_long> | ||
37 | 588 | <default>true</default> | ||
38 | 589 | </option> | ||
39 | 559 | </group> | 590 | </group> |
40 | 560 | </options> | 591 | </options> |
41 | 561 | </plugin> | 592 | </plugin> |
42 | 562 | 593 | ||
43 | === modified file 'plugins/grid/src/grid.cpp' | |||
44 | --- plugins/grid/src/grid.cpp 2011-04-05 13:32:45 +0000 | |||
45 | +++ plugins/grid/src/grid.cpp 2011-04-06 14:53:28 +0000 | |||
46 | @@ -127,7 +127,7 @@ | |||
47 | 127 | if (edgeToGridType () != GridUnknown && optionGetDrawIndicator () && | 127 | if (edgeToGridType () != GridUnknown && optionGetDrawIndicator () && |
48 | 128 | gw->allowGrid (edgeToGridType ())) | 128 | gw->allowGrid (edgeToGridType ())) |
49 | 129 | { | 129 | { |
51 | 130 | cRect = gw->constrainSize (desiredSlot); | 130 | cRect = gw->constrainSize (*desiredSlot); |
52 | 131 | } | 131 | } |
53 | 132 | else | 132 | else |
54 | 133 | cRect.setGeometry (0, 0, 0, 0); | 133 | cRect.setGeometry (0, 0, 0, 0); |
55 | @@ -146,7 +146,17 @@ | |||
56 | 146 | xid = CompOption::getIntOptionNamed (option, "window"); | 146 | xid = CompOption::getIntOptionNamed (option, "window"); |
57 | 147 | cw = screen->findWindow (xid); | 147 | cw = screen->findWindow (xid); |
58 | 148 | 148 | ||
60 | 149 | if (where == GridUnknown || screen->otherGrabExist ("move", NULL)) | 149 | if (where == GridUnknown) |
61 | 150 | { | ||
62 | 151 | if (desiredSlot) | ||
63 | 152 | { | ||
64 | 153 | delete desiredSlot; | ||
65 | 154 | desiredSlot = NULL; | ||
66 | 155 | } | ||
67 | 156 | |||
68 | 157 | return false; | ||
69 | 158 | } | ||
70 | 159 | else if (screen->otherGrabExist ("move", NULL)) | ||
71 | 150 | return false; | 160 | return false; |
72 | 151 | 161 | ||
73 | 152 | if (cw) | 162 | if (cw) |
74 | @@ -155,6 +165,9 @@ | |||
75 | 155 | 165 | ||
76 | 156 | GRID_WINDOW (cw); | 166 | GRID_WINDOW (cw); |
77 | 157 | 167 | ||
78 | 168 | if (!gw->allowGrid (where)) | ||
79 | 169 | return false; | ||
80 | 170 | |||
81 | 158 | if (gw->lastTarget != where) | 171 | if (gw->lastTarget != where) |
82 | 159 | gw->resizeCount = 0; | 172 | gw->resizeCount = 0; |
83 | 160 | 173 | ||
84 | @@ -199,6 +212,41 @@ | |||
85 | 199 | return true; | 212 | return true; |
86 | 200 | } | 213 | } |
87 | 201 | 214 | ||
88 | 215 | /* Should really be three different types here, but not enough time | ||
89 | 216 | * to implement that one FIXME */ | ||
90 | 217 | if (!desiredSlot) | ||
91 | 218 | { | ||
92 | 219 | if (resize) | ||
93 | 220 | { | ||
94 | 221 | desiredSlot = new PaintableAnimatedGridRectangle (); | ||
95 | 222 | |||
96 | 223 | if (!desiredSlot) | ||
97 | 224 | return false; | ||
98 | 225 | } | ||
99 | 226 | else | ||
100 | 227 | { | ||
101 | 228 | CompRect sbr = cw->serverBorderRect (); | ||
102 | 229 | if (compositingActive) | ||
103 | 230 | { | ||
104 | 231 | CompRect sbr = cw->serverBorderRect (); | ||
105 | 232 | desiredSlot = new PaintableAnimatedGridRectangle (); | ||
106 | 233 | |||
107 | 234 | if (!desiredSlot) | ||
108 | 235 | return false; | ||
109 | 236 | } | ||
110 | 237 | else | ||
111 | 238 | { | ||
112 | 239 | desiredSlot = new PaintableAnimatedGridRectangle (); | ||
113 | 240 | |||
114 | 241 | if (!desiredSlot) | ||
115 | 242 | return false; | ||
116 | 243 | } | ||
117 | 244 | |||
118 | 245 | ((AnimatedGridRectangle *) desiredSlot)->setFrom (sbr); | ||
119 | 246 | } | ||
120 | 247 | } | ||
121 | 248 | |||
122 | 249 | |||
123 | 202 | /* Convention: | 250 | /* Convention: |
124 | 203 | * xxxSlot include decorations (it's the screen area occupied) | 251 | * xxxSlot include decorations (it's the screen area occupied) |
125 | 204 | * xxxRect are undecorated (it's the constrained position | 252 | * xxxRect are undecorated (it's the constrained position |
126 | @@ -206,15 +254,15 @@ | |||
127 | 206 | */ | 254 | */ |
128 | 207 | 255 | ||
129 | 208 | /* slice and dice to get desired slot - including decorations */ | 256 | /* slice and dice to get desired slot - including decorations */ |
131 | 209 | desiredSlot.setY (workarea.y () + props.gravityDown * | 257 | desiredSlot->setY (workarea.y () + props.gravityDown * |
132 | 210 | (workarea.height () / props.numCellsY)); | 258 | (workarea.height () / props.numCellsY)); |
135 | 211 | desiredSlot.setHeight (workarea.height () / props.numCellsY); | 259 | desiredSlot->setHeight (workarea.height () / props.numCellsY); |
136 | 212 | desiredSlot.setX (workarea.x () + props.gravityRight * | 260 | desiredSlot->setX (workarea.x () + props.gravityRight * |
137 | 213 | (workarea.width () / props.numCellsX)); | 261 | (workarea.width () / props.numCellsX)); |
139 | 214 | desiredSlot.setWidth (workarea.width () / props.numCellsX); | 262 | desiredSlot->setWidth (workarea.width () / props.numCellsX); |
140 | 215 | 263 | ||
141 | 216 | /* Adjust for constraints and decorations */ | 264 | /* Adjust for constraints and decorations */ |
143 | 217 | desiredRect = gw->constrainSize (desiredSlot).subtractBorders (cw); | 265 | desiredRect = gw->constrainSize (*desiredSlot).subtractBorders (cw); |
144 | 218 | /* Get current rect not including decorations */ | 266 | /* Get current rect not including decorations */ |
145 | 219 | currentRect.setGeometry (cw->serverX (), cw->serverY (), | 267 | currentRect.setGeometry (cw->serverX (), cw->serverY (), |
146 | 220 | cw->serverWidth (), | 268 | cw->serverWidth (), |
147 | @@ -243,8 +291,8 @@ | |||
148 | 243 | switch (gw->resizeCount) | 291 | switch (gw->resizeCount) |
149 | 244 | { | 292 | { |
150 | 245 | case 1: | 293 | case 1: |
153 | 246 | desiredSlot.setWidth (slotWidth66); | 294 | desiredSlot->setWidth (slotWidth66); |
154 | 247 | desiredSlot.setX (workarea.x () + | 295 | desiredSlot->setX (workarea.x () + |
155 | 248 | props.gravityRight * slotWidth33); | 296 | props.gravityRight * slotWidth33); |
156 | 249 | gw->resizeCount++; | 297 | gw->resizeCount++; |
157 | 250 | break; | 298 | break; |
158 | @@ -252,20 +300,20 @@ | |||
159 | 252 | gw->resizeCount++; | 300 | gw->resizeCount++; |
160 | 253 | break; | 301 | break; |
161 | 254 | case 3: | 302 | case 3: |
164 | 255 | desiredSlot.setWidth (slotWidth33); | 303 | desiredSlot->setWidth (slotWidth33); |
165 | 256 | desiredSlot.setX (workarea.x () + | 304 | desiredSlot->setX (workarea.x () + |
166 | 257 | props.gravityRight * slotWidth66); | 305 | props.gravityRight * slotWidth66); |
167 | 258 | gw->resizeCount++; | 306 | gw->resizeCount++; |
168 | 259 | break; | 307 | break; |
169 | 260 | case 4: | 308 | case 4: |
172 | 261 | desiredSlot.setWidth (slotWidth25); | 309 | desiredSlot->setWidth (slotWidth25); |
173 | 262 | desiredSlot.setX (workarea.x () + | 310 | desiredSlot->setX (workarea.x () + |
174 | 263 | props.gravityRight * slotWidth75); | 311 | props.gravityRight * slotWidth75); |
175 | 264 | gw->resizeCount++; | 312 | gw->resizeCount++; |
176 | 265 | break; | 313 | break; |
177 | 266 | case 5: | 314 | case 5: |
180 | 267 | desiredSlot.setWidth (slotWidth75); | 315 | desiredSlot->setWidth (slotWidth75); |
181 | 268 | desiredSlot.setX (workarea.x () + | 316 | desiredSlot->setX (workarea.x () + |
182 | 269 | props.gravityRight * slotWidth25); | 317 | props.gravityRight * slotWidth25); |
183 | 270 | gw->resizeCount++; | 318 | gw->resizeCount++; |
184 | 271 | break; | 319 | break; |
185 | @@ -284,27 +332,27 @@ | |||
186 | 284 | switch (gw->resizeCount) | 332 | switch (gw->resizeCount) |
187 | 285 | { | 333 | { |
188 | 286 | case 1: | 334 | case 1: |
190 | 287 | desiredSlot.setWidth (workarea.width () - | 335 | desiredSlot->setWidth (workarea.width () - |
191 | 288 | (slotWidth17 * 2)); | 336 | (slotWidth17 * 2)); |
193 | 289 | desiredSlot.setX (workarea.x () + slotWidth17); | 337 | desiredSlot->setX (workarea.x () + slotWidth17); |
194 | 290 | gw->resizeCount++; | 338 | gw->resizeCount++; |
195 | 291 | break; | 339 | break; |
196 | 292 | case 2: | 340 | case 2: |
198 | 293 | desiredSlot.setWidth ((slotWidth25 * 2) + | 341 | desiredSlot->setWidth ((slotWidth25 * 2) + |
199 | 294 | (slotWidth17 * 2)); | 342 | (slotWidth17 * 2)); |
201 | 295 | desiredSlot.setX (workarea.x () + | 343 | desiredSlot->setX (workarea.x () + |
202 | 296 | (slotWidth25 - slotWidth17)); | 344 | (slotWidth25 - slotWidth17)); |
203 | 297 | gw->resizeCount++; | 345 | gw->resizeCount++; |
204 | 298 | break; | 346 | break; |
205 | 299 | case 3: | 347 | case 3: |
208 | 300 | desiredSlot.setWidth ((slotWidth25 * 2)); | 348 | desiredSlot->setWidth ((slotWidth25 * 2)); |
209 | 301 | desiredSlot.setX (workarea.x () + slotWidth25); | 349 | desiredSlot->setX (workarea.x () + slotWidth25); |
210 | 302 | gw->resizeCount++; | 350 | gw->resizeCount++; |
211 | 303 | break; | 351 | break; |
212 | 304 | case 4: | 352 | case 4: |
214 | 305 | desiredSlot.setWidth (slotWidth33 - | 353 | desiredSlot->setWidth (slotWidth33 - |
215 | 306 | (cw->border ().left + cw->border ().right)); | 354 | (cw->border ().left + cw->border ().right)); |
217 | 307 | desiredSlot.setX (workarea.x () + slotWidth33); | 355 | desiredSlot->setX (workarea.x () + slotWidth33); |
218 | 308 | gw->resizeCount++; | 356 | gw->resizeCount++; |
219 | 309 | break; | 357 | break; |
220 | 310 | case 5: | 358 | case 5: |
221 | @@ -318,7 +366,7 @@ | |||
222 | 318 | if (gw->resizeCount == 6) | 366 | if (gw->resizeCount == 6) |
223 | 319 | gw->resizeCount = 1; | 367 | gw->resizeCount = 1; |
224 | 320 | 368 | ||
226 | 321 | desiredRect = gw->constrainSize (desiredSlot).subtractBorders (cw); | 369 | desiredRect = gw->constrainSize (*desiredSlot).subtractBorders (cw); |
227 | 322 | } | 370 | } |
228 | 323 | 371 | ||
229 | 324 | /* TODO: animate move+resize */ | 372 | /* TODO: animate move+resize */ |
230 | @@ -336,6 +384,9 @@ | |||
231 | 336 | if (cw->mapNum ()) | 384 | if (cw->mapNum ()) |
232 | 337 | cw->sendSyncRequest (); | 385 | cw->sendSyncRequest (); |
233 | 338 | 386 | ||
234 | 387 | delete desiredSlot; | ||
235 | 388 | desiredSlot = NULL; | ||
236 | 389 | |||
237 | 339 | cw->configureXWindow (flags, &xwc); | 390 | cw->configureXWindow (flags, &xwc); |
238 | 340 | gw->isGridResized = true; | 391 | gw->isGridResized = true; |
239 | 341 | gw->isGridMaximized = false; | 392 | gw->isGridMaximized = false; |
240 | @@ -347,48 +398,102 @@ | |||
241 | 347 | return true; | 398 | return true; |
242 | 348 | } | 399 | } |
243 | 349 | 400 | ||
286 | 350 | void | 401 | CompRect |
287 | 351 | GridScreen::glPaintRectangle (const GLScreenPaintAttrib &sAttrib, | 402 | AnimatedGridRectangle::current () |
288 | 352 | const GLMatrix &transform, | 403 | { |
289 | 353 | CompOutput *output) | 404 | /* Expand edges out to destination rect based on progress */ |
290 | 354 | { | 405 | |
291 | 355 | CompRect rect; | 406 | CompRect ret = mFrom; |
292 | 356 | GLMatrix sTransform (transform); | 407 | |
293 | 357 | 408 | ret.setTop (floor (mFrom.top () + (top () - mFrom.top ()) * mProgress)); | |
294 | 358 | getPaintRectangle (rect); | 409 | ret.setLeft (floor (mFrom.left () + (left () - mFrom.left ()) * mProgress)); |
295 | 359 | 410 | ret.setRight (floor (mFrom.right () + (right () - mFrom.right ()) * mProgress)); | |
296 | 360 | glPushMatrix (); | 411 | ret.setBottom (floor (mFrom.bottom () + (bottom () - mFrom.bottom ()) * mProgress)); |
297 | 361 | 412 | ||
298 | 362 | sTransform.toScreenSpace (output, -DEFAULT_Z_CAMERA); | 413 | return ret; |
299 | 363 | 414 | } | |
300 | 364 | glLoadMatrixf (sTransform.getMatrix ()); | 415 | |
301 | 365 | 416 | float | |
302 | 366 | glDisableClientState (GL_TEXTURE_COORD_ARRAY); | 417 | AnimatedGridRectangle::progress () |
303 | 367 | glEnable (GL_BLEND); | 418 | { |
304 | 368 | 419 | return mProgress; | |
305 | 369 | /* fill rectangle */ | 420 | } |
306 | 370 | glColor4usv (optionGetFillColor ()); | 421 | |
307 | 371 | glRecti (rect.x1 (), rect.y2 (), rect.x2 (), rect.y1 ()); | 422 | void |
308 | 372 | 423 | AnimatedGridRectangle::setTime (unsigned int t) | |
309 | 373 | /* Set outline rect smaller to avoid damage issues */ | 424 | { |
310 | 374 | rect.setGeometry (rect.x () + 1, rect.y () + 1, | 425 | mTime = t; |
311 | 375 | rect.width () - 2, rect.height () - 2); | 426 | } |
312 | 376 | 427 | ||
313 | 377 | /* draw outline */ | 428 | void |
314 | 378 | glColor4usv (optionGetOutlineColor ()); | 429 | AnimatedGridRectangle::setFrom (CompRect &f) |
315 | 379 | glLineWidth (2.0); | 430 | { |
316 | 380 | glBegin (GL_LINE_LOOP); | 431 | mFrom = f; |
317 | 381 | glVertex2i (rect.x1 (), rect.y1 ()); | 432 | } |
318 | 382 | glVertex2i (rect.x2 (), rect.y1 ()); | 433 | |
319 | 383 | glVertex2i (rect.x2 (), rect.y2 ()); | 434 | void |
320 | 384 | glVertex2i (rect.x1 (), rect.y2 ()); | 435 | AnimatedGridRectangle::setProgress (float p) |
321 | 385 | glEnd (); | 436 | { |
322 | 386 | 437 | mProgress = p; | |
323 | 387 | /* clean up */ | 438 | |
324 | 388 | glColor4usv (defaultColor); | 439 | if (mProgress >= 1.0f) |
325 | 389 | glDisable (GL_BLEND); | 440 | mProgress = 1.0f; |
326 | 390 | glEnableClientState (GL_TEXTURE_COORD_ARRAY); | 441 | else if (mProgress <= 0.0f) |
327 | 391 | glPopMatrix (); | 442 | mProgress = 0.0f; |
328 | 443 | } | ||
329 | 444 | |||
330 | 445 | void | ||
331 | 446 | AnimatedGridRectangle::reset () | ||
332 | 447 | { | ||
333 | 448 | mProgress = 0.0f; | ||
334 | 449 | } | ||
335 | 450 | |||
336 | 451 | void | ||
337 | 452 | PaintableAnimatedGridRectangle::paint (const GLMatrix &mat) | ||
338 | 453 | { | ||
339 | 454 | CompRect outline; | ||
340 | 455 | CompRect fill = current (); | ||
341 | 456 | GridScreen *gScreen = GridScreen::get (screen); | ||
342 | 457 | |||
343 | 458 | if (gScreen->optionGetIndicatorType () == GridOptions::IndicatorTypeOutline) | ||
344 | 459 | { | ||
345 | 460 | glPushMatrix (); | ||
346 | 461 | |||
347 | 462 | glLoadMatrixf (mat.getMatrix ()); | ||
348 | 463 | |||
349 | 464 | glDisableClientState (GL_TEXTURE_COORD_ARRAY); | ||
350 | 465 | glEnable (GL_BLEND); | ||
351 | 466 | |||
352 | 467 | /* fill rectangle */ | ||
353 | 468 | glColor4f ((float) gScreen->optionGetFillColorRed () / 65535.0f, | ||
354 | 469 | (float) gScreen->optionGetFillColorGreen () / 65535.0f, | ||
355 | 470 | (float) gScreen->optionGetFillColorBlue () / 65535.0f, | ||
356 | 471 | ((float) gScreen->optionGetFillColorAlpha () / 65535.0f) * progress ()); | ||
357 | 472 | glRecti (fill.x1 (), fill.y2 (), fill.x2 (), fill.y1 ()); | ||
358 | 473 | |||
359 | 474 | /* Set outline rect smaller to avoid damage issues */ | ||
360 | 475 | outline.setGeometry (fill.x () + 1, fill.y () + 1, | ||
361 | 476 | fill.width () - 2,fill. height () - 2); | ||
362 | 477 | |||
363 | 478 | /* draw outline */ | ||
364 | 479 | glColor4f ((float) gScreen->optionGetOutlineColorRed () / 65535.0f, | ||
365 | 480 | (float) gScreen->optionGetOutlineColorGreen () / 65535.0f, | ||
366 | 481 | (float) gScreen->optionGetOutlineColorBlue () / 65535.0f, | ||
367 | 482 | ((float) gScreen->optionGetOutlineColorAlpha () / 65535.0f) * progress ()); | ||
368 | 483 | glLineWidth (2.0); | ||
369 | 484 | glBegin (GL_LINE_LOOP); | ||
370 | 485 | glVertex2i (outline.x1 (), outline.y1 ()); | ||
371 | 486 | glVertex2i (outline.x2 (), outline.y1 ()); | ||
372 | 487 | glVertex2i (outline.x2 (), outline.y2 ()); | ||
373 | 488 | glVertex2i (outline.x1 (), outline.y2 ()); | ||
374 | 489 | glEnd (); | ||
375 | 490 | |||
376 | 491 | /* clean up */ | ||
377 | 492 | glColor4usv (defaultColor); | ||
378 | 493 | glDisable (GL_BLEND); | ||
379 | 494 | glEnableClientState (GL_TEXTURE_COORD_ARRAY); | ||
380 | 495 | glPopMatrix (); | ||
381 | 496 | } | ||
382 | 392 | } | 497 | } |
383 | 393 | 498 | ||
384 | 394 | bool | 499 | bool |
385 | @@ -398,11 +503,18 @@ | |||
386 | 398 | CompOutput *output, | 503 | CompOutput *output, |
387 | 399 | unsigned int mask) | 504 | unsigned int mask) |
388 | 400 | { | 505 | { |
394 | 401 | bool status; | 506 | bool status; |
395 | 402 | 507 | ||
396 | 403 | status = glScreen->glPaintOutput (attrib, matrix, region, output, mask); | 508 | if (desiredSlot && optionGetDrawIndicator ()) |
397 | 404 | 509 | { | |
398 | 405 | glPaintRectangle (attrib, matrix, output); | 510 | GLMatrix sTransform (matrix); |
399 | 511 | status = glScreen->glPaintOutput (attrib, matrix, region, output, mask); | ||
400 | 512 | |||
401 | 513 | sTransform.toScreenSpace (output, -DEFAULT_Z_CAMERA); | ||
402 | 514 | ((PaintableAnimatedGridRectangle *) desiredSlot)->paint (sTransform); | ||
403 | 515 | } | ||
404 | 516 | else | ||
405 | 517 | status = glScreen->glPaintOutput (attrib, matrix, region, output, mask); | ||
406 | 406 | 518 | ||
407 | 407 | return status; | 519 | return status; |
408 | 408 | } | 520 | } |
409 | @@ -452,6 +564,8 @@ | |||
410 | 452 | CompOutput out; | 564 | CompOutput out; |
411 | 453 | CompOption::Vector opts; | 565 | CompOption::Vector opts; |
412 | 454 | CompOption::Value v = CompOption::Value ((int) mGrabWindow->id ()); | 566 | CompOption::Value v = CompOption::Value ((int) mGrabWindow->id ()); |
413 | 567 | CompRect *edgeBox = NULL; | ||
414 | 568 | float edgeDist; /* interpolated 0.0f -> 1.0f based on distance */ | ||
415 | 455 | 569 | ||
416 | 456 | screen->handleEvent (event); | 570 | screen->handleEvent (event); |
417 | 457 | 571 | ||
418 | @@ -469,31 +583,182 @@ | |||
419 | 469 | /* Bottom Left */ | 583 | /* Bottom Left */ |
420 | 470 | if (pointerY > (out.y () + out.height () - optionGetBottomEdgeThreshold()) && | 584 | if (pointerY > (out.y () + out.height () - optionGetBottomEdgeThreshold()) && |
421 | 471 | pointerX < out.x () + optionGetLeftEdgeThreshold()) | 585 | pointerX < out.x () + optionGetLeftEdgeThreshold()) |
422 | 586 | { | ||
423 | 587 | float xd, yd; | ||
424 | 588 | unsigned int xptr = (out.x ()) + pointerX; | ||
425 | 589 | unsigned int yptr = (out.y () + out.height ()) - pointerY; | ||
426 | 590 | |||
427 | 591 | if (xptr) | ||
428 | 592 | xd = MIN (((float) xptr / (float) optionGetLeftEdgeThreshold ()), 1.0f); | ||
429 | 593 | else | ||
430 | 594 | xd = 0.0f; | ||
431 | 595 | |||
432 | 596 | if (yptr) | ||
433 | 597 | yd = MIN (((float) yptr / (float) optionGetBottomEdgeThreshold ()), 1.0f); | ||
434 | 598 | else | ||
435 | 599 | yd = 0.0f; | ||
436 | 600 | |||
437 | 601 | if (optionGetIndicatorDirection () == GridOptions::IndicatorDirectionFromEdge) | ||
438 | 602 | edgeBox = new CompRect (out.x (), out.y () + (out.height () - mGrabWindow->height ()), | ||
439 | 603 | mGrabWindow->width (), mGrabWindow->height ()); | ||
440 | 604 | |||
441 | 605 | edgeDist = (xd + yd) / 2.0f; | ||
442 | 472 | edge = BottomLeft; | 606 | edge = BottomLeft; |
443 | 607 | } | ||
444 | 473 | /* Bottom Right */ | 608 | /* Bottom Right */ |
445 | 474 | else if (pointerY > (out.y () + out.height () - optionGetBottomEdgeThreshold()) && | 609 | else if (pointerY > (out.y () + out.height () - optionGetBottomEdgeThreshold()) && |
446 | 475 | pointerX > (out.x () + out.width () - optionGetRightEdgeThreshold())) | 610 | pointerX > (out.x () + out.width () - optionGetRightEdgeThreshold())) |
447 | 611 | { | ||
448 | 612 | float xd, yd; | ||
449 | 613 | unsigned int xptr = (out.x () + out.width ()) - pointerX; | ||
450 | 614 | unsigned int yptr = (out.y () + out.height ()) - pointerY; | ||
451 | 615 | |||
452 | 616 | if (xptr) | ||
453 | 617 | xd = MIN (((float) xptr / (float) optionGetRightEdgeThreshold ()), 1.0f); | ||
454 | 618 | else | ||
455 | 619 | xd = 0.0f; | ||
456 | 620 | |||
457 | 621 | if (yptr) | ||
458 | 622 | yd = MIN (((float) yptr / (float) optionGetBottomEdgeThreshold ()), 1.0f); | ||
459 | 623 | else | ||
460 | 624 | yd = 0.0f; | ||
461 | 625 | |||
462 | 626 | if (optionGetIndicatorDirection () == GridOptions::IndicatorDirectionFromEdge) | ||
463 | 627 | edgeBox = new CompRect (out.x () + (out.width () - mGrabWindow->width ()), | ||
464 | 628 | out.y () + (out.height () - mGrabWindow->height ()), | ||
465 | 629 | mGrabWindow->width (), mGrabWindow->height ()); | ||
466 | 630 | |||
467 | 631 | edgeDist = (xd + yd) / 2.0f; | ||
468 | 476 | edge = BottomRight; | 632 | edge = BottomRight; |
469 | 633 | } | ||
470 | 477 | /* Top Left */ | 634 | /* Top Left */ |
471 | 478 | else if (pointerY < optionGetTopEdgeThreshold() && | 635 | else if (pointerY < optionGetTopEdgeThreshold() && |
472 | 479 | pointerX < optionGetLeftEdgeThreshold()) | 636 | pointerX < optionGetLeftEdgeThreshold()) |
473 | 637 | { | ||
474 | 638 | float xd, yd; | ||
475 | 639 | unsigned int xptr = (out.x ()) + pointerX; | ||
476 | 640 | unsigned int yptr = (out.y ()) + pointerY; | ||
477 | 641 | |||
478 | 642 | if (xptr) | ||
479 | 643 | xd = MIN (((float) xptr / (float) optionGetLeftEdgeThreshold ()), 1.0f); | ||
480 | 644 | else | ||
481 | 645 | xd = 0.0f; | ||
482 | 646 | |||
483 | 647 | if (yptr) | ||
484 | 648 | yd = MIN (((float) yptr / (float) optionGetTopEdgeThreshold ()), 1.0f); | ||
485 | 649 | else | ||
486 | 650 | yd = 0.0f; | ||
487 | 651 | |||
488 | 652 | if (optionGetIndicatorDirection () == GridOptions::IndicatorDirectionFromEdge) | ||
489 | 653 | edgeBox = new CompRect (out.x (), | ||
490 | 654 | out.y (), | ||
491 | 655 | mGrabWindow->width (), mGrabWindow->height ()); | ||
492 | 656 | |||
493 | 657 | edgeDist = (xd + yd) / 2.0f; | ||
494 | 480 | edge = TopLeft; | 658 | edge = TopLeft; |
495 | 659 | } | ||
496 | 481 | /* Top Right */ | 660 | /* Top Right */ |
497 | 482 | else if (pointerY < out.y () + optionGetTopEdgeThreshold() && | 661 | else if (pointerY < out.y () + optionGetTopEdgeThreshold() && |
498 | 483 | pointerX > (out.x () + out.width () - optionGetRightEdgeThreshold())) | 662 | pointerX > (out.x () + out.width () - optionGetRightEdgeThreshold())) |
499 | 663 | { | ||
500 | 664 | float xd, yd; | ||
501 | 665 | unsigned int xptr = (out.x () + out.width ()) - pointerX; | ||
502 | 666 | unsigned int yptr = (out.y ()) + pointerY; | ||
503 | 667 | |||
504 | 668 | if (xptr) | ||
505 | 669 | xd = MIN (((float) xptr / (float) optionGetRightEdgeThreshold ()), 1.0f); | ||
506 | 670 | else | ||
507 | 671 | xd = 0.0f; | ||
508 | 672 | |||
509 | 673 | if (yptr) | ||
510 | 674 | yd = MIN (((float) yptr / (float) optionGetTopEdgeThreshold ()), 1.0f); | ||
511 | 675 | else | ||
512 | 676 | yd = 0.0f; | ||
513 | 677 | |||
514 | 678 | if (optionGetIndicatorDirection () == GridOptions::IndicatorDirectionFromEdge) | ||
515 | 679 | edgeBox = new CompRect (out.x () + (out.width () - mGrabWindow->width ()), | ||
516 | 680 | out.y (), | ||
517 | 681 | mGrabWindow->width (), mGrabWindow->height ()); | ||
518 | 682 | |||
519 | 683 | edgeDist = (xd + yd) / 2.0f; | ||
520 | 484 | edge = TopRight; | 684 | edge = TopRight; |
521 | 685 | } | ||
522 | 485 | /* Left */ | 686 | /* Left */ |
523 | 486 | else if (pointerX < out.x () + optionGetLeftEdgeThreshold()) | 687 | else if (pointerX < out.x () + optionGetLeftEdgeThreshold()) |
524 | 688 | { | ||
525 | 689 | float xd; | ||
526 | 690 | unsigned int xptr = (out.x ()) + pointerX; | ||
527 | 691 | |||
528 | 692 | if (xptr) | ||
529 | 693 | xd = MIN (((float) xptr / (float) optionGetLeftEdgeThreshold ()), 1.0f); | ||
530 | 694 | else | ||
531 | 695 | xd = 0.0f; | ||
532 | 696 | |||
533 | 697 | if (optionGetIndicatorDirection () == GridOptions::IndicatorDirectionFromEdge) | ||
534 | 698 | edgeBox = new CompRect (out.x (), | ||
535 | 699 | out.y () + (out.height () / 2.0f) - mGrabWindow->height () / 2.0f, | ||
536 | 700 | mGrabWindow->width (), mGrabWindow->height ()); | ||
537 | 701 | |||
538 | 702 | edgeDist = xd; | ||
539 | 487 | edge = Left; | 703 | edge = Left; |
540 | 704 | } | ||
541 | 488 | /* Right */ | 705 | /* Right */ |
542 | 489 | else if (pointerX > (out.x () + out.width () - optionGetRightEdgeThreshold())) | 706 | else if (pointerX > (out.x () + out.width () - optionGetRightEdgeThreshold())) |
543 | 707 | { | ||
544 | 708 | float xd; | ||
545 | 709 | unsigned int xptr = (out.x () + out.width ()) - pointerX; | ||
546 | 710 | |||
547 | 711 | if (xptr) | ||
548 | 712 | xd = MIN (((float) xptr / (float) optionGetRightEdgeThreshold ()), 1.0f); | ||
549 | 713 | else | ||
550 | 714 | xd = 0.0f; | ||
551 | 715 | |||
552 | 716 | if (optionGetIndicatorDirection () == GridOptions::IndicatorDirectionFromEdge) | ||
553 | 717 | edgeBox = new CompRect (out.x () + (out.width () - mGrabWindow->width ()), | ||
554 | 718 | out.y () + (out.height () / 2.0f) - mGrabWindow->height () / 2.0f, | ||
555 | 719 | mGrabWindow->width (), mGrabWindow->height ()); | ||
556 | 720 | |||
557 | 721 | edgeDist = xd; | ||
558 | 490 | edge = Right; | 722 | edge = Right; |
559 | 723 | } | ||
560 | 491 | /* Top */ | 724 | /* Top */ |
561 | 492 | else if (pointerY < out.y () + optionGetTopEdgeThreshold()) | 725 | else if (pointerY < out.y () + optionGetTopEdgeThreshold()) |
562 | 726 | { | ||
563 | 727 | float yd; | ||
564 | 728 | unsigned int yptr = (out.y ()) + pointerY; | ||
565 | 729 | |||
566 | 730 | if (yptr) | ||
567 | 731 | yd = MIN (((float) yptr / (float) optionGetTopEdgeThreshold ()), 1.0f); | ||
568 | 732 | else | ||
569 | 733 | yd = 0.0f; | ||
570 | 734 | |||
571 | 735 | if (optionGetIndicatorDirection () == GridOptions::IndicatorDirectionFromEdge) | ||
572 | 736 | edgeBox = new CompRect (out.x () + (out.width () / 2.0f) - mGrabWindow->width () / 2.0f, | ||
573 | 737 | out.y (), | ||
574 | 738 | mGrabWindow->width (), mGrabWindow->height ()); | ||
575 | 739 | |||
576 | 740 | edgeDist = yd; | ||
577 | 493 | edge = Top; | 741 | edge = Top; |
578 | 742 | } | ||
579 | 494 | /* Bottom */ | 743 | /* Bottom */ |
580 | 495 | else if (pointerY > (out.y () + out.height () - optionGetBottomEdgeThreshold())) | 744 | else if (pointerY > (out.y () + out.height () - optionGetBottomEdgeThreshold())) |
581 | 745 | { | ||
582 | 746 | float yd; | ||
583 | 747 | unsigned int yptr = (out.y () + out.width ()) - pointerY; | ||
584 | 748 | |||
585 | 749 | if (yptr) | ||
586 | 750 | yd = MIN (((float) yptr / (float) optionGetBottomEdgeThreshold ()), 1.0f); | ||
587 | 751 | else | ||
588 | 752 | yd = 0.0f; | ||
589 | 753 | |||
590 | 754 | if (optionGetIndicatorDirection () == GridOptions::IndicatorDirectionFromEdge) | ||
591 | 755 | edgeBox = new CompRect (out.x () + (out.width () / 2.0f) - mGrabWindow->width () / 2.0f, | ||
592 | 756 | out.y () + (out.height () - mGrabWindow->height ()), | ||
593 | 757 | mGrabWindow->width (), mGrabWindow->height ()); | ||
594 | 758 | |||
595 | 759 | edgeDist = yd; | ||
596 | 496 | edge = Bottom; | 760 | edge = Bottom; |
597 | 761 | } | ||
598 | 497 | /* No Edge */ | 762 | /* No Edge */ |
599 | 498 | else | 763 | else |
600 | 499 | edge = NoEdge; | 764 | edge = NoEdge; |
601 | @@ -504,29 +769,71 @@ | |||
602 | 504 | (screen->outputDeviceForPoint (pointerX, pointerY)); | 769 | (screen->outputDeviceForPoint (pointerX, pointerY)); |
603 | 505 | if (lastWorkarea != currentWorkarea) | 770 | if (lastWorkarea != currentWorkarea) |
604 | 506 | { | 771 | { |
605 | 772 | CompRect old; | ||
606 | 773 | |||
607 | 774 | if (desiredSlot) | ||
608 | 775 | old = *desiredSlot; | ||
609 | 776 | |||
610 | 507 | lastWorkarea = currentWorkarea; | 777 | lastWorkarea = currentWorkarea; |
611 | 508 | 778 | ||
612 | 509 | if (compositingActive && cScreen) | 779 | if (compositingActive && cScreen) |
614 | 510 | cScreen->damageRegion (desiredSlot); | 780 | cScreen->damageRegion (old); |
615 | 511 | 781 | ||
616 | 512 | initiateCommon (0, 0, opts, edgeToGridType (), false); | 782 | initiateCommon (0, 0, opts, edgeToGridType (), false); |
617 | 513 | 783 | ||
618 | 784 | if (edgeBox && desiredSlot) | ||
619 | 785 | { | ||
620 | 786 | desiredSlot->setFrom (*edgeBox); | ||
621 | 787 | delete edgeBox; | ||
622 | 788 | } | ||
623 | 789 | |||
624 | 514 | if (compositingActive && cScreen) | 790 | if (compositingActive && cScreen) |
626 | 515 | cScreen->damageRegion (desiredSlot); | 791 | cScreen->damageRegion (desiredSlot ? *desiredSlot : old); |
627 | 516 | } | 792 | } |
628 | 517 | 793 | ||
629 | 518 | /* Detect edge region change */ | 794 | /* Detect edge region change */ |
630 | 519 | if (lastEdge != edge) | 795 | if (lastEdge != edge) |
631 | 520 | { | 796 | { |
632 | 797 | CompRect old; | ||
633 | 798 | |||
634 | 799 | if (desiredSlot) | ||
635 | 800 | { | ||
636 | 801 | ((AnimatedGridRectangle *) desiredSlot)->reset (); | ||
637 | 802 | old = *desiredSlot; | ||
638 | 803 | } | ||
639 | 804 | |||
640 | 521 | lastEdge = edge; | 805 | lastEdge = edge; |
641 | 522 | 806 | ||
642 | 523 | if (compositingActive && cScreen) | 807 | if (compositingActive && cScreen) |
644 | 524 | cScreen->damageRegion (desiredSlot); | 808 | cScreen->damageRegion (old); |
645 | 525 | 809 | ||
646 | 526 | initiateCommon (0, 0, opts, edgeToGridType (), false); | 810 | initiateCommon (0, 0, opts, edgeToGridType (), false); |
647 | 527 | 811 | ||
648 | 812 | if (edgeBox && desiredSlot) | ||
649 | 813 | { | ||
650 | 814 | desiredSlot->setFrom (*edgeBox); | ||
651 | 815 | delete edgeBox; | ||
652 | 816 | } | ||
653 | 817 | |||
654 | 528 | if (compositingActive && cScreen) | 818 | if (compositingActive && cScreen) |
656 | 529 | cScreen->damageRegion (desiredSlot); | 819 | cScreen->damageRegion (desiredSlot ? *desiredSlot : old); |
657 | 820 | } | ||
658 | 821 | |||
659 | 822 | /* The closer the user gets to the edge, the more progress should go up */ | ||
660 | 823 | if (desiredSlot) | ||
661 | 824 | { | ||
662 | 825 | CompRect damage; | ||
663 | 826 | CompRect sbr = mGrabWindow->serverBorderRect (); | ||
664 | 827 | |||
665 | 828 | damage = ((AnimatedGridRectangle *) desiredSlot)->current (); | ||
666 | 829 | cScreen->damageRegion (damage); | ||
667 | 830 | |||
668 | 831 | if (optionGetIndicatorDirection () == GridOptions::IndicatorDirectionFromWindow) | ||
669 | 832 | ((AnimatedGridRectangle *) desiredSlot)->setFrom (sbr); | ||
670 | 833 | ((AnimatedGridRectangle *) desiredSlot)->setProgress (1.0f - edgeDist); | ||
671 | 834 | |||
672 | 835 | damage = ((AnimatedGridRectangle *) desiredSlot)->current (); | ||
673 | 836 | cScreen->damageRegion (damage); | ||
674 | 530 | } | 837 | } |
675 | 531 | 838 | ||
676 | 532 | GRID_WINDOW (mGrabWindow); | 839 | GRID_WINDOW (mGrabWindow); |
677 | @@ -540,6 +847,24 @@ | |||
678 | 540 | restoreWindow (0, 0, opts); | 847 | restoreWindow (0, 0, opts); |
679 | 541 | } | 848 | } |
680 | 542 | 849 | ||
681 | 850 | bool | ||
682 | 851 | GridWindow::glDraw (const GLMatrix &transform, | ||
683 | 852 | GLFragment::Attrib &fragment, | ||
684 | 853 | const CompRegion ®ion, | ||
685 | 854 | unsigned int mask) | ||
686 | 855 | { | ||
687 | 856 | CompRegion nRegion = region; | ||
688 | 857 | |||
689 | 858 | if (gScreen->desiredSlot) | ||
690 | 859 | { | ||
691 | 860 | nRegion = nRegion.united (gScreen->desiredSlot->current ()); | ||
692 | 861 | |||
693 | 862 | gScreen->desiredSlot->paint (transform); | ||
694 | 863 | } | ||
695 | 864 | |||
696 | 865 | return glWindow->glDraw (transform, fragment, nRegion, mask); | ||
697 | 866 | } | ||
698 | 867 | |||
699 | 543 | void | 868 | void |
700 | 544 | GridWindow::grabNotify (int x, | 869 | GridWindow::grabNotify (int x, |
701 | 545 | int y, | 870 | int y, |
702 | @@ -550,7 +875,12 @@ | |||
703 | 550 | { | 875 | { |
704 | 551 | screen->handleEventSetEnabled (gScreen, true); | 876 | screen->handleEventSetEnabled (gScreen, true); |
705 | 552 | if (compositingActive) | 877 | if (compositingActive) |
707 | 553 | gScreen->glScreen->glPaintOutputSetEnabled (gScreen, true); | 878 | { |
708 | 879 | if (gScreen->optionGetBehindWindow ()) | ||
709 | 880 | glWindow->glDrawSetEnabled (this, true); | ||
710 | 881 | else | ||
711 | 882 | gScreen->glScreen->glPaintOutputSetEnabled (gScreen, true); | ||
712 | 883 | } | ||
713 | 554 | gScreen->mGrabWindow = window; | 884 | gScreen->mGrabWindow = window; |
714 | 555 | pointerBufDx = pointerBufDy = 0; | 885 | pointerBufDx = pointerBufDy = 0; |
715 | 556 | 886 | ||
716 | @@ -574,6 +904,7 @@ | |||
717 | 574 | if (window == gScreen->mGrabWindow) | 904 | if (window == gScreen->mGrabWindow) |
718 | 575 | { | 905 | { |
719 | 576 | CompOption::Vector opts; | 906 | CompOption::Vector opts; |
720 | 907 | CompRect damage = gScreen->desiredSlot ? *gScreen->desiredSlot : CompRect (0, 0, 0, 0); | ||
721 | 577 | CompOption::Value v = CompOption::Value ((int) gScreen->mGrabWindow->id ()); | 908 | CompOption::Value v = CompOption::Value ((int) gScreen->mGrabWindow->id ()); |
722 | 578 | 909 | ||
723 | 579 | opts.resize (1); | 910 | opts.resize (1); |
724 | @@ -587,8 +918,11 @@ | |||
725 | 587 | 918 | ||
726 | 588 | if (compositingActive) | 919 | if (compositingActive) |
727 | 589 | { | 920 | { |
730 | 590 | gScreen->glScreen->glPaintOutputSetEnabled (gScreen, false); | 921 | if (gScreen->optionGetBehindWindow ()) |
731 | 591 | gScreen->cScreen->damageRegion (gScreen->desiredSlot); | 922 | glWindow->glDrawSetEnabled (this, false); |
732 | 923 | else | ||
733 | 924 | gScreen->glScreen->glPaintOutputSetEnabled (gScreen, false); | ||
734 | 925 | gScreen->cScreen->damageRegion (damage); | ||
735 | 592 | } | 926 | } |
736 | 593 | 927 | ||
737 | 594 | gScreen->mGrabWindow = NULL; | 928 | gScreen->mGrabWindow = NULL; |
738 | @@ -654,6 +988,7 @@ | |||
739 | 654 | 988 | ||
740 | 655 | GridScreen::GridScreen (CompScreen *screen) : | 989 | GridScreen::GridScreen (CompScreen *screen) : |
741 | 656 | PluginClassHandler<GridScreen, CompScreen> (screen), | 990 | PluginClassHandler<GridScreen, CompScreen> (screen), |
742 | 991 | desiredSlot (NULL), | ||
743 | 657 | mGrabWindow (NULL) | 992 | mGrabWindow (NULL) |
744 | 658 | { | 993 | { |
745 | 659 | if (compositingActive) | 994 | if (compositingActive) |
746 | @@ -661,8 +996,7 @@ | |||
747 | 661 | cScreen = CompositeScreen::get (screen); | 996 | cScreen = CompositeScreen::get (screen); |
748 | 662 | glScreen = GLScreen::get (screen); | 997 | glScreen = GLScreen::get (screen); |
749 | 663 | 998 | ||
752 | 664 | CompositeScreenInterface::setHandler (cScreen, false); | 999 | ScreenInterface::setHandler (screen, false); |
751 | 665 | GLScreenInterface::setHandler (glScreen, false); | ||
753 | 666 | } | 1000 | } |
754 | 667 | 1001 | ||
755 | 668 | ScreenInterface::setHandler (screen, false); | 1002 | ScreenInterface::setHandler (screen, false); |
756 | @@ -696,6 +1030,7 @@ | |||
757 | 696 | GridWindow::GridWindow (CompWindow *window) : | 1030 | GridWindow::GridWindow (CompWindow *window) : |
758 | 697 | PluginClassHandler <GridWindow, CompWindow> (window), | 1031 | PluginClassHandler <GridWindow, CompWindow> (window), |
759 | 698 | window (window), | 1032 | window (window), |
760 | 1033 | glWindow (GLWindow::get (window)), | ||
761 | 699 | gScreen (GridScreen::get (screen)), | 1034 | gScreen (GridScreen::get (screen)), |
762 | 700 | isGridResized (false), | 1035 | isGridResized (false), |
763 | 701 | isGridMaximized (false), | 1036 | isGridMaximized (false), |
764 | @@ -705,6 +1040,7 @@ | |||
765 | 705 | lastTarget (GridUnknown) | 1040 | lastTarget (GridUnknown) |
766 | 706 | { | 1041 | { |
767 | 707 | WindowInterface::setHandler (window); | 1042 | WindowInterface::setHandler (window); |
768 | 1043 | GLWindowInterface::setHandler (glWindow, false); | ||
769 | 708 | } | 1044 | } |
770 | 709 | 1045 | ||
771 | 710 | /* Initial plugin init function called. Checks to see if we are ABI | 1046 | /* Initial plugin init function called. Checks to see if we are ABI |
772 | 711 | 1047 | ||
773 | === modified file 'plugins/grid/src/grid.h' | |||
774 | --- plugins/grid/src/grid.h 2011-04-05 13:32:45 +0000 | |||
775 | +++ plugins/grid/src/grid.h 2011-04-06 14:53:28 +0000 | |||
776 | @@ -28,6 +28,8 @@ | |||
777 | 28 | #include <composite/composite.h> | 28 | #include <composite/composite.h> |
778 | 29 | #include <opengl/opengl.h> | 29 | #include <opengl/opengl.h> |
779 | 30 | 30 | ||
780 | 31 | #include <cmath> | ||
781 | 32 | |||
782 | 31 | #include "grid_options.h" | 33 | #include "grid_options.h" |
783 | 32 | 34 | ||
784 | 33 | #define SNAPOFF_THRESHOLD 50 | 35 | #define SNAPOFF_THRESHOLD 50 |
785 | @@ -85,6 +87,89 @@ | |||
786 | 85 | GridRectangle addBorders (CompWindow *w) const; | 87 | GridRectangle addBorders (CompWindow *w) const; |
787 | 86 | }; | 88 | }; |
788 | 87 | 89 | ||
789 | 90 | class Paintable | ||
790 | 91 | { | ||
791 | 92 | public: | ||
792 | 93 | |||
793 | 94 | Paintable () | ||
794 | 95 | { | ||
795 | 96 | }; | ||
796 | 97 | |||
797 | 98 | virtual void paint (const GLMatrix &mat) = 0; | ||
798 | 99 | }; | ||
799 | 100 | |||
800 | 101 | class AnimatedGridRectangle : | ||
801 | 102 | public GridRectangle | ||
802 | 103 | { | ||
803 | 104 | public: | ||
804 | 105 | |||
805 | 106 | AnimatedGridRectangle () : | ||
806 | 107 | GridRectangle::GridRectangle (), | ||
807 | 108 | mFrom (CompRect (0, 0, 0, 0)), | ||
808 | 109 | mProgress (0.0f), | ||
809 | 110 | mTime (300) | ||
810 | 111 | { | ||
811 | 112 | }; | ||
812 | 113 | |||
813 | 114 | AnimatedGridRectangle (const GridRectangle &r) : | ||
814 | 115 | GridRectangle::GridRectangle (r), | ||
815 | 116 | mFrom (CompRect (0, 0, 0, 0)), | ||
816 | 117 | mProgress (0.0f), | ||
817 | 118 | mTime (300) | ||
818 | 119 | { | ||
819 | 120 | }; | ||
820 | 121 | |||
821 | 122 | AnimatedGridRectangle (const CompRect &r) : | ||
822 | 123 | GridRectangle::GridRectangle (r), | ||
823 | 124 | mFrom (CompRect (0, 0, 0, 0)), | ||
824 | 125 | mProgress (0.0f), | ||
825 | 126 | mTime (300) | ||
826 | 127 | { | ||
827 | 128 | }; | ||
828 | 129 | |||
829 | 130 | CompRect current (); | ||
830 | 131 | float progress (); | ||
831 | 132 | |||
832 | 133 | void setFrom (CompRect &); | ||
833 | 134 | void setProgress (float); | ||
834 | 135 | void reset (); | ||
835 | 136 | void setTime (unsigned int); | ||
836 | 137 | |||
837 | 138 | private: | ||
838 | 139 | |||
839 | 140 | CompRect mFrom; | ||
840 | 141 | float mProgress; | ||
841 | 142 | |||
842 | 143 | unsigned int mTime; | ||
843 | 144 | }; | ||
844 | 145 | |||
845 | 146 | class PaintableAnimatedGridRectangle : | ||
846 | 147 | public Paintable, | ||
847 | 148 | public AnimatedGridRectangle | ||
848 | 149 | { | ||
849 | 150 | public: | ||
850 | 151 | |||
851 | 152 | PaintableAnimatedGridRectangle () : | ||
852 | 153 | Paintable::Paintable (), | ||
853 | 154 | AnimatedGridRectangle::AnimatedGridRectangle () | ||
854 | 155 | { | ||
855 | 156 | }; | ||
856 | 157 | |||
857 | 158 | PaintableAnimatedGridRectangle (const GridRectangle &r) : | ||
858 | 159 | Paintable::Paintable (), | ||
859 | 160 | AnimatedGridRectangle::AnimatedGridRectangle (r) | ||
860 | 161 | { | ||
861 | 162 | }; | ||
862 | 163 | |||
863 | 164 | PaintableAnimatedGridRectangle (const CompRect &r) : | ||
864 | 165 | Paintable::Paintable (), | ||
865 | 166 | AnimatedGridRectangle::AnimatedGridRectangle (r) | ||
866 | 167 | { | ||
867 | 168 | }; | ||
868 | 169 | |||
869 | 170 | virtual void paint (const GLMatrix &mat); | ||
870 | 171 | }; | ||
871 | 172 | |||
872 | 88 | class GridScreen : | 173 | class GridScreen : |
873 | 89 | public ScreenInterface, | 174 | public ScreenInterface, |
874 | 90 | public CompositeScreenInterface, | 175 | public CompositeScreenInterface, |
875 | @@ -98,7 +183,7 @@ | |||
876 | 98 | CompositeScreen *cScreen; | 183 | CompositeScreen *cScreen; |
877 | 99 | GLScreen *glScreen; | 184 | GLScreen *glScreen; |
878 | 100 | 185 | ||
880 | 101 | GridRectangle desiredSlot; | 186 | PaintableAnimatedGridRectangle *desiredSlot; |
881 | 102 | CompRect workarea, currentRect, | 187 | CompRect workarea, currentRect, |
882 | 103 | desiredRect, lastWorkarea, currentWorkarea; | 188 | desiredRect, lastWorkarea, currentWorkarea; |
883 | 104 | GridProps props; | 189 | GridProps props; |
884 | @@ -110,9 +195,6 @@ | |||
885 | 110 | bool initiateCommon (CompAction*, CompAction::State, | 195 | bool initiateCommon (CompAction*, CompAction::State, |
886 | 111 | CompOption::Vector&, GridType, bool); | 196 | CompOption::Vector&, GridType, bool); |
887 | 112 | 197 | ||
888 | 113 | void glPaintRectangle (const GLScreenPaintAttrib&, | ||
889 | 114 | const GLMatrix&, CompOutput *); | ||
890 | 115 | |||
891 | 116 | bool glPaintOutput (const GLScreenPaintAttrib &, | 198 | bool glPaintOutput (const GLScreenPaintAttrib &, |
892 | 117 | const GLMatrix &, const CompRegion &, | 199 | const GLMatrix &, const CompRegion &, |
893 | 118 | CompOutput *, unsigned int); | 200 | CompOutput *, unsigned int); |
894 | @@ -132,12 +214,14 @@ | |||
895 | 132 | 214 | ||
896 | 133 | class GridWindow : | 215 | class GridWindow : |
897 | 134 | public WindowInterface, | 216 | public WindowInterface, |
898 | 217 | public GLWindowInterface, | ||
899 | 135 | public PluginClassHandler <GridWindow, CompWindow> | 218 | public PluginClassHandler <GridWindow, CompWindow> |
900 | 136 | { | 219 | { |
901 | 137 | public: | 220 | public: |
902 | 138 | 221 | ||
903 | 139 | GridWindow (CompWindow *); | 222 | GridWindow (CompWindow *); |
904 | 140 | CompWindow *window; | 223 | CompWindow *window; |
905 | 224 | GLWindow *glWindow; | ||
906 | 141 | GridScreen *gScreen; | 225 | GridScreen *gScreen; |
907 | 142 | 226 | ||
908 | 143 | bool isGridResized; | 227 | bool isGridResized; |
909 | @@ -154,6 +238,12 @@ | |||
910 | 154 | GridRectangle | 238 | GridRectangle |
911 | 155 | constrainSize (const GridRectangle & slot); | 239 | constrainSize (const GridRectangle & slot); |
912 | 156 | 240 | ||
913 | 241 | bool | ||
914 | 242 | glDraw (const GLMatrix &transform, | ||
915 | 243 | GLFragment::Attrib &fragment, | ||
916 | 244 | const CompRegion ®ion, | ||
917 | 245 | unsigned int mask); | ||
918 | 246 | |||
919 | 157 | void grabNotify (int, int, unsigned int, unsigned int); | 247 | void grabNotify (int, int, unsigned int, unsigned int); |
920 | 158 | 248 | ||
921 | 159 | void ungrabNotify (); | 249 | void ungrabNotify (); |