Skip to content

Commit

Permalink
gwl: Track the getThumbnail timeout source id.
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
mtwebster committed Aug 3, 2023
1 parent e2cb99a commit a69d30b
Showing 1 changed file with 17 additions and 2 deletions.
19 changes: 17 additions & 2 deletions files/usr/share/cinnamon/applets/[email protected]/menus.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ const PopupMenu = imports.ui.popupMenu;
const Applet = imports.ui.applet;
const SignalManager = imports.misc.signalManager;
const WindowUtils = imports.misc.windowUtils;
const Mainloop = imports.mainloop;

const {each, findIndex, tryFn, unref, trySpawnCommandLine, spawn_async, getDesktopActionIcon} = imports.misc.util;
const {
Expand Down Expand Up @@ -534,6 +535,8 @@ class WindowThumbnail {
this.metaWindow = params.metaWindow;
this.index = params.index;

this.get_thumb_id = 0;

this.metaWindowActor = null;
this.thumbnailPadding = 16;
this.willUnmount = false;
Expand Down Expand Up @@ -821,9 +824,16 @@ class WindowThumbnail {
}

this.labelContainer.child.text = this.metaWindow.title || '';
setTimeout(() => {

if (this.get_thumb_id > 0) {
Mainloop.source_remove(this.get_thumb_id);
}

this.get_thumb_id = Mainloop.timeout_add(0, () => {
this.get_thumb_id = 0;
this.getThumbnail(thumbnailWidth, thumbnailHeight);
}, 0);
return false;
});
}

hoverPeek(opacity) {
Expand Down Expand Up @@ -878,6 +888,11 @@ class WindowThumbnail {
this.willUnmount = true;
if (!this.groupState) return;

if (this.get_thumb_id > 0) {
Mainloop.source_remove(this.get_thumb_id);
this.get_thumb_id = 0;
}

this.state.disconnect(this.stateConnectId);
this.groupState.disconnect(this.connectId);
this.signals.disconnectAllSignals();
Expand Down

0 comments on commit a69d30b

Please sign in to comment.