Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Grouped window list: Add option to only list windows from the current monitor #12225

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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"
}
}
}