|
1 | 1 | const Cinnamon = imports.gi.Cinnamon; |
2 | 2 | const Meta = imports.gi.Meta; |
3 | 3 | const Clutter = imports.gi.Clutter; |
| 4 | +const GLib = imports.gi.GLib; |
4 | 5 | const St = imports.gi.St; |
5 | 6 | const Main = imports.ui.main; |
6 | 7 | const Tweener = imports.ui.tweener; |
@@ -304,35 +305,40 @@ class AppGroup { |
304 | 305 | if (this._needsAttention) return; |
305 | 306 |
|
306 | 307 | this._needsAttention = true; |
307 | | - let counter = 0; |
308 | | - this.flashButton(counter); |
| 308 | + this.flashButton(); |
309 | 309 | } |
310 | 310 |
|
311 | | - flashButton(counter) { |
312 | | - if (!this._needsAttention || !this.actor) return; |
| 311 | + flashButton() { |
| 312 | + if (!this._needsAttention || !this.actor || this._flashTimer) |
| 313 | + return; |
313 | 314 |
|
314 | | - // If the app was closed during a flash sequence, stop looping. |
315 | | - if (!this.groupState.groupReady && this.groupState.isFavoriteApp) { |
316 | | - this.actor.remove_style_class_name('grouped-window-list-item-demands-attention'); |
| 315 | + if (!this.groupState.groupReady && this.groupState.isFavoriteApp) |
317 | 316 | return; |
318 | | - } |
319 | 317 |
|
320 | | - this.actor.remove_style_pseudo_class('active'); |
321 | | - this.actor.add_style_class_name('grouped-window-list-item-demands-attention'); |
322 | | - if (counter < FLASH_MAX_COUNT) { |
323 | | - this.flashTimer = Mainloop.timeout_add(FLASH_INTERVAL, () => { |
324 | | - if (this.actor && this.actor.has_style_class_name('grouped-window-list-item-demands-attention')) { |
325 | | - this.actor.remove_style_class_name('grouped-window-list-item-demands-attention'); |
326 | | - this.actor.add_style_pseudo_class('active'); |
327 | | - } |
| 318 | + let counter = 0; |
| 319 | + const sc = "grouped-window-list-item-demands-attention"; |
328 | 320 |
|
329 | | - this.flashTimer = Mainloop.timeout_add(FLASH_INTERVAL, () => { |
330 | | - this.flashButton(++counter); |
331 | | - }); |
332 | | - }); |
333 | | - } else { |
334 | | - this.flashTimer = 0; |
335 | | - } |
| 321 | + this.flashTimer = Mainloop.timeout_add(FLASH_INTERVAL, () => { |
| 322 | + if (!this._needsAttention) { |
| 323 | + this.flashTimer = 0; |
| 324 | + return GLib.SOURCE_REMOVE; |
| 325 | + } |
| 326 | + |
| 327 | + if (this.actor.has_style_class_name(sc)) { |
| 328 | + this.actor.add_style_class_name("active"); |
| 329 | + this.actor.remove_style_class_name(sc); |
| 330 | + } |
| 331 | + else { |
| 332 | + this.actor.remove_style_class_name("active") |
| 333 | + this.actor.add_style_class_name(sc); |
| 334 | + } |
| 335 | + |
| 336 | + const continueFlashing = (counter++ < FLASH_MAX_COUNT); |
| 337 | + if (!continueFlashing) { |
| 338 | + this.flashTimer = 0; |
| 339 | + } |
| 340 | + return continueFlashing; |
| 341 | + }); |
336 | 342 | } |
337 | 343 |
|
338 | 344 | getPreferredWidth(actor, forHeight, alloc) { |
@@ -597,9 +603,7 @@ class AppGroup { |
597 | 603 | if (hasFocus) { |
598 | 604 | this.listState.trigger('updateFocusState', appId); |
599 | 605 | this.actor.add_style_pseudo_class('focus'); |
600 | | - if (this.actor.has_style_class_name('grouped-window-list-item-demands-attention')) { |
601 | | - this.actor.remove_style_class_name('grouped-window-list-item-demands-attention'); |
602 | | - } |
| 606 | + this.actor.remove_style_class_name('grouped-window-list-item-demands-attention'); |
603 | 607 | this._needsAttention = false; |
604 | 608 | } else { |
605 | 609 | this.actor.remove_style_pseudo_class('focus'); |
|
0 commit comments