Skip to content

Commit b1db347

Browse files
committed
gwl: Simplify appGroup windowRemoved method
It makes sense to call the callback to clean the appGroup if willUnmount is set true as well, however no need to only perform updates to the groupstate otherwise considering things like removing thumbnails have to be performed anyways, and considering the appGroup, in case of no open windows in the appGroup, or willUnmount is set, will be removed anyways, it likely shouldn't cause issues.
1 parent bc85e28 commit b1db347

1 file changed

Lines changed: 17 additions & 17 deletions

File tree

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

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -995,36 +995,36 @@ var AppGroup = class AppGroup {
995995
}
996996

997997
windowRemoved(metaWorkspace, metaWindow, refWindow, cb) {
998-
if (refWindow === -1) return;
998+
if (!metaWindow) return;
999999

10001000
this.signals.disconnect('notify::title', metaWindow);
10011001
this.signals.disconnect('notify::appears-focused', metaWindow);
10021002
this.signals.disconnect('notify::icon', metaWindow);
10031003
this.signals.disconnect('notify::progress', metaWindow);
10041004

1005-
const metaWindows = this.groupState.metaWindows.filter((w) => w != metaWindow);
1005+
const metaWindows = this.groupState.metaWindows.filter((w) => w != metaWindow);
10061006

10071007
if (this.progressOverlay.visible) this.onProgressChange();
10081008

1009-
if (!this.groupState.willUnmount) {
1010-
const lastFocused = this.groupState.lastFocused === metaWindow
1011-
? getLastFocusedWindow(metaWindows)
1012-
: this.groupState.lastFocused;
1013-
this.groupState.set({metaWindows: metaWindows, lastFocused: lastFocused}, true);
1014-
this.onWindowTitleChanged(lastFocused);
1015-
if (this.hoverMenu) this.groupState.trigger('removeThumbnailFromMenu', metaWindow);
1016-
this.calcWindowNumber();
1017-
}
1009+
const lastFocused = this.groupState.lastFocused === metaWindow
1010+
? getLastFocusedWindow(metaWindows)
1011+
: this.groupState.lastFocused;
1012+
1013+
this.groupState.set({metaWindows: metaWindows, lastFocused: lastFocused}, true);
1014+
1015+
if (lastFocused) this.onWindowTitleChanged(lastFocused);
10181016

1019-
if (metaWindows.length === 0) {
1017+
if (this.hoverMenu) this.groupState.trigger('removeThumbnailFromMenu', metaWindow);
1018+
1019+
this.calcWindowNumber();
1020+
1021+
if ((metaWindows.length === 0 || this.groupState.willUnmount) && typeof cb === 'function') {
10201022
// This is the last window, so this group needs to be destroyed. We'll call back windowRemoved
10211023
// in workspace to put the final nail in the coffin.
1022-
if (typeof cb === 'function') {
1023-
if (this.hoverMenu && this.groupState.isFavoriteApp) {
1024-
this.groupState.trigger('removeThumbnailFromMenu', metaWindow);
1025-
}
1026-
cb(this.groupState.appId, this.groupState.isFavoriteApp);
1024+
if (this.hoverMenu && this.groupState.isFavoriteApp) {
1025+
this.groupState.trigger('removeThumbnailFromMenu', metaWindow);
10271026
}
1027+
cb(this.groupState.appId, this.groupState.isFavoriteApp);
10281028
}
10291029
}
10301030

0 commit comments

Comments
 (0)