From 8cc94892df45566baf19b00bb887ce780e98acca Mon Sep 17 00:00:00 2001 From: jarierca Date: Sat, 8 Jun 2024 16:27:27 +0200 Subject: [PATCH] Grouped window list: Add option to only list windows from the current monitor --- .../applet.js | 56 ++++++++++++------- .../settings-schema.json | 10 +++- 2 files changed, 43 insertions(+), 23 deletions(-) diff --git a/files/usr/share/cinnamon/applets/grouped-window-list@cinnamon.org/applet.js b/files/usr/share/cinnamon/applets/grouped-window-list@cinnamon.org/applet.js index 1bdead4aa3..57293888e0 100644 --- a/files/usr/share/cinnamon/applets/grouped-window-list@cinnamon.org/applet.js +++ b/files/usr/share/cinnamon/applets/grouped-window-list@cinnamon.org/applet.js @@ -328,7 +328,8 @@ class GroupedWindowListApplet extends Applet.Applet { {key: 'show-recent', value: 'showRecent', cb: null}, {key: 'autostart-menu-item', value: 'autoStart', cb: null}, {key: 'monitor-move-all-windows', value: 'monitorMoveAllWindows', cb: null}, - {key: 'show-all-workspaces', value: 'showAllWorkspaces', cb: this.refreshAllAppLists} + {key: 'show-all-workspaces', value: 'showAllWorkspaces', cb: this.refreshAllAppLists}, + {key: 'list-monitor-windows', value: 'listMonitorWindows', cb: this.reloadAllAppsMonitor} ]; for (let i = 0, len = settingsProps.length; i < len; i++) { @@ -503,6 +504,11 @@ class GroupedWindowListApplet extends Applet.Applet { } + reloadAllAppsMonitor(){ + this.refreshAllAppLists(); + this.updateMonitorWatchlist(); + } + updateMonitorWatchlist() { if (!this.numberOfMonitors) { this.numberOfMonitors = global.display.get_n_monitors(); @@ -510,32 +516,40 @@ class GroupedWindowListApplet extends Applet.Applet { const onPrimary = this.panel.monitorIndex === Main.layoutManager.primaryIndex; const instances = Main.AppletManager.getRunningInstancesForUuid(this.state.uuid); let {monitorWatchList} = this.state; - /* Simple cases */ - if (this.numberOfMonitors === 1) { - monitorWatchList = [Main.layoutManager.primaryIndex]; - } else if (instances.length > 1 && !onPrimary) { - monitorWatchList = [this.panel.monitorIndex]; + + // Show all applications from all monitors + if (!this.state.settings.listMonitorWindows) { + monitorWatchList = Array.from({ length: this.numberOfMonitors }, (_, i) => i); + } else { - /* This is an instance on the primary monitor - it will be - * responsible for any monitors not covered individually. First - * convert the instances list into a list of the monitor indices, - * and then add the monitors not present to the monitor watch list - * */ - monitorWatchList = [this.panel.monitorIndex]; - for (let i = 0; i < instances.length; i++) { - if (!instances[i]) { - continue; + // Original logic + if (this.numberOfMonitors === 1) { + monitorWatchList = [Main.layoutManager.primaryIndex]; + } else if (instances.length > 1 && !onPrimary) { + monitorWatchList = [this.panel.monitorIndex]; + } else { + /* This is an instance on the primary monitor - it will be + * responsible for any monitors not covered individually. First + * convert the instances list into a list of the monitor indices, + * and then add the monitors not present to the monitor watch list + * */ + monitorWatchList = [this.panel.monitorIndex]; + for (let i = 0; i < instances.length; i++) { + if (!instances[i]) { + continue; + } + instances[i] = instances[i].panel.monitorIndex; } - instances[i] = instances[i].panel.monitorIndex; - } - for (let i = 0; i < this.numberOfMonitors; i++) { - if (instances.indexOf(i) === -1) { - monitorWatchList.push(i); + for (let i = 0; i < this.numberOfMonitors; i++) { + if (instances.indexOf(i) === -1) { + monitorWatchList.push(i); + } } } } - this.state.set({monitorWatchList}); + this.state.set({ monitorWatchList }); + global.log("Monitor Watch List updated: " + JSON.stringify(monitorWatchList)); } refreshCurrentAppList() { diff --git a/files/usr/share/cinnamon/applets/grouped-window-list@cinnamon.org/settings-schema.json b/files/usr/share/cinnamon/applets/grouped-window-list@cinnamon.org/settings-schema.json index d0e63eff20..9bca928d70 100644 --- a/files/usr/share/cinnamon/applets/grouped-window-list@cinnamon.org/settings-schema.json +++ b/files/usr/share/cinnamon/applets/grouped-window-list@cinnamon.org/settings-schema.json @@ -30,7 +30,8 @@ "scroll-behavior", "left-click-action", "middle-click-action", - "show-all-workspaces" + "show-all-workspaces", + "list-monitor-windows" ] }, "appButtonsSection": { @@ -149,6 +150,11 @@ "default": false, "description": "Show windows from all workspaces" }, + "list-monitor-windows": { + "type": "checkbox", + "default": true, + "description": "Only list windows from the current monitor" + }, "enable-app-button-dragging": { "type": "checkbox", "default": true, @@ -299,4 +305,4 @@ "units": "percent", "description": "Window opacity" } -} \ No newline at end of file +}