Skip to content
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
38 changes: 28 additions & 10 deletions files/usr/share/cinnamon/applets/[email protected]/applet.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,11 @@ const {
class PinnedFavs {
constructor(params) {
this.params = params;
this.params.settings.bind(
'share-pinned-windows', // key
'sharePinnedWindows', // value
() => this.saveFavorites() // cb
);
this.reload();
}

Expand Down Expand Up @@ -65,16 +70,31 @@ class PinnedFavs {
}
}

applyPins(ids, pinnedFavorites = this) {
pinnedFavorites.params.settings.setValue('pinned-apps', ids);
pinnedFavorites.onFavoritesChange();
}

saveFavorites() {
const uniqueSet = new Set();
const ids = [];
for (let i = 0; i < this._favorites.length; i++) {
if (uniqueSet.has(this._favorites[i].id) === false) {
ids.push(this._favorites[i].id);
uniqueSet.add(this._favorites[i].id);
}
let newPins = [...new Set(this._favorites.map(e => e.id))];
const SHARING_PINS = this.params.settings.getValue('share-pinned-windows');
const BASE_CURRENT_PINS = this.params.settings.getValue('pinned-apps');
const REMOVED_PINS = BASE_CURRENT_PINS.filter(p => !newPins.includes(p));
this.applyPins(newPins);
if (SHARING_PINS) {
const INSTANCES = Main.AppletManager.getRunningInstancesForUuid(this.params.state.uuid);
for (let instance of INSTANCES) {
const otherPinnedFavorites = instance.pinnedFavorites;
if (otherPinnedFavorites === this) continue;
newPins = [...newPins];
// This ensures other window lists do not lose pins that were not in this window list.
const OTHER_CURRENT_PINS = otherPinnedFavorites.params.settings.getValue('pinned-apps');
OTHER_CURRENT_PINS.forEach(e => {
if (!REMOVED_PINS.includes(e) && !newPins.includes(e)) newPins.push(e);
});
this.applyPins(newPins, otherPinnedFavorites);
};
}
this.params.settings.setValue('pinned-apps', ids);
}

onFavoritesChange() {
Expand Down Expand Up @@ -138,7 +158,6 @@ class PinnedFavs {
}

this.saveFavorites();
this.onFavoritesChange();
return true;
}

Expand All @@ -156,7 +175,6 @@ class PinnedFavs {
this.triggerUpdate(appId, false);
this._favorites.splice(refFav, 1);
this.saveFavorites();
this.onFavoritesChange();
return true;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@
"left-click-action",
"middle-click-action",
"show-all-workspaces",
"window-display-settings"
"window-display-settings",
"share-pinned-windows"
]
},
"hotKeysSection": {
Expand Down Expand Up @@ -139,6 +140,11 @@
"From all monitors": 2
}
},
"share-pinned-windows": {
"type": "checkbox",
"default": false,
"description": "Share pinned windows with all window lists"
},
"cycleMenusHotkey": {
"type": "keybinding",
"default": "",
Expand Down