Skip to content

Commit eda15c6

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 a8f7626 commit eda15c6

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
@@ -994,36 +994,36 @@ class AppGroup {
994994
}
995995

996996
windowRemoved(metaWorkspace, metaWindow, refWindow, cb) {
997-
if (refWindow === -1) return;
997+
if (!metaWindow) return;
998998

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

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

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

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

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

0 commit comments

Comments
 (0)