Merge lp:~mc-return/compiz/compiz.merge-fix1173684-ring-switcher-needs-vertical-text-offset-option-also into lp:compiz/0.9.10

Proposed by MC Return
Status: Merged
Approved by: Sam Spilsbury
Approved revision: 3693
Merged at revision: 3701
Proposed branch: lp:~mc-return/compiz/compiz.merge-fix1173684-ring-switcher-needs-vertical-text-offset-option-also
Merge into: lp:compiz/0.9.10
Diff against target: 1089 lines (+250/-265)
2 files modified
plugins/ring/ring.xml.in (+9/-2)
plugins/ring/src/ring.cpp (+241/-263)
To merge this branch: bzr merge lp:~mc-return/compiz/compiz.merge-fix1173684-ring-switcher-needs-vertical-text-offset-option-also
Reviewer Review Type Date Requested Status
PS Jenkins bot (community) continuous-integration Approve
Sam Spilsbury Approve
Review via email: mp+163298@code.launchpad.net

Commit message

*Ring Switcher, new feature:

Implemented "Vertical Offset" option with a default of 50 pixels.
This allows the CCSM user to easily and exactly configure where the
window title text should be displayed.

Ring Switcher, cleanup:

Simplified RingWindow::compareRingWindowDepth (...).
Bail out of functions ASAP, do not initialize anything you do not need,
if you exit anyway.
Merged if condition checks.
Declaration and assignment of local variables in one line.
Removed redundant brackets.
Added and removed newlines, if appropriate.
Fixed indentation.

(LP: #1173684)

Description of the change

Note:
The additional option is exactly analogue to:
https://code.launchpad.net/~mc-return/compiz/compiz.merge-fix1173684-shift-switcher-broken-and-hardcoded-text-placement/+merge/161294

Note 2:
I apologize for mixing the cleanup with the additional feature here, it happened because I thought the Ring Switcher code was already cleaned up in trunk, but just the .xml was...

To post a comment you must log in.
Revision history for this message
Sam Spilsbury (smspillaz) :
review: Approve
Revision history for this message
PS Jenkins bot (ps-jenkins) :
review: Approve (continuous-integration)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'plugins/ring/ring.xml.in'
2--- plugins/ring/ring.xml.in 2013-04-28 01:25:04 +0000
3+++ plugins/ring/ring.xml.in 2013-05-13 15:20:33 +0000
4@@ -239,13 +239,20 @@
5 </desc>
6 <desc>
7 <value>1</value>
8- <_name>Above ring</_name>
9+ <_name>Top of screen minus offset</_name>
10 </desc>
11 <desc>
12 <value>2</value>
13- <_name>Below ring</_name>
14+ <_name>Bottom of screen plus offset</_name>
15 </desc>
16 </option>
17+ <option name="vertical_offset" type="int">
18+ <_short>Vertical Offset</_short>
19+ <_long>Vertical offset from top or bottom of the screen (in pixels).</_long>
20+ <default>50</default>
21+ <min>0</min>
22+ <max>500</max>
23+ </option>
24 </group>
25 </options>
26 </plugin>
27
28=== modified file 'plugins/ring/src/ring.cpp'
29--- plugins/ring/src/ring.cpp 2013-05-11 09:30:49 +0000
30+++ plugins/ring/src/ring.cpp 2013-05-13 15:20:33 +0000
31@@ -76,56 +76,46 @@
32 bool
33 RingWindow::is (bool removing)
34 {
35+ if ((!removing && window->destroyed ()) ||
36+ window->overrideRedirect () ||
37+ window->wmType () & (CompWindowTypeDockMask | CompWindowTypeDesktopMask))
38+ return false;
39+
40 RING_SCREEN (screen);
41
42- if (!removing && window->destroyed ())
43- return false;
44-
45- if (window->overrideRedirect ())
46- return false;
47-
48- if (window->wmType () & (CompWindowTypeDockMask | CompWindowTypeDesktopMask))
49- return false;
50-
51 if (!removing && (!window->mapNum () || !window->isViewable ()))
52 {
53 if (rs->optionGetMinimized ())
54 {
55- if (!window->minimized () && !window->inShowDesktopMode () &&
56- !window->shaded ())
57+ if (!window->minimized () &&
58+ !window->inShowDesktopMode () &&
59+ !window->shaded ())
60 return false;
61 }
62 else
63- return false;
64+ return false;
65 }
66
67 if (!removing && rs->mType == RingScreen::RingTypeNormal)
68 {
69 if (!window->mapNum () || !window->isViewable ())
70 {
71- if (window->serverX () + window->width () <= 0 ||
72- window->serverY () + window->height () <= 0 ||
73- window->serverX () >= screen->width () ||
74+ if (window->serverX () + window->width () <= 0 ||
75+ window->serverY () + window->height () <= 0 ||
76+ window->serverX () >= screen->width () ||
77 window->serverY () >= screen->height ())
78 return false;
79 }
80- else
81- {
82- if (!window->focus ())
83- return false;
84- }
85+ else if (!window->focus ())
86+ return false;
87 }
88- else if (rs->mType == RingScreen::RingTypeGroup &&
89- rs->mClientLeader != window->clientLeader () &&
90+ else if (rs->mType == RingScreen::RingTypeGroup &&
91+ rs->mClientLeader != window->clientLeader () &&
92 rs->mClientLeader != window->id ())
93- {
94- return false;
95- }
96-
97- if (window->state () & CompWindowStateSkipTaskbarMask)
98- return false;
99-
100- if (!rs->mCurrentMatch.evaluate (window))
101+ return false;
102+
103+ if (window->state () & CompWindowStateSkipTaskbarMask ||
104+ !rs->mCurrentMatch.evaluate (window))
105 return false;
106
107 return true;
108@@ -139,21 +129,17 @@
109 void
110 RingScreen::renderWindowTitle ()
111 {
112- if (!textAvailable)
113+ if (!textAvailable || !optionGetWindowTitle ())
114 return;
115
116 CompText::Attrib attrib;
117- CompRect oe;
118
119 freeWindowTitle ();
120
121 if (!mSelectedWindow)
122 return;
123
124- if (!optionGetWindowTitle ())
125- return;
126-
127- oe = screen->getCurrentOutputExtents ();
128+ CompRect oe = screen->getCurrentOutputExtents ();
129
130 /* 75% of the output device as maximum width */
131 attrib.maxWidth = oe.width () * 3 / 4;
132@@ -165,8 +151,10 @@
133 attrib.color[2] = optionGetTitleFontColorBlue ();
134 attrib.color[3] = optionGetTitleFontColorAlpha ();
135 attrib.flags = CompText::WithBackground | CompText::Ellipsized;
136+
137 if (optionGetTitleFontBold ())
138 attrib.flags |= CompText::StyleBold;
139+
140 attrib.family = "Sans";
141 attrib.bgHMargin = 15;
142 attrib.bgVMargin = 15;
143@@ -176,22 +164,22 @@
144 attrib.bgColor[3] = optionGetTitleBackColorAlpha ();
145
146 mText.renderWindowTitle (mSelectedWindow->id (),
147- mType == RingScreen::RingTypeAll,
148- attrib);
149+ mType == RingScreen::RingTypeAll,
150+ attrib);
151 }
152
153 void
154 RingScreen::drawWindowTitle (const GLMatrix &transform)
155 {
156- if (!textAvailable)
157+ if (!textAvailable || !optionGetWindowTitle ())
158 return;
159
160- float x, y;
161- CompRect oe;
162-
163- oe = screen->getCurrentOutputExtents ();
164-
165- x = oe.centerX () - mText.getWidth () / 2;
166+ CompRect oe = screen->getCurrentOutputExtents ();
167+
168+ float x = oe.centerX () - mText.getWidth () / 2;
169+ float y;
170+
171+ unsigned short verticalOffset = optionGetVerticalOffset ();
172
173 /* assign y (for the lower corner!) according to the setting */
174 switch (optionGetTitleTextPlacement ())
175@@ -199,18 +187,20 @@
176 case RingOptions::TitleTextPlacementCenteredOnScreen:
177 y = oe.centerY () + mText.getHeight () / 2;
178 break;
179- case RingOptions::TitleTextPlacementAboveRing:
180- case RingOptions::TitleTextPlacementBelowRing:
181+
182+ case RingOptions::TitleTextPlacementTopOfScreenMinusOffset:
183+ case RingOptions::TitleTextPlacementBottomOfScreenPlusOffset:
184 {
185 CompRect workArea = screen->currentOutputDev ().workArea ();
186
187- if (optionGetTitleTextPlacement () ==
188- RingOptions::TitleTextPlacementAboveRing)
189- y = oe.y1 () + workArea.y () + mText.getHeight ();
190- else
191- y = oe.y1 () + workArea.y2 ();
192+ if (optionGetTitleTextPlacement () ==
193+ RingOptions::TitleTextPlacementTopOfScreenMinusOffset)
194+ y = oe.y1 () + workArea.y () + mText.getHeight () + verticalOffset;
195+ else /* TitleTextPlacementBottomOfScreenPlusOffset */
196+ y = oe.y1 () + workArea.y2 () - verticalOffset;
197 }
198 break;
199+
200 default:
201 return;
202 break;
203@@ -222,23 +212,23 @@
204 bool
205 RingWindow::glPaint (const GLWindowPaintAttrib &attrib,
206 const GLMatrix &transform,
207- const CompRegion &region,
208- unsigned int mask)
209+ const CompRegion &region,
210+ unsigned int mask)
211 {
212- bool status;
213-
214 RING_SCREEN (screen);
215
216+ bool status;
217+
218 if (rs->mState != RingScreen::RingStateNone)
219 {
220 GLWindowPaintAttrib sAttrib = attrib;
221 bool scaled = false;
222 bool pixmap = true;
223
224- if (window->mapNum ())
225+ if (window->mapNum () &&
226+ gWindow->textures ().empty ())
227 {
228- if (gWindow->textures ().empty ())
229- gWindow->bind ();
230+ gWindow->bind ();
231 }
232
233 if (mAdjust || mSlot)
234@@ -249,10 +239,8 @@
235 else if (rs->mState != RingScreen::RingStateIn)
236 {
237 if (rs->optionGetDarkenBack ())
238- {
239 /* modify brightness of the other windows */
240 sAttrib.brightness = sAttrib.brightness / 2;
241- }
242 }
243
244 status = gWindow->glPaint (sAttrib, transform, region, mask);
245@@ -262,19 +250,18 @@
246 if (scaled && pixmap)
247 {
248 GLWindowPaintAttrib wAttrib (gWindow->lastPaintAttrib ());
249- GLMatrix wTransform = transform;
250+ GLMatrix wTransform = transform;
251
252 if (mask & PAINT_WINDOW_OCCLUSION_DETECTION_MASK)
253 return false;
254
255 if (mSlot)
256 {
257- wAttrib.brightness = (float)wAttrib.brightness *
258- mSlot->depthBrightness;
259+ wAttrib.brightness = (float)wAttrib.brightness * mSlot->depthBrightness;
260
261 if (window != rs->mSelectedWindow)
262 wAttrib.opacity = (float)wAttrib.opacity *
263- rs->optionGetInactiveOpacity () / 100;
264+ rs->optionGetInactiveOpacity () / 100;
265 }
266
267 if (window->alpha () || wAttrib.opacity != OPAQUE)
268@@ -283,8 +270,8 @@
269 wTransform.translate (window->x (), window->y (), 0.0f);
270 wTransform.scale (mScale, mScale, 1.0f);
271 wTransform.translate (mTx / mScale - window->x (),
272- mTy / mScale - window->y (),
273- 0.0f);
274+ mTy / mScale - window->y (),
275+ 0.0f);
276
277 gWindow->glDraw (wTransform, wAttrib, region,
278 mask | PAINT_WINDOW_TRANSFORMED_MASK);
279@@ -297,22 +284,21 @@
280 GLTexture *icon;
281
282 icon = gWindow->getIcon (512, 512);
283+
284 if (!icon)
285 icon = rs->gScreen->defaultIcon ();
286
287 if (icon)
288 {
289- GLTexture::Matrix matrix;
290- GLTexture::MatrixList matricies;
291- float scale;
292- float x, y;
293- int width, height;
294- int scaledWinWidth, scaledWinHeight;
295-
296- enum RingOptions::OverlayIcon iconOverlay;
297-
298- scaledWinWidth = window->width () * mScale;
299- scaledWinHeight = window->height () * mScale;
300+ GLTexture::Matrix matrix;
301+ GLTexture::MatrixList matricies;
302+ float scale;
303+ float x, y;
304+
305+ enum RingOptions::OverlayIcon iconOverlay;
306+
307+ int scaledWinWidth = window->width () * mScale;
308+ int scaledWinHeight = window->height () * mScale;
309
310 if (!pixmap)
311 iconOverlay = RingOptions::OverlayIconBig;
312@@ -320,35 +306,42 @@
313 iconOverlay = (enum RingOptions::OverlayIcon)
314 rs->optionGetOverlayIcon ();
315
316- switch (iconOverlay) {
317- case RingOptions::OverlayIconNone:
318+ switch (iconOverlay)
319+ {
320+ case RingOptions::OverlayIconNone:
321 case RingOptions::OverlayIconEmblem:
322 scale = (mSlot) ? mSlot->depthScale : 1.0f;
323- if (icon->width () > ICON_SIZE ||
324- icon->height () > ICON_SIZE)
325+
326+ if (icon->width () > ICON_SIZE ||
327+ icon->height () > ICON_SIZE)
328 scale = MIN ((scale * ICON_SIZE / icon->width ()),
329 (scale * ICON_SIZE / icon->height ()));
330+
331 break;
332+
333 case RingOptions::OverlayIconBig:
334 default:
335 /* only change opacity if not painting an
336 icon for a minimized window */
337 if (pixmap)
338 sAttrib.opacity /= 3;
339+
340 scale = MIN (((float) scaledWinWidth / icon->width ()),
341 ((float) scaledWinHeight / icon->height ()));
342 break;
343 }
344
345- width = icon->width () * scale;
346- height = icon->height () * scale;
347+ int width = icon->width () * scale;
348+ int height = icon->height () * scale;
349
350- switch (iconOverlay) {
351+ switch (iconOverlay)
352+ {
353 case RingOptions::OverlayIconNone:
354 case RingOptions::OverlayIconEmblem:
355 x = window->x () + scaledWinWidth - width;
356 y = window->y () + scaledWinHeight - height;
357 break;
358+
359 case RingOptions::OverlayIconBig:
360 default:
361 x = window->x () + scaledWinWidth / 2 - width / 2;
362@@ -377,23 +370,24 @@
363
364 gWindow->vertexBuffer ()->begin ();
365 gWindow->glAddGeometry (matricies, iconReg, iconReg);
366+
367 if (gWindow->vertexBuffer ()->end ())
368 {
369 GLWindowPaintAttrib wAttrib (sAttrib);
370- GLMatrix wTransform = transform;
371+ GLMatrix wTransform = transform;
372
373 if (!pixmap)
374 sAttrib.opacity = gWindow->paintAttrib ().opacity;
375
376 if (mSlot)
377- wAttrib.brightness = (float)wAttrib.brightness *
378- mSlot->depthBrightness;
379+ wAttrib.brightness = (float)wAttrib.brightness *
380+ mSlot->depthBrightness;
381
382 wTransform.translate (window->x (), window->y (), 0.0f);
383 wTransform.scale (scale, scale, 1.0f);
384 wTransform.translate ((x - window->x ()) / scale - window->x (),
385- (y - window->y ()) / scale - window->y (),
386- 0.0f);
387+ (y - window->y ()) / scale - window->y (),
388+ 0.0f);
389
390 gWindow->glDrawTexture (icon, wTransform, wAttrib, mask);
391 }
392@@ -401,17 +395,17 @@
393 }
394 }
395 else
396- {
397 status = gWindow->glPaint (attrib, transform, region, mask);
398- }
399
400 return status;
401 }
402
403 static inline float
404 ringLinearInterpolation (float valX,
405- float minX, float maxX,
406- float minY, float maxY)
407+ float minX,
408+ float maxX,
409+ float minY,
410+ float maxY)
411 {
412 double factor = (maxY - minY) / (maxX - minX);
413 return (minY + (factor * (valX - minX)));
414@@ -434,41 +428,35 @@
415 RingWindow::compareRingWindowDepth (RingScreen::RingDrawSlot e1,
416 RingScreen::RingDrawSlot e2)
417 {
418- RingScreen::RingSlot *a1 = (*(e1.slot));
419- RingScreen::RingSlot *a2 = (*(e2.slot));
420+ RingScreen::RingSlot *a1 = (*(e1.slot));
421+ RingScreen::RingSlot *a2 = (*(e2.slot));
422
423 if (a1->y < a2->y)
424 return true;
425- else if (a1->y > a2->y)
426- return false;
427- else
428+ else /* if (a1->y >= a2->y) */
429 return false;
430 }
431
432 bool
433 RingScreen::layoutThumbs ()
434 {
435- float baseAngle, angle;
436+ float angle;
437 int index = 0;
438- int ww, wh;
439 float xScale, yScale;
440- int centerX, centerY;
441- int ellipseA, ellipseB;
442- CompRect oe;
443
444 if ((mState == RingStateNone) || (mState == RingStateIn))
445 return false;
446
447- baseAngle = (2 * PI * mRotTarget) / 3600;
448+ float baseAngle = (2 * PI * mRotTarget) / 3600;
449
450- oe = screen->getCurrentOutputExtents ();
451+ CompRect oe = screen->getCurrentOutputExtents ();
452
453 /* the center of the ellipse is in the middle
454 of the used output device */
455- centerX = oe.centerX ();
456- centerY = oe.centerY ();
457- ellipseA = oe.width () * optionGetRingWidth () / 200;
458- ellipseB = oe.height () * optionGetRingHeight () / 200;
459+ int centerX = oe.centerX ();
460+ int centerY = oe.centerY ();
461+ int ellipseA = oe.width () * optionGetRingWidth () / 200;
462+ int ellipseB = oe.height () * optionGetRingHeight () / 200;
463
464 mDrawSlots.resize (mWindows.size ());
465
466@@ -487,11 +475,11 @@
467 angle = baseAngle - (index * (2 * PI / mWindows.size ()));
468
469 rw->mSlot->x = centerX + (optionGetRingClockwise () ? -1 : 1) *
470- ((float) ellipseA * sin (angle));
471+ ((float) ellipseA * sin (angle));
472 rw->mSlot->y = centerY + ((float) ellipseB * cos (angle));
473
474- ww = w->width () + w->input ().left + w->input ().right;
475- wh = w->height () + w->input ().top + w->input ().bottom;
476+ int ww = w->width () + w->input ().left + w->input ().right;
477+ int wh = w->height () + w->input ().top + w->input ().bottom;
478
479 if (ww > optionGetThumbWidth ())
480 xScale = (float)(optionGetThumbWidth ()) / (float) ww;
481@@ -522,7 +510,7 @@
482 mDrawSlots.at (index).w = w;
483 mDrawSlots.at (index).slot = &rw->mSlot;
484
485- index++;
486+ ++index;
487 }
488
489 /* sort the draw list so that the windows with the
490@@ -547,6 +535,7 @@
491 sort (mWindows.begin (), mWindows.end (), RingWindow::compareWindows);
492
493 mRotTarget = 0;
494+
495 foreach (CompWindow *w, mWindows)
496 {
497 if (w == mSelectedWindow)
498@@ -566,6 +555,7 @@
499 foreach (CompWindow *w, screen->windows ())
500 {
501 RING_WINDOW (w);
502+
503 if (rw->is ())
504 {
505 addWindowToList (w);
506@@ -589,7 +579,8 @@
507 {
508 if (w == mSelectedWindow)
509 break;
510- cur++;
511+
512+ ++cur;
513 }
514
515 if (cur == mWindows.size ())
516@@ -605,6 +596,7 @@
517 CompWindow *old = mSelectedWindow;
518
519 mSelectedWindow = w;
520+
521 if (old != w)
522 {
523 if (toNext)
524@@ -623,14 +615,14 @@
525 int
526 RingScreen::countWindows ()
527 {
528- int count = 0;
529+ int count = 0;
530
531 foreach (CompWindow *w, screen->windows ())
532 {
533 RING_WINDOW (w);
534
535 if (rw->is ())
536- count++;
537+ ++count;
538 }
539
540 return count;
541@@ -639,13 +631,11 @@
542 int
543 RingScreen::adjustRingRotation (float chunk)
544 {
545- float dx, adjust, amount;
546- int change;
547-
548- dx = mRotAdjust;
549-
550- adjust = dx * 0.15f;
551- amount = fabs (dx) * 1.5f;
552+ float dx = mRotAdjust;
553+
554+ float adjust = dx * 0.15f;
555+ float amount = fabs (dx) * 1.5f;
556+
557 if (amount < 0.2f)
558 amount = 0.2f;
559 else if (amount > 2.0f)
560@@ -661,7 +651,8 @@
561 return 0;
562 }
563
564- change = mRVelocity * chunk;
565+ int change = mRVelocity * chunk;
566+
567 if (!change)
568 {
569 if (mRVelocity)
570@@ -680,7 +671,6 @@
571 int
572 RingWindow::adjustVelocity ()
573 {
574- float dx, dy, ds, adjust, amount;
575 float x1, y1, scale;
576
577 if (mSlot)
578@@ -696,10 +686,11 @@
579 y1 = window->y ();
580 }
581
582- dx = x1 - (window->x () + mTx);
583-
584- adjust = dx * 0.15f;
585- amount = fabs (dx) * 1.5f;
586+ float dx = x1 - (window->x () + mTx);
587+
588+ float adjust = dx * 0.15f;
589+ float amount = fabs (dx) * 1.5f;
590+
591 if (amount < 0.5f)
592 amount = 0.5f;
593 else if (amount > 5.0f)
594@@ -707,10 +698,11 @@
595
596 mXVelocity = (amount * mXVelocity + adjust) / (amount + 1.0f);
597
598- dy = y1 - (window->y () + mTy);
599+ float dy = y1 - (window->y () + mTy);
600
601 adjust = dy * 0.15f;
602 amount = fabs (dy) * 1.5f;
603+
604 if (amount < 0.5f)
605 amount = 0.5f;
606 else if (amount > 5.0f)
607@@ -718,16 +710,16 @@
608
609 mYVelocity = (amount * mYVelocity + adjust) / (amount + 1.0f);
610
611- ds = scale - mScale;
612+ float ds = scale - mScale;
613 adjust = ds * 0.1f;
614 amount = fabs (ds) * 7.0f;
615+
616 if (amount < 0.01f)
617 amount = 0.01f;
618 else if (amount > 0.15f)
619 amount = 0.15f;
620
621- mScaleVelocity = (amount * mScaleVelocity + adjust) /
622- (amount + 1.0f);
623+ mScaleVelocity = (amount * mScaleVelocity + adjust) / (amount + 1.0f);
624
625 if (fabs (dx) < 0.1f && fabs (mXVelocity) < 0.2f &&
626 fabs (dy) < 0.1f && fabs (mYVelocity) < 0.2f &&
627@@ -746,19 +738,17 @@
628
629 bool
630 RingScreen::glPaintOutput (const GLScreenPaintAttrib &attrib,
631- const GLMatrix &transform,
632- const CompRegion &region,
633- CompOutput *output,
634- unsigned int mask)
635+ const GLMatrix &transform,
636+ const CompRegion &region,
637+ CompOutput *output,
638+ unsigned int mask)
639 {
640- bool status;
641-
642 if (mState != RingStateNone)
643 mask |= PAINT_SCREEN_WITH_TRANSFORMED_WINDOWS_MASK;
644
645 //mask |= PAINT_SCREEN_NO_OCCLUSION_DETECTION_MASK;
646
647- status = gScreen->glPaintOutput (attrib, transform, region, output, mask);
648+ bool status = gScreen->glPaintOutput (attrib, transform, region, output, mask);
649
650 if (mState != RingStateNone)
651 {
652@@ -770,7 +760,6 @@
653
654 if (mState == RingScreen::RingStateSwitching ||
655 mState == RingScreen::RingStateOut)
656- {
657 for (std::vector <RingDrawSlot>::iterator it = mDrawSlots.begin ();
658 it != mDrawSlots.end (); ++it)
659 {
660@@ -779,9 +768,8 @@
661 RING_WINDOW (w);
662
663 status |= rw->gWindow->glPaint (rw->gWindow->paintAttrib (),
664- sTransform, infiniteRegion, 0);
665+ sTransform, infiniteRegion, 0);
666 }
667- }
668
669 if (mState != RingStateIn)
670 drawWindowTitle (sTransform);
671@@ -795,15 +783,12 @@
672 {
673 if (mState != RingStateNone && (mMoreAdjust || mRotateAdjust))
674 {
675- int steps;
676- float amount, chunk;
677-
678- amount = msSinceLastPaint * 0.05f * optionGetSpeed ();
679- steps = amount / (0.5f * optionGetTimestep ());
680+ float amount = msSinceLastPaint * 0.05f * optionGetSpeed ();
681+ int steps = amount / (0.5f * optionGetTimestep ());
682
683 if (!steps)
684 steps = 1;
685- chunk = amount / (float) steps;
686+ float chunk = amount / (float) steps;
687
688 while (steps--)
689 {
690@@ -851,9 +836,7 @@
691 if (mState != RingStateNone)
692 {
693 if (mMoreAdjust)
694- {
695 cScreen->damageScreen ();
696- }
697 else
698 {
699 if (mRotateAdjust)
700@@ -879,38 +862,37 @@
701 {
702 if (mGrabIndex)
703 {
704- screen->removeGrab (mGrabIndex, 0);
705- mGrabIndex = 0;
706+ screen->removeGrab (mGrabIndex, 0);
707+ mGrabIndex = 0;
708 }
709
710 if (mState != RingStateNone)
711 {
712- foreach (CompWindow *w, screen->windows ())
713- {
714+ foreach (CompWindow *w, screen->windows ())
715+ {
716 RING_WINDOW (w);
717
718 if (rw->mSlot)
719 {
720- delete rw->mSlot;
721- rw->mSlot = NULL;
722+ delete rw->mSlot;
723+ rw->mSlot = NULL;
724
725- rw->mAdjust = true;
726+ rw->mAdjust = true;
727 }
728- }
729- mMoreAdjust = true;
730- mState = RingStateIn;
731- cScreen->damageScreen ();
732-
733- if (!(state & CompAction::StateCancel) &&
734- mSelectedWindow && !mSelectedWindow->destroyed ())
735- {
736- screen->sendWindowActivationRequest (mSelectedWindow->id ());
737- }
738+ }
739+
740+ mMoreAdjust = true;
741+ mState = RingStateIn;
742+ cScreen->damageScreen ();
743+
744+ if (!(state & CompAction::StateCancel) &&
745+ mSelectedWindow && !mSelectedWindow->destroyed ())
746+ screen->sendWindowActivationRequest (mSelectedWindow->id ());
747 }
748
749 if (action)
750- action->setState ( ~(CompAction::StateTermKey |
751- CompAction::StateTermButton |
752+ action->setState ( ~(CompAction::StateTermKey |
753+ CompAction::StateTermButton |
754 CompAction::StateTermEdge));
755
756 return false;
757@@ -921,25 +903,20 @@
758 CompAction::State state,
759 CompOption::Vector options)
760 {
761- int count;
762-
763 if (screen->otherGrabExist ("ring", NULL))
764 return false;
765
766 mCurrentMatch = optionGetWindowMatch ();
767
768 mMatch = CompOption::getMatchOptionNamed (options, "match", CompMatch ());
769+
770 if (!mMatch.isEmpty ())
771- {
772 mCurrentMatch = mMatch;
773- }
774
775- count = countWindows ();
776+ int count = countWindows ();
777
778 if (count < 1)
779- {
780 return false;
781- }
782
783 if (!mGrabIndex)
784 {
785@@ -960,7 +937,7 @@
786 renderWindowTitle ();
787 mRotTarget = 0;
788
789- mMoreAdjust = true;
790+ mMoreAdjust = true;
791 toggleFunctions (true);
792 cScreen->damageScreen ();
793
794@@ -974,46 +951,42 @@
795 RingScreen::doSwitch (CompAction *action,
796 CompAction::State state,
797 CompOption::Vector options,
798- bool nextWindow,
799- RingType type)
800+ bool nextWindow,
801+ RingType type)
802 {
803- bool ret = true;
804+ bool ret = true;
805
806 if ((mState == RingStateNone) || (mState == RingStateIn))
807 {
808- if (type == RingTypeGroup)
809- {
810- CompWindow *w;
811- w = screen->findWindow (CompOption::getIntOptionNamed (options,
812- "window",
813- 0));
814+ if (type == RingTypeGroup)
815+ {
816+ CompWindow *w = screen->findWindow (CompOption::getIntOptionNamed (options,
817+ "window", 0));
818+
819 if (w)
820 {
821- mType = RingTypeGroup;
822- mClientLeader =
823- (w->clientLeader ()) ? w->clientLeader () : w->id ();
824- ret = initiate (action, state, options);
825+ mType = RingTypeGroup;
826+ mClientLeader = (w->clientLeader ()) ? w->clientLeader () : w->id ();
827+ ret = initiate (action, state, options);
828 }
829- }
830- else
831- {
832+ }
833+ else
834+ {
835 mType = type;
836 ret = initiate (action, mState, options);
837- }
838+ }
839
840- if (state & CompAction::StateInitKey)
841+ if (state & CompAction::StateInitKey)
842 action->setState (action->state () | CompAction::StateTermKey);
843
844- if (state & CompAction::StateInitEdge)
845+ if (state & CompAction::StateInitEdge)
846 action->setState (action->state () | CompAction::StateTermEdge);
847- else if (mState & CompAction::StateInitButton)
848- action->setState (action->state () |
849- CompAction::StateTermButton);
850+ else if (mState & CompAction::StateInitButton)
851+ action->setState (action->state () | CompAction::StateTermButton);
852 }
853
854 if (ret)
855- switchToWindow (nextWindow);
856-
857+ switchToWindow (nextWindow);
858
859 return ret;
860 }
861@@ -1033,11 +1006,12 @@
862 foreach (CompWindow *w, mWindows)
863 {
864 RING_WINDOW (w);
865- if (rw->mSlot)
866+
867+ if (rw->mSlot)
868 {
869- if ((x >= (rw->mTx + w->x ())) &&
870+ if ((x >= (rw->mTx + w->x ())) &&
871 (x <= (rw->mTx + w->x () + (w->width () * rw->mScale))) &&
872- (y >= (rw->mTy + w->y ())) &&
873+ (y >= (rw->mTy + w->y ())) &&
874 (y <= (rw->mTy + w->y () + (w->height () * rw->mScale))))
875 {
876 /* we have found one, select it */
877@@ -1063,14 +1037,13 @@
878 else if (!shouldTerminate && (selected != mSelectedWindow ))
879 {
880 if (!selected)
881- {
882 freeWindowTitle ();
883- }
884 else
885 {
886 mSelectedWindow = selected;
887 renderWindowTitle ();
888 }
889+
890 cScreen->damageScreen ();
891 }
892 }
893@@ -1080,19 +1053,18 @@
894 {
895 if (w)
896 {
897- bool inList = false;
898- CompWindow *selected;
899- CompWindowVector::iterator it = mWindows.begin ();
900-
901- RING_WINDOW (w);
902-
903 if (mState == RingStateNone)
904 return;
905
906+ RING_WINDOW (w);
907+
908 if (!rw->is (true))
909- return;
910+ return;
911
912+ bool inList = false;
913+ CompWindow *selected;
914 selected = mSelectedWindow;
915+ CompWindowVector::iterator it = mWindows.begin ();
916
917 while (it != mWindows.end ())
918 {
919@@ -1103,10 +1075,12 @@
920 if (w == selected)
921 {
922 ++it;
923+
924 if (it != mWindows.end ())
925 selected = *it;
926- else
927+ else
928 selected = mWindows.front ();
929+
930 --it;
931
932 mSelectedWindow = selected;
933@@ -1116,6 +1090,7 @@
934 mWindows.erase (it);
935 break;
936 }
937+
938 ++it;
939 }
940
941@@ -1156,7 +1131,8 @@
942 {
943 CompWindow *w = NULL;
944
945- switch (event->type) {
946+ switch (event->type)
947+ {
948 case DestroyNotify:
949 /* We need to get the CompWindow * for event->xdestroywindow.window
950 here because in the ::screen->handleEvent call below, that
951@@ -1164,57 +1140,64 @@
952 able to find the CompWindow after that. */
953 w = ::screen->findWindow (event->xdestroywindow.window);
954 break;
955+
956 default:
957 break;
958 }
959
960 screen->handleEvent (event);
961
962- switch (event->type) {
963- case PropertyNotify:
964- if (event->xproperty.atom == XA_WM_NAME)
965- {
966- w = screen->findWindow (event->xproperty.window);
967- if (w)
968+ switch (event->type)
969+ {
970+ case PropertyNotify:
971+ if (event->xproperty.atom == XA_WM_NAME)
972 {
973- if (mGrabIndex && (w == mSelectedWindow))
974- {
975- renderWindowTitle ();
976- cScreen->damageScreen ();
977+ w = screen->findWindow (event->xproperty.window);
978+
979+ if (w &&
980+ mGrabIndex && (w == mSelectedWindow))
981+ {
982+ renderWindowTitle ();
983+ cScreen->damageScreen ();
984 }
985 }
986- }
987- break;
988- case ButtonPress:
989- if (event->xbutton.button == Button1)
990- {
991+
992+ break;
993+
994+ case ButtonPress:
995+ if (event->xbutton.button == Button1 &&
996+ mGrabIndex)
997+ windowSelectAt (event->xbutton.x_root,
998+ event->xbutton.y_root, true);
999+
1000+ break;
1001+
1002+ case MotionNotify:
1003 if (mGrabIndex)
1004- windowSelectAt (event->xbutton.x_root,
1005- event->xbutton.y_root,
1006- true);
1007- }
1008- break;
1009- case MotionNotify:
1010- if (mGrabIndex)
1011- windowSelectAt (event->xmotion.x_root,
1012- event->xmotion.y_root,
1013- false);
1014- break;
1015- case UnmapNotify:
1016- w = ::screen->findWindow (event->xunmap.window);
1017- windowRemove (w);
1018- break;
1019- case DestroyNotify:
1020- windowRemove (w);
1021- break;
1022+ windowSelectAt (event->xmotion.x_root,
1023+ event->xmotion.y_root, false);
1024+
1025+ break;
1026+
1027+ case UnmapNotify:
1028+ w = ::screen->findWindow (event->xunmap.window);
1029+ windowRemove (w);
1030+ break;
1031+
1032+ case DestroyNotify:
1033+ windowRemove (w);
1034+ break;
1035+
1036+ default:
1037+ break;
1038 }
1039 }
1040
1041 bool
1042-RingWindow::damageRect (bool initial,
1043+RingWindow::damageRect (bool initial,
1044 const CompRect &rect)
1045 {
1046- bool status = false;
1047+ bool status = false;
1048
1049 RING_SCREEN (screen);
1050
1051@@ -1223,6 +1206,7 @@
1052 if (rs->mGrabIndex && is ())
1053 {
1054 rs->addWindowToList (window);
1055+
1056 if (rs->updateWindowList ())
1057 {
1058 mAdjust = true;
1059@@ -1232,17 +1216,12 @@
1060 }
1061 }
1062 }
1063- else if (rs->mState == RingScreen::RingStateSwitching)
1064+ else if (rs->mState == RingScreen::RingStateSwitching &&
1065+ mSlot)
1066 {
1067-
1068- if (mSlot)
1069- {
1070- cWindow->damageTransformedRect (mScale, mScale,
1071- mTx, mTy,
1072- rect);
1073- status = true;
1074- }
1075-
1076+ cWindow->damageTransformedRect (mScale, mScale,
1077+ mTx, mTy, rect);
1078+ status = true;
1079 }
1080
1081 status |= cWindow->damageRect (initial, rect);
1082@@ -1305,7 +1284,6 @@
1083 RINGTERMBIND (PrevGroupButton, terminate);
1084 }
1085
1086-
1087 RingScreen::~RingScreen ()
1088 {
1089 mWindows.clear ();

Subscribers

People subscribed via source and target branches

to all changes: