diff --git a/files/usr/share/cinnamon/applets/grouped-window-list@cinnamon.org/appGroup.js b/files/usr/share/cinnamon/applets/grouped-window-list@cinnamon.org/appGroup.js index 6a0f0990c5..fdfad94e75 100644 --- a/files/usr/share/cinnamon/applets/grouped-window-list@cinnamon.org/appGroup.js +++ b/files/usr/share/cinnamon/applets/grouped-window-list@cinnamon.org/appGroup.js @@ -19,7 +19,8 @@ const { MAX_BUTTON_WIDTH, BUTTON_BOX_ANIMATION_TIME, RESERVE_KEYS, - TitleDisplay + TitleDisplay, + CountNumbers } = require('./constants'); const _reLetterRtl = new RegExp("\\p{Script=Hebrew}|\\p{Script=Arabic}", "u"); @@ -70,6 +71,7 @@ class AppGroup { appInfo: params.app.get_app_info(), metaWindows: params.metaWindows || [], windowCount: params.metaWindows ? params.metaWindows.length : 0, + notificationCount: params.notificationCount ?? 0, lastFocused: params.metaWindow || null, isFavoriteApp: !params.metaWindow ? true : params.isFavoriteApp === true, autoStartIndex: this.state.autoStartApps.findIndex( app => app.id === params.appId), @@ -1071,23 +1073,49 @@ class AppGroup { this.checkFocusStyle(); } + notificationReceived(notification) { + if (this.groupState.willUnmount) return; + + this.groupState.set({ notificationCount: this.groupState.notificationCount + 1 }); + this.showBadge(); + } + + resetNotificationCount() { + if (this.groupState.willUnmount) return; + + this.groupState.set({ notificationCount: 0 }); + this.showBadge(); + } + calcWindowNumber() { if (this.groupState.willUnmount) return; - const windowCount = this.groupState.metaWindows ? this.groupState.metaWindows.length : 0; - this.numberLabel.text = windowCount.toString(); + this.groupState.set({windowCount: this.groupState.metaWindows ? this.groupState.metaWindows.length : 0}); + this.showBadge(); + } - this.groupState.set({windowCount}); + showBadge(){ + if(this.state.settings.numDisplay == CountNumbers.None){ + this.badge.hide(); + return; + } - if (this.state.settings.numDisplay) { - if (windowCount <= 1) { - this.badge.hide(); - } else { - this.badge.show(); + let numberToShow = 0; + let minNumberToShow = 0; - } + if (this.state.settings.numDisplay == CountNumbers.Notification) { + numberToShow = this.groupState.notificationCount; } else { + numberToShow = this.groupState.windowCount; + minNumberToShow = 1; + } + + this.numberLabel.text = numberToShow.toString(); + + if (numberToShow <= minNumberToShow) { this.badge.hide(); + } else { + this.badge.show(); } } diff --git a/files/usr/share/cinnamon/applets/grouped-window-list@cinnamon.org/constants.js b/files/usr/share/cinnamon/applets/grouped-window-list@cinnamon.org/constants.js index 51b08467e4..ebf9a4921b 100644 --- a/files/usr/share/cinnamon/applets/grouped-window-list@cinnamon.org/constants.js +++ b/files/usr/share/cinnamon/applets/grouped-window-list@cinnamon.org/constants.js @@ -18,6 +18,11 @@ const constants = { Title: 3, Focused: 4 }, + CountNumbers: { + None: 1, + Window: 2, + Notification: 3 + }, FavType: { favorites: 0, pinnedApps: 1, 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 b86af45073..c3bbe6077f 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 @@ -185,9 +185,14 @@ } }, "number-display": { - "type": "checkbox", - "default": true, - "description": "Show window count numbers" + "type": "combobox", + "default": 2, + "description": "Show count numbers", + "options": { + "None": 1, + "Window": 2, + "Notification": 3 + } }, "enable-app-button-dragging": { "type": "checkbox", diff --git a/files/usr/share/cinnamon/applets/grouped-window-list@cinnamon.org/workspace.js b/files/usr/share/cinnamon/applets/grouped-window-list@cinnamon.org/workspace.js index 4329489297..209388fcc0 100644 --- a/files/usr/share/cinnamon/applets/grouped-window-list@cinnamon.org/workspace.js +++ b/files/usr/share/cinnamon/applets/grouped-window-list@cinnamon.org/workspace.js @@ -32,7 +32,10 @@ class Workspace { }, updateFocusState: (focusedAppId) => { this.appGroups.forEach( appGroup => { - if (focusedAppId === appGroup.groupState.appId) return; + if (focusedAppId === appGroup.groupState.appId) { + appGroup.resetNotificationCount(); + return; + } appGroup.onFocusChange(false); }); } @@ -53,6 +56,7 @@ class Workspace { // Ugly change: refresh the removed app instances from all workspaces this.signals.connect(this.metaWorkspace, 'window-removed', (...args) => this.windowRemoved(...args)); this.signals.connect(global.window_manager, 'switch-workspace' , (...args) => this.reloadList(...args)); + Main.messageTray.connect('notify-applet-update', (mtray, notification) => this.calculateAppNotifications(mtray, notification)); this.on_orientation_changed(null, true); } @@ -77,6 +81,16 @@ class Workspace { return windowCount; } + calculateAppNotifications(mtray, notification) { + var appId = notification.source.app.get_id(); + this.appGroups.forEach(appGroup => { + if (appId === appGroup.groupState.appId) { + appGroup.notificationReceived(notification); + return; + } + }); + } + closeAllHoverMenus(cb) { this.appGroups.forEach( appGroup => { const {hoverMenu, groupState} = appGroup;