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