Skip to content

Commit 3e1fca6

Browse files
authored
Grouped window list: Add option to only list windows from the current monitor (#12225)
Grouped window list: Add option to only list windows from the current monitor
1 parent 2b18f7f commit 3e1fca6

File tree

2 files changed

+47
-24
lines changed

2 files changed

+47
-24
lines changed

files/usr/share/cinnamon/applets/[email protected]/applet.js

Lines changed: 35 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -328,7 +328,8 @@ class GroupedWindowListApplet extends Applet.Applet {
328328
{key: 'show-recent', value: 'showRecent', cb: null},
329329
{key: 'autostart-menu-item', value: 'autoStart', cb: null},
330330
{key: 'monitor-move-all-windows', value: 'monitorMoveAllWindows', cb: null},
331-
{key: 'show-all-workspaces', value: 'showAllWorkspaces', cb: this.refreshAllAppLists}
331+
{key: 'show-all-workspaces', value: 'showAllWorkspaces', cb: this.refreshAllAppLists},
332+
{key: 'window-display-settings', value: 'windowDisplaySettings', cb: this.reloadAllAppsMonitor}
332333
];
333334

334335
for (let i = 0, len = settingsProps.length; i < len; i++) {
@@ -503,39 +504,51 @@ class GroupedWindowListApplet extends Applet.Applet {
503504

504505
}
505506

507+
reloadAllAppsMonitor(){
508+
this.refreshAllAppLists();
509+
this.updateMonitorWatchlist();
510+
}
511+
506512
updateMonitorWatchlist() {
507513
if (!this.numberOfMonitors) {
508514
this.numberOfMonitors = global.display.get_n_monitors();
509515
}
510516
const onPrimary = this.panel.monitorIndex === Main.layoutManager.primaryIndex;
511517
const instances = Main.AppletManager.getRunningInstancesForUuid(this.state.uuid);
512518
let {monitorWatchList} = this.state;
513-
/* Simple cases */
514-
if (this.numberOfMonitors === 1) {
515-
monitorWatchList = [Main.layoutManager.primaryIndex];
516-
} else if (instances.length > 1 && !onPrimary) {
517-
monitorWatchList = [this.panel.monitorIndex];
519+
520+
// Show all applications from all monitors
521+
if (this.state.settings.windowDisplaySettings === 2) {
522+
monitorWatchList = Array.from({ length: this.numberOfMonitors }, (_, i) => i);
523+
518524
} else {
519-
/* This is an instance on the primary monitor - it will be
520-
* responsible for any monitors not covered individually. First
521-
* convert the instances list into a list of the monitor indices,
522-
* and then add the monitors not present to the monitor watch list
523-
* */
524-
monitorWatchList = [this.panel.monitorIndex];
525-
for (let i = 0; i < instances.length; i++) {
526-
if (!instances[i]) {
527-
continue;
525+
// Original logic
526+
if (this.numberOfMonitors === 1) {
527+
monitorWatchList = [Main.layoutManager.primaryIndex];
528+
} else if (instances.length > 1 && !onPrimary) {
529+
monitorWatchList = [this.panel.monitorIndex];
530+
} else {
531+
/* This is an instance on the primary monitor - it will be
532+
* responsible for any monitors not covered individually. First
533+
* convert the instances list into a list of the monitor indices,
534+
* and then add the monitors not present to the monitor watch list
535+
* */
536+
monitorWatchList = [this.panel.monitorIndex];
537+
for (let i = 0; i < instances.length; i++) {
538+
if (!instances[i]) {
539+
continue;
540+
}
541+
instances[i] = instances[i].panel.monitorIndex;
528542
}
529-
instances[i] = instances[i].panel.monitorIndex;
530-
}
531-
532-
for (let i = 0; i < this.numberOfMonitors; i++) {
533-
if (instances.indexOf(i) === -1) {
534-
monitorWatchList.push(i);
543+
for (let i = 0; i < this.numberOfMonitors; i++) {
544+
if (instances.indexOf(i) === -1) {
545+
monitorWatchList.push(i);
546+
}
535547
}
536548
}
537549
}
538-
this.state.set({monitorWatchList});
550+
this.state.set({ monitorWatchList });
551+
global.log("Monitor Watch List updated: " + JSON.stringify(monitorWatchList));
539552
}
540553

541554
refreshCurrentAppList() {

files/usr/share/cinnamon/applets/[email protected]/settings-schema.json

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,8 @@
3030
"scroll-behavior",
3131
"left-click-action",
3232
"middle-click-action",
33-
"show-all-workspaces"
33+
"show-all-workspaces",
34+
"window-display-settings"
3435
]
3536
},
3637
"appButtonsSection": {
@@ -149,6 +150,15 @@
149150
"default": false,
150151
"description": "Show windows from all workspaces"
151152
},
153+
"window-display-settings": {
154+
"type": "combobox",
155+
"default": 1,
156+
"description": "Window display mode",
157+
"options": {
158+
"Track windows individually per monitor": 1,
159+
"Always track windows from all monitors": 2
160+
}
161+
},
152162
"enable-app-button-dragging": {
153163
"type": "checkbox",
154164
"default": true,
@@ -299,4 +309,4 @@
299309
"units": "percent",
300310
"description": "Window opacity"
301311
}
302-
}
312+
}

0 commit comments

Comments
 (0)