Skip to content

Commit 3779122

Browse files
committed
grouped-window-list: Make appGroup's flashButton sane, fix invalid
source id. There's no need for nesting here, or starting a new timeout for each iteration. Also, the highlight should stay active until the user focuses the window, not removed at the end of the flash cycle.
1 parent da1cdb2 commit 3779122

File tree

1 file changed

+30
-26
lines changed

1 file changed

+30
-26
lines changed

files/usr/share/cinnamon/applets/[email protected]/appGroup.js

Lines changed: 30 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
const Cinnamon = imports.gi.Cinnamon;
22
const Meta = imports.gi.Meta;
33
const Clutter = imports.gi.Clutter;
4+
const GLib = imports.gi.GLib;
45
const St = imports.gi.St;
56
const Main = imports.ui.main;
67
const Tweener = imports.ui.tweener;
@@ -304,35 +305,40 @@ class AppGroup {
304305
if (this._needsAttention) return;
305306

306307
this._needsAttention = true;
307-
let counter = 0;
308-
this.flashButton(counter);
308+
this.flashButton();
309309
}
310310

311-
flashButton(counter) {
312-
if (!this._needsAttention || !this.actor) return;
311+
flashButton() {
312+
if (!this._needsAttention || !this.actor || this._flashTimer)
313+
return;
313314

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)
317316
return;
318-
}
319317

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";
328320

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+
});
336342
}
337343

338344
getPreferredWidth(actor, forHeight, alloc) {
@@ -597,9 +603,7 @@ class AppGroup {
597603
if (hasFocus) {
598604
this.listState.trigger('updateFocusState', appId);
599605
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');
603607
this._needsAttention = false;
604608
} else {
605609
this.actor.remove_style_pseudo_class('focus');

0 commit comments

Comments
 (0)