Skip to content
Closed
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
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down Expand Up @@ -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),
Expand Down Expand Up @@ -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();
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,11 @@ const constants = {
Title: 3,
Focused: 4
},
CountNumbers: {
None: 1,
Window: 2,
Notification: 3
},
FavType: {
favorites: 0,
pinnedApps: 1,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
});
}
Expand All @@ -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);
}

Expand All @@ -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;
Expand Down