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
=== modified file 'plugins/ring/ring.xml.in'
--- plugins/ring/ring.xml.in 2013-04-28 01:25:04 +0000
+++ plugins/ring/ring.xml.in 2013-05-13 15:20:33 +0000
@@ -239,13 +239,20 @@
239 </desc>239 </desc>
240 <desc>240 <desc>
241 <value>1</value>241 <value>1</value>
242 <_name>Above ring</_name>242 <_name>Top of screen minus offset</_name>
243 </desc>243 </desc>
244 <desc>244 <desc>
245 <value>2</value>245 <value>2</value>
246 <_name>Below ring</_name>246 <_name>Bottom of screen plus offset</_name>
247 </desc>247 </desc>
248 </option>248 </option>
249 <option name="vertical_offset" type="int">
250 <_short>Vertical Offset</_short>
251 <_long>Vertical offset from top or bottom of the screen (in pixels).</_long>
252 <default>50</default>
253 <min>0</min>
254 <max>500</max>
255 </option>
249 </group>256 </group>
250 </options>257 </options>
251 </plugin>258 </plugin>
252259
=== modified file 'plugins/ring/src/ring.cpp'
--- plugins/ring/src/ring.cpp 2013-05-11 09:30:49 +0000
+++ plugins/ring/src/ring.cpp 2013-05-13 15:20:33 +0000
@@ -76,56 +76,46 @@
76bool76bool
77RingWindow::is (bool removing)77RingWindow::is (bool removing)
78{78{
79 if ((!removing && window->destroyed ()) ||
80 window->overrideRedirect () ||
81 window->wmType () & (CompWindowTypeDockMask | CompWindowTypeDesktopMask))
82 return false;
83
79 RING_SCREEN (screen);84 RING_SCREEN (screen);
8085
81 if (!removing && window->destroyed ())
82 return false;
83
84 if (window->overrideRedirect ())
85 return false;
86
87 if (window->wmType () & (CompWindowTypeDockMask | CompWindowTypeDesktopMask))
88 return false;
89
90 if (!removing && (!window->mapNum () || !window->isViewable ()))86 if (!removing && (!window->mapNum () || !window->isViewable ()))
91 {87 {
92 if (rs->optionGetMinimized ())88 if (rs->optionGetMinimized ())
93 {89 {
94 if (!window->minimized () && !window->inShowDesktopMode () &&90 if (!window->minimized () &&
95 !window->shaded ())91 !window->inShowDesktopMode () &&
92 !window->shaded ())
96 return false;93 return false;
97 }94 }
98 else95 else
99 return false;96 return false;
100 }97 }
10198
102 if (!removing && rs->mType == RingScreen::RingTypeNormal)99 if (!removing && rs->mType == RingScreen::RingTypeNormal)
103 {100 {
104 if (!window->mapNum () || !window->isViewable ())101 if (!window->mapNum () || !window->isViewable ())
105 {102 {
106 if (window->serverX () + window->width () <= 0 ||103 if (window->serverX () + window->width () <= 0 ||
107 window->serverY () + window->height () <= 0 ||104 window->serverY () + window->height () <= 0 ||
108 window->serverX () >= screen->width () ||105 window->serverX () >= screen->width () ||
109 window->serverY () >= screen->height ())106 window->serverY () >= screen->height ())
110 return false;107 return false;
111 }108 }
112 else109 else if (!window->focus ())
113 {110 return false;
114 if (!window->focus ())
115 return false;
116 }
117 }111 }
118 else if (rs->mType == RingScreen::RingTypeGroup &&112 else if (rs->mType == RingScreen::RingTypeGroup &&
119 rs->mClientLeader != window->clientLeader () &&113 rs->mClientLeader != window->clientLeader () &&
120 rs->mClientLeader != window->id ())114 rs->mClientLeader != window->id ())
121 {115 return false;
122 return false;116
123 }117 if (window->state () & CompWindowStateSkipTaskbarMask ||
124118 !rs->mCurrentMatch.evaluate (window))
125 if (window->state () & CompWindowStateSkipTaskbarMask)
126 return false;
127
128 if (!rs->mCurrentMatch.evaluate (window))
129 return false;119 return false;
130120
131 return true;121 return true;
@@ -139,21 +129,17 @@
139void129void
140RingScreen::renderWindowTitle ()130RingScreen::renderWindowTitle ()
141{131{
142 if (!textAvailable)132 if (!textAvailable || !optionGetWindowTitle ())
143 return;133 return;
144134
145 CompText::Attrib attrib;135 CompText::Attrib attrib;
146 CompRect oe;
147136
148 freeWindowTitle ();137 freeWindowTitle ();
149138
150 if (!mSelectedWindow)139 if (!mSelectedWindow)
151 return;140 return;
152141
153 if (!optionGetWindowTitle ())142 CompRect oe = screen->getCurrentOutputExtents ();
154 return;
155
156 oe = screen->getCurrentOutputExtents ();
157143
158 /* 75% of the output device as maximum width */144 /* 75% of the output device as maximum width */
159 attrib.maxWidth = oe.width () * 3 / 4;145 attrib.maxWidth = oe.width () * 3 / 4;
@@ -165,8 +151,10 @@
165 attrib.color[2] = optionGetTitleFontColorBlue ();151 attrib.color[2] = optionGetTitleFontColorBlue ();
166 attrib.color[3] = optionGetTitleFontColorAlpha ();152 attrib.color[3] = optionGetTitleFontColorAlpha ();
167 attrib.flags = CompText::WithBackground | CompText::Ellipsized;153 attrib.flags = CompText::WithBackground | CompText::Ellipsized;
154
168 if (optionGetTitleFontBold ())155 if (optionGetTitleFontBold ())
169 attrib.flags |= CompText::StyleBold;156 attrib.flags |= CompText::StyleBold;
157
170 attrib.family = "Sans";158 attrib.family = "Sans";
171 attrib.bgHMargin = 15;159 attrib.bgHMargin = 15;
172 attrib.bgVMargin = 15;160 attrib.bgVMargin = 15;
@@ -176,22 +164,22 @@
176 attrib.bgColor[3] = optionGetTitleBackColorAlpha ();164 attrib.bgColor[3] = optionGetTitleBackColorAlpha ();
177165
178 mText.renderWindowTitle (mSelectedWindow->id (),166 mText.renderWindowTitle (mSelectedWindow->id (),
179 mType == RingScreen::RingTypeAll,167 mType == RingScreen::RingTypeAll,
180 attrib);168 attrib);
181}169}
182170
183void171void
184RingScreen::drawWindowTitle (const GLMatrix &transform)172RingScreen::drawWindowTitle (const GLMatrix &transform)
185{173{
186 if (!textAvailable)174 if (!textAvailable || !optionGetWindowTitle ())
187 return;175 return;
188176
189 float x, y;177 CompRect oe = screen->getCurrentOutputExtents ();
190 CompRect oe;178
191179 float x = oe.centerX () - mText.getWidth () / 2;
192 oe = screen->getCurrentOutputExtents ();180 float y;
193181
194 x = oe.centerX () - mText.getWidth () / 2;182 unsigned short verticalOffset = optionGetVerticalOffset ();
195183
196 /* assign y (for the lower corner!) according to the setting */184 /* assign y (for the lower corner!) according to the setting */
197 switch (optionGetTitleTextPlacement ())185 switch (optionGetTitleTextPlacement ())
@@ -199,18 +187,20 @@
199 case RingOptions::TitleTextPlacementCenteredOnScreen:187 case RingOptions::TitleTextPlacementCenteredOnScreen:
200 y = oe.centerY () + mText.getHeight () / 2;188 y = oe.centerY () + mText.getHeight () / 2;
201 break;189 break;
202 case RingOptions::TitleTextPlacementAboveRing:190
203 case RingOptions::TitleTextPlacementBelowRing:191 case RingOptions::TitleTextPlacementTopOfScreenMinusOffset:
192 case RingOptions::TitleTextPlacementBottomOfScreenPlusOffset:
204 {193 {
205 CompRect workArea = screen->currentOutputDev ().workArea ();194 CompRect workArea = screen->currentOutputDev ().workArea ();
206195
207 if (optionGetTitleTextPlacement () ==196 if (optionGetTitleTextPlacement () ==
208 RingOptions::TitleTextPlacementAboveRing)197 RingOptions::TitleTextPlacementTopOfScreenMinusOffset)
209 y = oe.y1 () + workArea.y () + mText.getHeight ();198 y = oe.y1 () + workArea.y () + mText.getHeight () + verticalOffset;
210 else199 else /* TitleTextPlacementBottomOfScreenPlusOffset */
211 y = oe.y1 () + workArea.y2 ();200 y = oe.y1 () + workArea.y2 () - verticalOffset;
212 }201 }
213 break;202 break;
203
214 default:204 default:
215 return;205 return;
216 break;206 break;
@@ -222,23 +212,23 @@
222bool212bool
223RingWindow::glPaint (const GLWindowPaintAttrib &attrib,213RingWindow::glPaint (const GLWindowPaintAttrib &attrib,
224 const GLMatrix &transform,214 const GLMatrix &transform,
225 const CompRegion &region,215 const CompRegion &region,
226 unsigned int mask)216 unsigned int mask)
227{217{
228 bool status;
229
230 RING_SCREEN (screen);218 RING_SCREEN (screen);
231219
220 bool status;
221
232 if (rs->mState != RingScreen::RingStateNone)222 if (rs->mState != RingScreen::RingStateNone)
233 {223 {
234 GLWindowPaintAttrib sAttrib = attrib;224 GLWindowPaintAttrib sAttrib = attrib;
235 bool scaled = false;225 bool scaled = false;
236 bool pixmap = true;226 bool pixmap = true;
237227
238 if (window->mapNum ())228 if (window->mapNum () &&
229 gWindow->textures ().empty ())
239 {230 {
240 if (gWindow->textures ().empty ())231 gWindow->bind ();
241 gWindow->bind ();
242 }232 }
243233
244 if (mAdjust || mSlot)234 if (mAdjust || mSlot)
@@ -249,10 +239,8 @@
249 else if (rs->mState != RingScreen::RingStateIn)239 else if (rs->mState != RingScreen::RingStateIn)
250 {240 {
251 if (rs->optionGetDarkenBack ())241 if (rs->optionGetDarkenBack ())
252 {
253 /* modify brightness of the other windows */242 /* modify brightness of the other windows */
254 sAttrib.brightness = sAttrib.brightness / 2;243 sAttrib.brightness = sAttrib.brightness / 2;
255 }
256 }244 }
257245
258 status = gWindow->glPaint (sAttrib, transform, region, mask);246 status = gWindow->glPaint (sAttrib, transform, region, mask);
@@ -262,19 +250,18 @@
262 if (scaled && pixmap)250 if (scaled && pixmap)
263 {251 {
264 GLWindowPaintAttrib wAttrib (gWindow->lastPaintAttrib ());252 GLWindowPaintAttrib wAttrib (gWindow->lastPaintAttrib ());
265 GLMatrix wTransform = transform;253 GLMatrix wTransform = transform;
266254
267 if (mask & PAINT_WINDOW_OCCLUSION_DETECTION_MASK)255 if (mask & PAINT_WINDOW_OCCLUSION_DETECTION_MASK)
268 return false;256 return false;
269257
270 if (mSlot)258 if (mSlot)
271 {259 {
272 wAttrib.brightness = (float)wAttrib.brightness *260 wAttrib.brightness = (float)wAttrib.brightness * mSlot->depthBrightness;
273 mSlot->depthBrightness;
274261
275 if (window != rs->mSelectedWindow)262 if (window != rs->mSelectedWindow)
276 wAttrib.opacity = (float)wAttrib.opacity *263 wAttrib.opacity = (float)wAttrib.opacity *
277 rs->optionGetInactiveOpacity () / 100;264 rs->optionGetInactiveOpacity () / 100;
278 }265 }
279266
280 if (window->alpha () || wAttrib.opacity != OPAQUE)267 if (window->alpha () || wAttrib.opacity != OPAQUE)
@@ -283,8 +270,8 @@
283 wTransform.translate (window->x (), window->y (), 0.0f);270 wTransform.translate (window->x (), window->y (), 0.0f);
284 wTransform.scale (mScale, mScale, 1.0f);271 wTransform.scale (mScale, mScale, 1.0f);
285 wTransform.translate (mTx / mScale - window->x (),272 wTransform.translate (mTx / mScale - window->x (),
286 mTy / mScale - window->y (),273 mTy / mScale - window->y (),
287 0.0f);274 0.0f);
288275
289 gWindow->glDraw (wTransform, wAttrib, region,276 gWindow->glDraw (wTransform, wAttrib, region,
290 mask | PAINT_WINDOW_TRANSFORMED_MASK);277 mask | PAINT_WINDOW_TRANSFORMED_MASK);
@@ -297,22 +284,21 @@
297 GLTexture *icon;284 GLTexture *icon;
298285
299 icon = gWindow->getIcon (512, 512);286 icon = gWindow->getIcon (512, 512);
287
300 if (!icon)288 if (!icon)
301 icon = rs->gScreen->defaultIcon ();289 icon = rs->gScreen->defaultIcon ();
302290
303 if (icon)291 if (icon)
304 {292 {
305 GLTexture::Matrix matrix;293 GLTexture::Matrix matrix;
306 GLTexture::MatrixList matricies;294 GLTexture::MatrixList matricies;
307 float scale;295 float scale;
308 float x, y;296 float x, y;
309 int width, height;297
310 int scaledWinWidth, scaledWinHeight;298 enum RingOptions::OverlayIcon iconOverlay;
311299
312 enum RingOptions::OverlayIcon iconOverlay;300 int scaledWinWidth = window->width () * mScale;
313301 int scaledWinHeight = window->height () * mScale;
314 scaledWinWidth = window->width () * mScale;
315 scaledWinHeight = window->height () * mScale;
316302
317 if (!pixmap)303 if (!pixmap)
318 iconOverlay = RingOptions::OverlayIconBig;304 iconOverlay = RingOptions::OverlayIconBig;
@@ -320,35 +306,42 @@
320 iconOverlay = (enum RingOptions::OverlayIcon)306 iconOverlay = (enum RingOptions::OverlayIcon)
321 rs->optionGetOverlayIcon ();307 rs->optionGetOverlayIcon ();
322308
323 switch (iconOverlay) {309 switch (iconOverlay)
324 case RingOptions::OverlayIconNone:310 {
311 case RingOptions::OverlayIconNone:
325 case RingOptions::OverlayIconEmblem:312 case RingOptions::OverlayIconEmblem:
326 scale = (mSlot) ? mSlot->depthScale : 1.0f;313 scale = (mSlot) ? mSlot->depthScale : 1.0f;
327 if (icon->width () > ICON_SIZE ||314
328 icon->height () > ICON_SIZE)315 if (icon->width () > ICON_SIZE ||
316 icon->height () > ICON_SIZE)
329 scale = MIN ((scale * ICON_SIZE / icon->width ()),317 scale = MIN ((scale * ICON_SIZE / icon->width ()),
330 (scale * ICON_SIZE / icon->height ()));318 (scale * ICON_SIZE / icon->height ()));
319
331 break;320 break;
321
332 case RingOptions::OverlayIconBig:322 case RingOptions::OverlayIconBig:
333 default:323 default:
334 /* only change opacity if not painting an324 /* only change opacity if not painting an
335 icon for a minimized window */325 icon for a minimized window */
336 if (pixmap)326 if (pixmap)
337 sAttrib.opacity /= 3;327 sAttrib.opacity /= 3;
328
338 scale = MIN (((float) scaledWinWidth / icon->width ()),329 scale = MIN (((float) scaledWinWidth / icon->width ()),
339 ((float) scaledWinHeight / icon->height ()));330 ((float) scaledWinHeight / icon->height ()));
340 break;331 break;
341 }332 }
342333
343 width = icon->width () * scale;334 int width = icon->width () * scale;
344 height = icon->height () * scale;335 int height = icon->height () * scale;
345336
346 switch (iconOverlay) {337 switch (iconOverlay)
338 {
347 case RingOptions::OverlayIconNone:339 case RingOptions::OverlayIconNone:
348 case RingOptions::OverlayIconEmblem:340 case RingOptions::OverlayIconEmblem:
349 x = window->x () + scaledWinWidth - width;341 x = window->x () + scaledWinWidth - width;
350 y = window->y () + scaledWinHeight - height;342 y = window->y () + scaledWinHeight - height;
351 break;343 break;
344
352 case RingOptions::OverlayIconBig:345 case RingOptions::OverlayIconBig:
353 default:346 default:
354 x = window->x () + scaledWinWidth / 2 - width / 2;347 x = window->x () + scaledWinWidth / 2 - width / 2;
@@ -377,23 +370,24 @@
377370
378 gWindow->vertexBuffer ()->begin ();371 gWindow->vertexBuffer ()->begin ();
379 gWindow->glAddGeometry (matricies, iconReg, iconReg);372 gWindow->glAddGeometry (matricies, iconReg, iconReg);
373
380 if (gWindow->vertexBuffer ()->end ())374 if (gWindow->vertexBuffer ()->end ())
381 {375 {
382 GLWindowPaintAttrib wAttrib (sAttrib);376 GLWindowPaintAttrib wAttrib (sAttrib);
383 GLMatrix wTransform = transform;377 GLMatrix wTransform = transform;
384378
385 if (!pixmap)379 if (!pixmap)
386 sAttrib.opacity = gWindow->paintAttrib ().opacity;380 sAttrib.opacity = gWindow->paintAttrib ().opacity;
387381
388 if (mSlot)382 if (mSlot)
389 wAttrib.brightness = (float)wAttrib.brightness *383 wAttrib.brightness = (float)wAttrib.brightness *
390 mSlot->depthBrightness;384 mSlot->depthBrightness;
391385
392 wTransform.translate (window->x (), window->y (), 0.0f);386 wTransform.translate (window->x (), window->y (), 0.0f);
393 wTransform.scale (scale, scale, 1.0f);387 wTransform.scale (scale, scale, 1.0f);
394 wTransform.translate ((x - window->x ()) / scale - window->x (),388 wTransform.translate ((x - window->x ()) / scale - window->x (),
395 (y - window->y ()) / scale - window->y (),389 (y - window->y ()) / scale - window->y (),
396 0.0f);390 0.0f);
397391
398 gWindow->glDrawTexture (icon, wTransform, wAttrib, mask);392 gWindow->glDrawTexture (icon, wTransform, wAttrib, mask);
399 }393 }
@@ -401,17 +395,17 @@
401 }395 }
402 }396 }
403 else397 else
404 {
405 status = gWindow->glPaint (attrib, transform, region, mask);398 status = gWindow->glPaint (attrib, transform, region, mask);
406 }
407399
408 return status;400 return status;
409}401}
410402
411static inline float403static inline float
412ringLinearInterpolation (float valX,404ringLinearInterpolation (float valX,
413 float minX, float maxX,405 float minX,
414 float minY, float maxY)406 float maxX,
407 float minY,
408 float maxY)
415{409{
416 double factor = (maxY - minY) / (maxX - minX);410 double factor = (maxY - minY) / (maxX - minX);
417 return (minY + (factor * (valX - minX)));411 return (minY + (factor * (valX - minX)));
@@ -434,41 +428,35 @@
434RingWindow::compareRingWindowDepth (RingScreen::RingDrawSlot e1,428RingWindow::compareRingWindowDepth (RingScreen::RingDrawSlot e1,
435 RingScreen::RingDrawSlot e2)429 RingScreen::RingDrawSlot e2)
436{430{
437 RingScreen::RingSlot *a1 = (*(e1.slot));431 RingScreen::RingSlot *a1 = (*(e1.slot));
438 RingScreen::RingSlot *a2 = (*(e2.slot));432 RingScreen::RingSlot *a2 = (*(e2.slot));
439433
440 if (a1->y < a2->y)434 if (a1->y < a2->y)
441 return true;435 return true;
442 else if (a1->y > a2->y)436 else /* if (a1->y >= a2->y) */
443 return false;
444 else
445 return false;437 return false;
446}438}
447439
448bool440bool
449RingScreen::layoutThumbs ()441RingScreen::layoutThumbs ()
450{442{
451 float baseAngle, angle;443 float angle;
452 int index = 0;444 int index = 0;
453 int ww, wh;
454 float xScale, yScale;445 float xScale, yScale;
455 int centerX, centerY;
456 int ellipseA, ellipseB;
457 CompRect oe;
458446
459 if ((mState == RingStateNone) || (mState == RingStateIn))447 if ((mState == RingStateNone) || (mState == RingStateIn))
460 return false;448 return false;
461449
462 baseAngle = (2 * PI * mRotTarget) / 3600;450 float baseAngle = (2 * PI * mRotTarget) / 3600;
463451
464 oe = screen->getCurrentOutputExtents ();452 CompRect oe = screen->getCurrentOutputExtents ();
465453
466 /* the center of the ellipse is in the middle454 /* the center of the ellipse is in the middle
467 of the used output device */455 of the used output device */
468 centerX = oe.centerX ();456 int centerX = oe.centerX ();
469 centerY = oe.centerY ();457 int centerY = oe.centerY ();
470 ellipseA = oe.width () * optionGetRingWidth () / 200;458 int ellipseA = oe.width () * optionGetRingWidth () / 200;
471 ellipseB = oe.height () * optionGetRingHeight () / 200;459 int ellipseB = oe.height () * optionGetRingHeight () / 200;
472460
473 mDrawSlots.resize (mWindows.size ());461 mDrawSlots.resize (mWindows.size ());
474462
@@ -487,11 +475,11 @@
487 angle = baseAngle - (index * (2 * PI / mWindows.size ()));475 angle = baseAngle - (index * (2 * PI / mWindows.size ()));
488476
489 rw->mSlot->x = centerX + (optionGetRingClockwise () ? -1 : 1) *477 rw->mSlot->x = centerX + (optionGetRingClockwise () ? -1 : 1) *
490 ((float) ellipseA * sin (angle));478 ((float) ellipseA * sin (angle));
491 rw->mSlot->y = centerY + ((float) ellipseB * cos (angle));479 rw->mSlot->y = centerY + ((float) ellipseB * cos (angle));
492480
493 ww = w->width () + w->input ().left + w->input ().right;481 int ww = w->width () + w->input ().left + w->input ().right;
494 wh = w->height () + w->input ().top + w->input ().bottom;482 int wh = w->height () + w->input ().top + w->input ().bottom;
495483
496 if (ww > optionGetThumbWidth ())484 if (ww > optionGetThumbWidth ())
497 xScale = (float)(optionGetThumbWidth ()) / (float) ww;485 xScale = (float)(optionGetThumbWidth ()) / (float) ww;
@@ -522,7 +510,7 @@
522 mDrawSlots.at (index).w = w;510 mDrawSlots.at (index).w = w;
523 mDrawSlots.at (index).slot = &rw->mSlot;511 mDrawSlots.at (index).slot = &rw->mSlot;
524512
525 index++;513 ++index;
526 }514 }
527515
528 /* sort the draw list so that the windows with the516 /* sort the draw list so that the windows with the
@@ -547,6 +535,7 @@
547 sort (mWindows.begin (), mWindows.end (), RingWindow::compareWindows);535 sort (mWindows.begin (), mWindows.end (), RingWindow::compareWindows);
548536
549 mRotTarget = 0;537 mRotTarget = 0;
538
550 foreach (CompWindow *w, mWindows)539 foreach (CompWindow *w, mWindows)
551 {540 {
552 if (w == mSelectedWindow)541 if (w == mSelectedWindow)
@@ -566,6 +555,7 @@
566 foreach (CompWindow *w, screen->windows ())555 foreach (CompWindow *w, screen->windows ())
567 {556 {
568 RING_WINDOW (w);557 RING_WINDOW (w);
558
569 if (rw->is ())559 if (rw->is ())
570 {560 {
571 addWindowToList (w);561 addWindowToList (w);
@@ -589,7 +579,8 @@
589 {579 {
590 if (w == mSelectedWindow)580 if (w == mSelectedWindow)
591 break;581 break;
592 cur++;582
583 ++cur;
593 }584 }
594585
595 if (cur == mWindows.size ())586 if (cur == mWindows.size ())
@@ -605,6 +596,7 @@
605 CompWindow *old = mSelectedWindow;596 CompWindow *old = mSelectedWindow;
606597
607 mSelectedWindow = w;598 mSelectedWindow = w;
599
608 if (old != w)600 if (old != w)
609 {601 {
610 if (toNext)602 if (toNext)
@@ -623,14 +615,14 @@
623int615int
624RingScreen::countWindows ()616RingScreen::countWindows ()
625{617{
626 int count = 0;618 int count = 0;
627619
628 foreach (CompWindow *w, screen->windows ())620 foreach (CompWindow *w, screen->windows ())
629 {621 {
630 RING_WINDOW (w);622 RING_WINDOW (w);
631623
632 if (rw->is ())624 if (rw->is ())
633 count++;625 ++count;
634 }626 }
635627
636 return count;628 return count;
@@ -639,13 +631,11 @@
639int631int
640RingScreen::adjustRingRotation (float chunk)632RingScreen::adjustRingRotation (float chunk)
641{633{
642 float dx, adjust, amount;634 float dx = mRotAdjust;
643 int change;635
644636 float adjust = dx * 0.15f;
645 dx = mRotAdjust;637 float amount = fabs (dx) * 1.5f;
646638
647 adjust = dx * 0.15f;
648 amount = fabs (dx) * 1.5f;
649 if (amount < 0.2f)639 if (amount < 0.2f)
650 amount = 0.2f;640 amount = 0.2f;
651 else if (amount > 2.0f)641 else if (amount > 2.0f)
@@ -661,7 +651,8 @@
661 return 0;651 return 0;
662 }652 }
663653
664 change = mRVelocity * chunk;654 int change = mRVelocity * chunk;
655
665 if (!change)656 if (!change)
666 {657 {
667 if (mRVelocity)658 if (mRVelocity)
@@ -680,7 +671,6 @@
680int671int
681RingWindow::adjustVelocity ()672RingWindow::adjustVelocity ()
682{673{
683 float dx, dy, ds, adjust, amount;
684 float x1, y1, scale;674 float x1, y1, scale;
685675
686 if (mSlot)676 if (mSlot)
@@ -696,10 +686,11 @@
696 y1 = window->y ();686 y1 = window->y ();
697 }687 }
698688
699 dx = x1 - (window->x () + mTx);689 float dx = x1 - (window->x () + mTx);
700690
701 adjust = dx * 0.15f;691 float adjust = dx * 0.15f;
702 amount = fabs (dx) * 1.5f;692 float amount = fabs (dx) * 1.5f;
693
703 if (amount < 0.5f)694 if (amount < 0.5f)
704 amount = 0.5f;695 amount = 0.5f;
705 else if (amount > 5.0f)696 else if (amount > 5.0f)
@@ -707,10 +698,11 @@
707698
708 mXVelocity = (amount * mXVelocity + adjust) / (amount + 1.0f);699 mXVelocity = (amount * mXVelocity + adjust) / (amount + 1.0f);
709700
710 dy = y1 - (window->y () + mTy);701 float dy = y1 - (window->y () + mTy);
711702
712 adjust = dy * 0.15f;703 adjust = dy * 0.15f;
713 amount = fabs (dy) * 1.5f;704 amount = fabs (dy) * 1.5f;
705
714 if (amount < 0.5f)706 if (amount < 0.5f)
715 amount = 0.5f;707 amount = 0.5f;
716 else if (amount > 5.0f)708 else if (amount > 5.0f)
@@ -718,16 +710,16 @@
718710
719 mYVelocity = (amount * mYVelocity + adjust) / (amount + 1.0f);711 mYVelocity = (amount * mYVelocity + adjust) / (amount + 1.0f);
720712
721 ds = scale - mScale;713 float ds = scale - mScale;
722 adjust = ds * 0.1f;714 adjust = ds * 0.1f;
723 amount = fabs (ds) * 7.0f;715 amount = fabs (ds) * 7.0f;
716
724 if (amount < 0.01f)717 if (amount < 0.01f)
725 amount = 0.01f;718 amount = 0.01f;
726 else if (amount > 0.15f)719 else if (amount > 0.15f)
727 amount = 0.15f;720 amount = 0.15f;
728721
729 mScaleVelocity = (amount * mScaleVelocity + adjust) /722 mScaleVelocity = (amount * mScaleVelocity + adjust) / (amount + 1.0f);
730 (amount + 1.0f);
731723
732 if (fabs (dx) < 0.1f && fabs (mXVelocity) < 0.2f &&724 if (fabs (dx) < 0.1f && fabs (mXVelocity) < 0.2f &&
733 fabs (dy) < 0.1f && fabs (mYVelocity) < 0.2f &&725 fabs (dy) < 0.1f && fabs (mYVelocity) < 0.2f &&
@@ -746,19 +738,17 @@
746738
747bool739bool
748RingScreen::glPaintOutput (const GLScreenPaintAttrib &attrib,740RingScreen::glPaintOutput (const GLScreenPaintAttrib &attrib,
749 const GLMatrix &transform,741 const GLMatrix &transform,
750 const CompRegion &region,742 const CompRegion &region,
751 CompOutput *output,743 CompOutput *output,
752 unsigned int mask)744 unsigned int mask)
753{745{
754 bool status;
755
756 if (mState != RingStateNone)746 if (mState != RingStateNone)
757 mask |= PAINT_SCREEN_WITH_TRANSFORMED_WINDOWS_MASK;747 mask |= PAINT_SCREEN_WITH_TRANSFORMED_WINDOWS_MASK;
758748
759 //mask |= PAINT_SCREEN_NO_OCCLUSION_DETECTION_MASK;749 //mask |= PAINT_SCREEN_NO_OCCLUSION_DETECTION_MASK;
760750
761 status = gScreen->glPaintOutput (attrib, transform, region, output, mask);751 bool status = gScreen->glPaintOutput (attrib, transform, region, output, mask);
762752
763 if (mState != RingStateNone)753 if (mState != RingStateNone)
764 {754 {
@@ -770,7 +760,6 @@
770760
771 if (mState == RingScreen::RingStateSwitching ||761 if (mState == RingScreen::RingStateSwitching ||
772 mState == RingScreen::RingStateOut)762 mState == RingScreen::RingStateOut)
773 {
774 for (std::vector <RingDrawSlot>::iterator it = mDrawSlots.begin ();763 for (std::vector <RingDrawSlot>::iterator it = mDrawSlots.begin ();
775 it != mDrawSlots.end (); ++it)764 it != mDrawSlots.end (); ++it)
776 {765 {
@@ -779,9 +768,8 @@
779 RING_WINDOW (w);768 RING_WINDOW (w);
780769
781 status |= rw->gWindow->glPaint (rw->gWindow->paintAttrib (),770 status |= rw->gWindow->glPaint (rw->gWindow->paintAttrib (),
782 sTransform, infiniteRegion, 0);771 sTransform, infiniteRegion, 0);
783 }772 }
784 }
785773
786 if (mState != RingStateIn)774 if (mState != RingStateIn)
787 drawWindowTitle (sTransform);775 drawWindowTitle (sTransform);
@@ -795,15 +783,12 @@
795{783{
796 if (mState != RingStateNone && (mMoreAdjust || mRotateAdjust))784 if (mState != RingStateNone && (mMoreAdjust || mRotateAdjust))
797 {785 {
798 int steps;786 float amount = msSinceLastPaint * 0.05f * optionGetSpeed ();
799 float amount, chunk;787 int steps = amount / (0.5f * optionGetTimestep ());
800
801 amount = msSinceLastPaint * 0.05f * optionGetSpeed ();
802 steps = amount / (0.5f * optionGetTimestep ());
803788
804 if (!steps)789 if (!steps)
805 steps = 1;790 steps = 1;
806 chunk = amount / (float) steps;791 float chunk = amount / (float) steps;
807792
808 while (steps--)793 while (steps--)
809 {794 {
@@ -851,9 +836,7 @@
851 if (mState != RingStateNone)836 if (mState != RingStateNone)
852 {837 {
853 if (mMoreAdjust)838 if (mMoreAdjust)
854 {
855 cScreen->damageScreen ();839 cScreen->damageScreen ();
856 }
857 else840 else
858 {841 {
859 if (mRotateAdjust)842 if (mRotateAdjust)
@@ -879,38 +862,37 @@
879{862{
880 if (mGrabIndex)863 if (mGrabIndex)
881 {864 {
882 screen->removeGrab (mGrabIndex, 0);865 screen->removeGrab (mGrabIndex, 0);
883 mGrabIndex = 0;866 mGrabIndex = 0;
884 }867 }
885868
886 if (mState != RingStateNone)869 if (mState != RingStateNone)
887 {870 {
888 foreach (CompWindow *w, screen->windows ())871 foreach (CompWindow *w, screen->windows ())
889 {872 {
890 RING_WINDOW (w);873 RING_WINDOW (w);
891874
892 if (rw->mSlot)875 if (rw->mSlot)
893 {876 {
894 delete rw->mSlot;877 delete rw->mSlot;
895 rw->mSlot = NULL;878 rw->mSlot = NULL;
896879
897 rw->mAdjust = true;880 rw->mAdjust = true;
898 }881 }
899 }882 }
900 mMoreAdjust = true;883
901 mState = RingStateIn;884 mMoreAdjust = true;
902 cScreen->damageScreen ();885 mState = RingStateIn;
903886 cScreen->damageScreen ();
904 if (!(state & CompAction::StateCancel) &&887
905 mSelectedWindow && !mSelectedWindow->destroyed ())888 if (!(state & CompAction::StateCancel) &&
906 {889 mSelectedWindow && !mSelectedWindow->destroyed ())
907 screen->sendWindowActivationRequest (mSelectedWindow->id ());890 screen->sendWindowActivationRequest (mSelectedWindow->id ());
908 }
909 }891 }
910892
911 if (action)893 if (action)
912 action->setState ( ~(CompAction::StateTermKey |894 action->setState ( ~(CompAction::StateTermKey |
913 CompAction::StateTermButton |895 CompAction::StateTermButton |
914 CompAction::StateTermEdge));896 CompAction::StateTermEdge));
915897
916 return false;898 return false;
@@ -921,25 +903,20 @@
921 CompAction::State state,903 CompAction::State state,
922 CompOption::Vector options)904 CompOption::Vector options)
923{905{
924 int count;
925
926 if (screen->otherGrabExist ("ring", NULL))906 if (screen->otherGrabExist ("ring", NULL))
927 return false;907 return false;
928908
929 mCurrentMatch = optionGetWindowMatch ();909 mCurrentMatch = optionGetWindowMatch ();
930910
931 mMatch = CompOption::getMatchOptionNamed (options, "match", CompMatch ());911 mMatch = CompOption::getMatchOptionNamed (options, "match", CompMatch ());
912
932 if (!mMatch.isEmpty ())913 if (!mMatch.isEmpty ())
933 {
934 mCurrentMatch = mMatch;914 mCurrentMatch = mMatch;
935 }
936915
937 count = countWindows ();916 int count = countWindows ();
938917
939 if (count < 1)918 if (count < 1)
940 {
941 return false;919 return false;
942 }
943920
944 if (!mGrabIndex)921 if (!mGrabIndex)
945 {922 {
@@ -960,7 +937,7 @@
960 renderWindowTitle ();937 renderWindowTitle ();
961 mRotTarget = 0;938 mRotTarget = 0;
962939
963 mMoreAdjust = true;940 mMoreAdjust = true;
964 toggleFunctions (true);941 toggleFunctions (true);
965 cScreen->damageScreen ();942 cScreen->damageScreen ();
966943
@@ -974,46 +951,42 @@
974RingScreen::doSwitch (CompAction *action,951RingScreen::doSwitch (CompAction *action,
975 CompAction::State state,952 CompAction::State state,
976 CompOption::Vector options,953 CompOption::Vector options,
977 bool nextWindow,954 bool nextWindow,
978 RingType type)955 RingType type)
979{956{
980 bool ret = true;957 bool ret = true;
981958
982 if ((mState == RingStateNone) || (mState == RingStateIn))959 if ((mState == RingStateNone) || (mState == RingStateIn))
983 {960 {
984 if (type == RingTypeGroup)961 if (type == RingTypeGroup)
985 {962 {
986 CompWindow *w;963 CompWindow *w = screen->findWindow (CompOption::getIntOptionNamed (options,
987 w = screen->findWindow (CompOption::getIntOptionNamed (options,964 "window", 0));
988 "window",965
989 0));
990 if (w)966 if (w)
991 {967 {
992 mType = RingTypeGroup;968 mType = RingTypeGroup;
993 mClientLeader =969 mClientLeader = (w->clientLeader ()) ? w->clientLeader () : w->id ();
994 (w->clientLeader ()) ? w->clientLeader () : w->id ();970 ret = initiate (action, state, options);
995 ret = initiate (action, state, options);
996 }971 }
997 }972 }
998 else973 else
999 {974 {
1000 mType = type;975 mType = type;
1001 ret = initiate (action, mState, options);976 ret = initiate (action, mState, options);
1002 }977 }
1003978
1004 if (state & CompAction::StateInitKey)979 if (state & CompAction::StateInitKey)
1005 action->setState (action->state () | CompAction::StateTermKey);980 action->setState (action->state () | CompAction::StateTermKey);
1006981
1007 if (state & CompAction::StateInitEdge)982 if (state & CompAction::StateInitEdge)
1008 action->setState (action->state () | CompAction::StateTermEdge);983 action->setState (action->state () | CompAction::StateTermEdge);
1009 else if (mState & CompAction::StateInitButton)984 else if (mState & CompAction::StateInitButton)
1010 action->setState (action->state () |985 action->setState (action->state () | CompAction::StateTermButton);
1011 CompAction::StateTermButton);
1012 }986 }
1013987
1014 if (ret)988 if (ret)
1015 switchToWindow (nextWindow);989 switchToWindow (nextWindow);
1016
1017990
1018 return ret;991 return ret;
1019}992}
@@ -1033,11 +1006,12 @@
1033 foreach (CompWindow *w, mWindows)1006 foreach (CompWindow *w, mWindows)
1034 {1007 {
1035 RING_WINDOW (w);1008 RING_WINDOW (w);
1036 if (rw->mSlot)1009
1010 if (rw->mSlot)
1037 {1011 {
1038 if ((x >= (rw->mTx + w->x ())) &&1012 if ((x >= (rw->mTx + w->x ())) &&
1039 (x <= (rw->mTx + w->x () + (w->width () * rw->mScale))) &&1013 (x <= (rw->mTx + w->x () + (w->width () * rw->mScale))) &&
1040 (y >= (rw->mTy + w->y ())) &&1014 (y >= (rw->mTy + w->y ())) &&
1041 (y <= (rw->mTy + w->y () + (w->height () * rw->mScale))))1015 (y <= (rw->mTy + w->y () + (w->height () * rw->mScale))))
1042 {1016 {
1043 /* we have found one, select it */1017 /* we have found one, select it */
@@ -1063,14 +1037,13 @@
1063 else if (!shouldTerminate && (selected != mSelectedWindow ))1037 else if (!shouldTerminate && (selected != mSelectedWindow ))
1064 {1038 {
1065 if (!selected)1039 if (!selected)
1066 {
1067 freeWindowTitle ();1040 freeWindowTitle ();
1068 }
1069 else1041 else
1070 {1042 {
1071 mSelectedWindow = selected;1043 mSelectedWindow = selected;
1072 renderWindowTitle ();1044 renderWindowTitle ();
1073 }1045 }
1046
1074 cScreen->damageScreen ();1047 cScreen->damageScreen ();
1075 }1048 }
1076}1049}
@@ -1080,19 +1053,18 @@
1080{1053{
1081 if (w)1054 if (w)
1082 {1055 {
1083 bool inList = false;
1084 CompWindow *selected;
1085 CompWindowVector::iterator it = mWindows.begin ();
1086
1087 RING_WINDOW (w);
1088
1089 if (mState == RingStateNone)1056 if (mState == RingStateNone)
1090 return;1057 return;
10911058
1059 RING_WINDOW (w);
1060
1092 if (!rw->is (true))1061 if (!rw->is (true))
1093 return;1062 return;
10941063
1064 bool inList = false;
1065 CompWindow *selected;
1095 selected = mSelectedWindow;1066 selected = mSelectedWindow;
1067 CompWindowVector::iterator it = mWindows.begin ();
10961068
1097 while (it != mWindows.end ())1069 while (it != mWindows.end ())
1098 {1070 {
@@ -1103,10 +1075,12 @@
1103 if (w == selected)1075 if (w == selected)
1104 {1076 {
1105 ++it;1077 ++it;
1078
1106 if (it != mWindows.end ())1079 if (it != mWindows.end ())
1107 selected = *it;1080 selected = *it;
1108 else1081 else
1109 selected = mWindows.front ();1082 selected = mWindows.front ();
1083
1110 --it;1084 --it;
11111085
1112 mSelectedWindow = selected;1086 mSelectedWindow = selected;
@@ -1116,6 +1090,7 @@
1116 mWindows.erase (it);1090 mWindows.erase (it);
1117 break;1091 break;
1118 }1092 }
1093
1119 ++it;1094 ++it;
1120 }1095 }
11211096
@@ -1156,7 +1131,8 @@
1156{1131{
1157 CompWindow *w = NULL;1132 CompWindow *w = NULL;
11581133
1159 switch (event->type) {1134 switch (event->type)
1135 {
1160 case DestroyNotify:1136 case DestroyNotify:
1161 /* We need to get the CompWindow * for event->xdestroywindow.window1137 /* We need to get the CompWindow * for event->xdestroywindow.window
1162 here because in the ::screen->handleEvent call below, that1138 here because in the ::screen->handleEvent call below, that
@@ -1164,57 +1140,64 @@
1164 able to find the CompWindow after that. */1140 able to find the CompWindow after that. */
1165 w = ::screen->findWindow (event->xdestroywindow.window);1141 w = ::screen->findWindow (event->xdestroywindow.window);
1166 break;1142 break;
1143
1167 default:1144 default:
1168 break;1145 break;
1169 }1146 }
11701147
1171 screen->handleEvent (event);1148 screen->handleEvent (event);
11721149
1173 switch (event->type) {1150 switch (event->type)
1174 case PropertyNotify:1151 {
1175 if (event->xproperty.atom == XA_WM_NAME)1152 case PropertyNotify:
1176 {1153 if (event->xproperty.atom == XA_WM_NAME)
1177 w = screen->findWindow (event->xproperty.window);
1178 if (w)
1179 {1154 {
1180 if (mGrabIndex && (w == mSelectedWindow))1155 w = screen->findWindow (event->xproperty.window);
1181 {1156
1182 renderWindowTitle ();1157 if (w &&
1183 cScreen->damageScreen ();1158 mGrabIndex && (w == mSelectedWindow))
1159 {
1160 renderWindowTitle ();
1161 cScreen->damageScreen ();
1184 }1162 }
1185 }1163 }
1186 }1164
1187 break;1165 break;
1188 case ButtonPress:1166
1189 if (event->xbutton.button == Button1)1167 case ButtonPress:
1190 {1168 if (event->xbutton.button == Button1 &&
1169 mGrabIndex)
1170 windowSelectAt (event->xbutton.x_root,
1171 event->xbutton.y_root, true);
1172
1173 break;
1174
1175 case MotionNotify:
1191 if (mGrabIndex)1176 if (mGrabIndex)
1192 windowSelectAt (event->xbutton.x_root,1177 windowSelectAt (event->xmotion.x_root,
1193 event->xbutton.y_root,1178 event->xmotion.y_root, false);
1194 true);1179
1195 }1180 break;
1196 break;1181
1197 case MotionNotify:1182 case UnmapNotify:
1198 if (mGrabIndex)1183 w = ::screen->findWindow (event->xunmap.window);
1199 windowSelectAt (event->xmotion.x_root,1184 windowRemove (w);
1200 event->xmotion.y_root,1185 break;
1201 false);1186
1202 break;1187 case DestroyNotify:
1203 case UnmapNotify:1188 windowRemove (w);
1204 w = ::screen->findWindow (event->xunmap.window);1189 break;
1205 windowRemove (w);1190
1206 break;1191 default:
1207 case DestroyNotify:1192 break;
1208 windowRemove (w);
1209 break;
1210 }1193 }
1211}1194}
12121195
1213bool1196bool
1214RingWindow::damageRect (bool initial,1197RingWindow::damageRect (bool initial,
1215 const CompRect &rect)1198 const CompRect &rect)
1216{1199{
1217 bool status = false;1200 bool status = false;
12181201
1219 RING_SCREEN (screen);1202 RING_SCREEN (screen);
12201203
@@ -1223,6 +1206,7 @@
1223 if (rs->mGrabIndex && is ())1206 if (rs->mGrabIndex && is ())
1224 {1207 {
1225 rs->addWindowToList (window);1208 rs->addWindowToList (window);
1209
1226 if (rs->updateWindowList ())1210 if (rs->updateWindowList ())
1227 {1211 {
1228 mAdjust = true;1212 mAdjust = true;
@@ -1232,17 +1216,12 @@
1232 }1216 }
1233 }1217 }
1234 }1218 }
1235 else if (rs->mState == RingScreen::RingStateSwitching)1219 else if (rs->mState == RingScreen::RingStateSwitching &&
1220 mSlot)
1236 {1221 {
12371222 cWindow->damageTransformedRect (mScale, mScale,
1238 if (mSlot)1223 mTx, mTy, rect);
1239 {1224 status = true;
1240 cWindow->damageTransformedRect (mScale, mScale,
1241 mTx, mTy,
1242 rect);
1243 status = true;
1244 }
1245
1246 }1225 }
12471226
1248 status |= cWindow->damageRect (initial, rect);1227 status |= cWindow->damageRect (initial, rect);
@@ -1305,7 +1284,6 @@
1305 RINGTERMBIND (PrevGroupButton, terminate);1284 RINGTERMBIND (PrevGroupButton, terminate);
1306}1285}
13071286
1308
1309RingScreen::~RingScreen ()1287RingScreen::~RingScreen ()
1310{1288{
1311 mWindows.clear ();1289 mWindows.clear ();

Subscribers

People subscribed via source and target branches

to all changes: