@@ -70,6 +70,7 @@ class AppGroup {
7070 appInfo : params . app . get_app_info ( ) ,
7171 metaWindows : params . metaWindows || [ ] ,
7272 windowCount : params . metaWindows ? params . metaWindows . length : 0 ,
73+ notificationCount : 0 ,
7374 lastFocused : params . metaWindow || null ,
7475 isFavoriteApp : ! params . metaWindow ? true : params . isFavoriteApp === true ,
7576 autoStartIndex : this . state . autoStartApps . findIndex ( app => app . id === params . appId ) ,
@@ -119,31 +120,50 @@ class AppGroup {
119120 } ) ;
120121 this . actor . add_child ( this . progressOverlay ) ;
121122
122- // Create the app button icon, number label , and text label for titleDisplay
123+ // Create the app button icon, window count and notification badges , and text label for titleDisplay
123124 this . iconBox = new Cinnamon . Slicer ( { name : 'appMenuIcon' } ) ;
124125 this . actor . add_child ( this . iconBox ) ;
125126 this . setActorAttributes ( null , params . metaWindow ) ;
126127
127- this . badge = new St . BoxLayout ( {
128- style_class : 'grouped-window-list-badge' ,
128+ this . windowsBadge = new St . BoxLayout ( {
129+ style_class : 'grouped-window-list-windows- badge' ,
129130 important : true ,
131+ x_align : St . Align . MIDDLE ,
132+ y_align : St . Align . MIDDLE ,
133+ show_on_set_parent : false ,
134+ } ) ;
135+ this . windowsBadgeLabel = new St . Label ( {
136+ style_class : 'grouped-window-list-windows-badge-label' ,
137+ important : true ,
138+ text : ''
139+ } ) ;
140+ this . windowsBadgeLabel . clutter_text . ellipsize = false ;
141+ this . windowsBadge . add ( this . windowsBadgeLabel , {
130142 x_align : St . Align . START ,
143+ y_align : St . Align . START ,
144+ } ) ;
145+ this . actor . add_child ( this . windowsBadge ) ;
146+ this . windowsBadge . set_text_direction ( St . TextDirection . LTR ) ;
147+
148+ this . notificationsBadge = new St . BoxLayout ( {
149+ style_class : 'grouped-window-list-notifications-badge' ,
150+ important : true ,
151+ x_align : St . Align . MIDDLE ,
131152 y_align : St . Align . MIDDLE ,
132153 show_on_set_parent : false ,
133154 } ) ;
134- this . numberLabel = new St . Label ( {
135- style_class : 'grouped-window-list-number -label' ,
155+ this . notificationsBadgeLabel = new St . Label ( {
156+ style_class : 'grouped-window-list-notifications-badge -label' ,
136157 important : true ,
137- text : '' ,
138- anchor_x : - 3 * global . ui_scale ,
158+ text : ''
139159 } ) ;
140- this . numberLabel . clutter_text . ellipsize = false ;
141- this . badge . add ( this . numberLabel , {
160+ this . notificationsBadgeLabel . clutter_text . ellipsize = false ;
161+ this . notificationsBadge . add ( this . notificationsBadgeLabel , {
142162 x_align : St . Align . START ,
143163 y_align : St . Align . START ,
144164 } ) ;
145- this . actor . add_child ( this . badge ) ;
146- this . badge . set_text_direction ( St . TextDirection . LTR ) ;
165+ this . actor . add_child ( this . notificationsBadge ) ;
166+ this . notificationsBadge . set_text_direction ( St . TextDirection . LTR ) ;
147167
148168 this . label = new St . Label ( {
149169 style_class : 'grouped-window-list-button-label' ,
@@ -394,15 +414,23 @@ class AppGroup {
394414
395415 this . iconBox . allocate ( childBox , flags ) ;
396416
397- // Set badge position
398- const windowCountFactor = this . groupState . windowCount > 9 ? 1.5 : 2 ;
399- const badgeOffset = 2 * global . ui_scale ;
400- childBox . x1 = childBox . x1 - badgeOffset ;
401- childBox . x2 = childBox . x1 + ( this . numberLabel . width * windowCountFactor ) ;
402- childBox . y1 = Math . max ( childBox . y1 - badgeOffset , 0 ) ;
403- childBox . y2 = childBox . y1 + this . badge . get_preferred_height ( childBox . get_width ( ) ) [ 1 ] ;
417+ this . updateBadgesTextSize ( ) ;
418+
419+ // Set windows badge position
420+ childBox . x1 = box . x1 ;
421+ childBox . x2 = childBox . x1 + this . windowsBadgeLabel . width ;
422+ childBox . y1 = box . y2 - this . windowsBadge . get_preferred_height ( childBox . get_width ( ) ) [ 1 ] ;
423+ childBox . y2 = box . y2 ;
424+
425+ this . windowsBadge . allocate ( childBox , flags ) ;
404426
405- this . badge . allocate ( childBox , flags ) ;
427+ // Set notifications badge position
428+ childBox . x2 = box . x2 ;
429+ childBox . x1 = childBox . x2 - this . notificationsBadgeLabel . width ;
430+ childBox . y1 = box . y1 ;
431+ childBox . y2 = childBox . y1 + this . notificationsBadge . get_preferred_height ( childBox . get_width ( ) ) [ 1 ] ;
432+
433+ this . notificationsBadge . allocate ( childBox , flags ) ;
406434
407435 // Set label position
408436 if ( this . drawLabel ) {
@@ -450,6 +478,14 @@ class AppGroup {
450478 if ( this . progressOverlay . visible ) this . allocateProgress ( childBox , flags ) ;
451479 }
452480
481+ updateBadgesTextSize ( ) {
482+ const badgeTextSize = Math . round ( this . iconBox . width / 2.5 / global . ui_scale ) ;
483+ const badgePadding = Math . round ( badgeTextSize / 4 ) ;
484+ const sizeStyle = `font-size: ${ badgeTextSize } px; padding-left: ${ badgePadding } px; padding-right: ${ badgePadding } px;` ;
485+ this . windowsBadgeLabel . set_style ( sizeStyle ) ;
486+ this . notificationsBadgeLabel . set_style ( sizeStyle ) ;
487+ }
488+
453489 showLabel ( animate = false ) {
454490 if ( this . labelVisiblePref
455491 || ! this . label
@@ -676,8 +712,8 @@ class AppGroup {
676712 }
677713
678714 showOrderLabel ( number ) {
679- this . numberLabel . text = ( number + 1 ) . toString ( ) ;
680- this . badge . show ( ) ;
715+ this . windowsBadgeLabel . text = ( number + 1 ) . toString ( ) ;
716+ this . windowsBadge . show ( ) ;
681717 }
682718
683719 launchNewInstance ( offload = false ) {
@@ -917,6 +953,7 @@ class AppGroup {
917953 this . setIcon ( metaWindow )
918954
919955 this . calcWindowNumber ( ) ;
956+ this . updateNotificationsBadge ( ) ;
920957 this . onFocusChange ( ) ;
921958 }
922959 set ( {
@@ -1071,23 +1108,42 @@ class AppGroup {
10711108 this . checkFocusStyle ( ) ;
10721109 }
10731110
1074- calcWindowNumber ( ) {
1111+ incrementNotificationCount ( ) {
10751112 if ( this . groupState . willUnmount ) return ;
10761113
1077- const windowCount = this . groupState . metaWindows ? this . groupState . metaWindows . length : 0 ;
1078- this . numberLabel . text = windowCount . toString ( ) ;
1114+ this . groupState . set ( { notificationCount : this . groupState . notificationCount + 1 } ) ;
1115+ this . updateNotificationsBadge ( ) ;
1116+ }
10791117
1080- this . groupState . set ( { windowCount} ) ;
1118+ resetNotificationCount ( ) {
1119+ if ( this . groupState . willUnmount ) return ;
1120+
1121+ this . groupState . set ( { notificationCount : 0 } ) ;
1122+ this . updateNotificationsBadge ( ) ;
1123+ }
10811124
1082- if ( this . state . settings . numDisplay ) {
1083- if ( windowCount <= 1 ) {
1084- this . badge . hide ( ) ;
1085- } else {
1086- this . badge . show ( ) ;
1125+ calcWindowNumber ( ) {
1126+ if ( this . groupState . willUnmount ) return ;
10871127
1088- }
1128+ this . groupState . set ( { windowCount : this . groupState . metaWindows ? this . groupState . metaWindows . length : 0 } ) ;
1129+ this . updateWindowsBadge ( ) ;
1130+ }
1131+
1132+ updateWindowsBadge ( ) {
1133+ if ( this . groupState . windowCount > 1 ) {
1134+ this . windowsBadgeLabel . text = this . groupState . windowCount . toString ( ) ;
1135+ this . windowsBadge . show ( ) ;
1136+ } else {
1137+ this . windowsBadge . hide ( ) ;
1138+ }
1139+ }
1140+
1141+ updateNotificationsBadge ( ) {
1142+ if ( this . groupState . notificationCount > 0 ) {
1143+ this . notificationsBadgeLabel . text = this . groupState . notificationCount . toString ( ) ;
1144+ this . notificationsBadge . show ( ) ;
10891145 } else {
1090- this . badge . hide ( ) ;
1146+ this . notificationsBadge . hide ( ) ;
10911147 }
10921148 }
10931149
0 commit comments