Skip to content

Commit

Permalink
Grouped window list: Add option to only list windows from the current…
Browse files Browse the repository at this point in the history
… monitor
  • Loading branch information
jarierca committed Jun 8, 2024
1 parent fee5a32 commit 8cc9489
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 23 deletions.
56 changes: 35 additions & 21 deletions files/usr/share/cinnamon/applets/[email protected]/applet.js
Original file line number Diff line number Diff line change
Expand Up @@ -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++) {
Expand Down Expand Up @@ -503,39 +504,52 @@ class GroupedWindowListApplet extends Applet.Applet {

}

reloadAllAppsMonitor(){
this.refreshAllAppLists();
this.updateMonitorWatchlist();
}

updateMonitorWatchlist() {
if (!this.numberOfMonitors) {
this.numberOfMonitors = global.display.get_n_monitors();
}
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() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@
"scroll-behavior",
"left-click-action",
"middle-click-action",
"show-all-workspaces"
"show-all-workspaces",
"list-monitor-windows"
]
},
"appButtonsSection": {
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -299,4 +305,4 @@
"units": "percent",
"description": "Window opacity"
}
}
}

0 comments on commit 8cc9489

Please sign in to comment.