Skip to content

Commit a69d30b

Browse files
committed
gwl: Track the getThumbnail timeout source id.
Follow-up to 2faa38d, this timeout can be hit multiple times before a window actor is created for a new window, so any existing timer should be replaced.
1 parent e2cb99a commit a69d30b

File tree

1 file changed

+17
-2
lines changed

1 file changed

+17
-2
lines changed

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

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ const PopupMenu = imports.ui.popupMenu;
99
const Applet = imports.ui.applet;
1010
const SignalManager = imports.misc.signalManager;
1111
const WindowUtils = imports.misc.windowUtils;
12+
const Mainloop = imports.mainloop;
1213

1314
const {each, findIndex, tryFn, unref, trySpawnCommandLine, spawn_async, getDesktopActionIcon} = imports.misc.util;
1415
const {
@@ -534,6 +535,8 @@ class WindowThumbnail {
534535
this.metaWindow = params.metaWindow;
535536
this.index = params.index;
536537

538+
this.get_thumb_id = 0;
539+
537540
this.metaWindowActor = null;
538541
this.thumbnailPadding = 16;
539542
this.willUnmount = false;
@@ -821,9 +824,16 @@ class WindowThumbnail {
821824
}
822825

823826
this.labelContainer.child.text = this.metaWindow.title || '';
824-
setTimeout(() => {
827+
828+
if (this.get_thumb_id > 0) {
829+
Mainloop.source_remove(this.get_thumb_id);
830+
}
831+
832+
this.get_thumb_id = Mainloop.timeout_add(0, () => {
833+
this.get_thumb_id = 0;
825834
this.getThumbnail(thumbnailWidth, thumbnailHeight);
826-
}, 0);
835+
return false;
836+
});
827837
}
828838

829839
hoverPeek(opacity) {
@@ -878,6 +888,11 @@ class WindowThumbnail {
878888
this.willUnmount = true;
879889
if (!this.groupState) return;
880890

891+
if (this.get_thumb_id > 0) {
892+
Mainloop.source_remove(this.get_thumb_id);
893+
this.get_thumb_id = 0;
894+
}
895+
881896
this.state.disconnect(this.stateConnectId);
882897
this.groupState.disconnect(this.connectId);
883898
this.signals.disconnectAllSignals();

0 commit comments

Comments
 (0)