Skip to content

Commit 9990948

Browse files
committed
gwl: Let workspace.windowAdded arbitrate over if metaWindow should be added to the workspace
This already checks if window is in correct workspace and/or windows should be shown in all workspaces, plus checking the monitor using the shouldWindowBeAdded method.
1 parent b1db347 commit 9990948

File tree

3 files changed

+16
-30
lines changed

3 files changed

+16
-30
lines changed

files/usr/share/cinnamon/applets/grouped-window-list@cinnamon.org/appGroup.js

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -64,8 +64,9 @@ const getFocusState = function(metaWindow) {
6464
const getLastFocusedWindow = function(metaWindows) {
6565
let lastFocusedWindow = null;
6666
for (let i = 0; i < metaWindows.length; i++) {
67-
if (!lastFocusedWindow || (metaWindows[i].get_user_time() > lastFocusedWindow.get_user_time())) {
68-
lastFocusedWindow = metaWindows[i];
67+
const metaWindow = metaWindows[i];
68+
if (!lastFocusedWindow || (metaWindow.get_user_time() > lastFocusedWindow.get_user_time())) {
69+
lastFocusedWindow = metaWindow;
6970
}
7071
}
7172
return lastFocusedWindow;
@@ -1019,11 +1020,6 @@ var AppGroup = class AppGroup {
10191020
this.calcWindowNumber();
10201021

10211022
if ((metaWindows.length === 0 || this.groupState.willUnmount) && typeof cb === 'function') {
1022-
// This is the last window, so this group needs to be destroyed. We'll call back windowRemoved
1023-
// in workspace to put the final nail in the coffin.
1024-
if (this.hoverMenu && this.groupState.isFavoriteApp) {
1025-
this.groupState.trigger('removeThumbnailFromMenu', metaWindow);
1026-
}
10271023
cb(this.groupState.appId, this.groupState.isFavoriteApp);
10281024
}
10291025
}

files/usr/share/cinnamon/applets/grouped-window-list@cinnamon.org/applet.js

Lines changed: 9 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -449,16 +449,12 @@ class GroupedWindowListApplet extends Applet.Applet {
449449
}
450450

451451
onWindowMonitorChanged(display, metaWindow, monitor) {
452-
const metaWorkspace = metaWindow.get_workspace();
453-
if ((this.state.monitorWatchList.length !== this.numberOfMonitors) && metaWorkspace) {
454-
const windowWorkspace = this.workspaces.find(
455-
workspace => workspace.metaWorkspace && workspace.metaWorkspace.index() === metaWorkspace.index()
456-
);
457-
458-
if (windowWorkspace !== null) {
459-
windowWorkspace.windowRemoved(metaWorkspace, metaWindow);
460-
windowWorkspace.windowAdded(metaWorkspace, metaWindow);
461-
}
452+
if ((this.state.monitorWatchList.length !== this.numberOfMonitors)) {
453+
this.workspaces.forEach( workspace => {
454+
if (!workspace) return;
455+
workspace.windowRemoved(workspace.metaWorkspace, metaWindow);
456+
workspace.windowAdded(workspace.metaWorkspace, metaWindow);
457+
});
462458
}
463459
}
464460

@@ -1021,15 +1017,10 @@ class GroupedWindowListApplet extends Applet.Applet {
10211017

10221018
_onWindowAppChanged(tracker, metaWindow) {
10231019
if (!metaWindow) return;
1024-
1025-
const windowWorkspace = metaWindow.get_workspace();
1026-
10271020
this.workspaces.forEach(workspace => {
10281021
if (!workspace) return;
1029-
if (windowWorkspace && (workspace.metaWorkspace.index() === windowWorkspace.index())) {
1030-
workspace.windowRemoved(workspace.metaWorkspace, metaWindow);
1031-
workspace.windowAdded(workspace.metaWorkspace, metaWindow);
1032-
}
1022+
workspace.windowRemoved(workspace.metaWorkspace, metaWindow);
1023+
workspace.windowAdded(workspace.metaWorkspace, metaWindow);
10331024
});
10341025
}
10351026

@@ -1040,7 +1031,7 @@ class GroupedWindowListApplet extends Applet.Applet {
10401031

10411032
_onNotificationReceived(mtray, notification) {
10421033
let appId = notification.source.app?.get_id();
1043-
1034+
10441035
if (!appId) {
10451036
return;
10461037
}

files/usr/share/cinnamon/applets/grouped-window-list@cinnamon.org/workspace.js

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -234,16 +234,15 @@ var Workspace = class Workspace {
234234

235235
shouldWindowBeAdded(metaWindow) {
236236
return (this.state.settings.showAllWorkspaces
237-
|| metaWindow.is_on_all_workspaces()
238-
|| metaWindow.get_workspace() === this.metaWorkspace)
237+
|| metaWindow.is_on_all_workspaces()
238+
|| (metaWindow.get_workspace().index() === this.metaWorkspace.index()))
239239
&& Main.isInteresting(metaWindow)
240240
&& this.state.monitorWatchList.indexOf(metaWindow.get_monitor()) > -1;
241241
}
242242

243243
windowWorkspaceChanged(display, metaWindow, metaWorkspace) {
244-
// If the window is removed the metaWorkspace will be null, in that
245-
// case we wouldn't want to add the window again.
246-
if (metaWorkspace && this.metaWorkspace.index() === metaWorkspace.index()) {
244+
// If the window is removed the metaWorkspace will be null.
245+
if (metaWorkspace) {
247246
this.windowAdded(metaWorkspace, metaWindow);
248247
} else {
249248
this.windowRemoved(metaWorkspace, metaWindow);

0 commit comments

Comments
 (0)