@@ -10,7 +10,7 @@ const Tooltips = imports.ui.tooltips;
1010const PopupMenu = imports . ui . popupMenu ;
1111const Mainloop = imports . mainloop ;
1212const { SignalManager} = imports . misc . signalManager ;
13- const { each , findIndex , unref} = imports . misc . util ;
13+ const { unref} = imports . misc . util ;
1414const { createStore} = imports . misc . state ;
1515
1616const { AppMenuButtonRightClickMenu, HoverMenuController, AppThumbnailHoverMenu} = require ( './menus' ) ;
@@ -39,9 +39,9 @@ const getTextDirection = function(text) {
3939// centered in length
4040
4141const center = function ( length , naturalLength ) {
42- let maxLength = Math . min ( length , naturalLength ) ;
43- let x1 = Math . floor ( ( length - maxLength ) / 2 ) ;
44- let x2 = x1 + maxLength ;
42+ const maxLength = Math . min ( length , naturalLength ) ;
43+ const x1 = Math . floor ( ( length - maxLength ) / 2 ) ;
44+ const x2 = x1 + maxLength ;
4545 return [ x1 , x2 ] ;
4646} ;
4747
@@ -73,7 +73,7 @@ class AppGroup {
7373 windowCount : params . metaWindows ? params . metaWindows . length : 0 ,
7474 lastFocused : params . metaWindow || null ,
7575 isFavoriteApp : ! params . metaWindow ? true : params . isFavoriteApp === true ,
76- autoStartIndex : findIndex ( this . state . autoStartApps , ( app ) => app . id === params . appId ) ,
76+ autoStartIndex : this . state . autoStartApps . findIndex ( app => app . id === params . appId ) ,
7777 willUnmount : false ,
7878 tooltip : null ,
7979 // Not to be confused with the vertical thumbnail setting, this is for overriding horizontal
@@ -201,7 +201,7 @@ class AppGroup {
201201 }
202202
203203 initRightClickMenu ( ) {
204- let { state, groupState, actor} = this ;
204+ const { state, groupState, actor} = this ;
205205 this . rightClickMenu = new AppMenuButtonRightClickMenu ( {
206206 state,
207207 groupState,
@@ -238,7 +238,7 @@ class AppGroup {
238238
239239 this . actor . style = null ;
240240
241- let panelHeight = this . state . trigger ( 'getPanelHeight' ) ;
241+ const panelHeight = this . state . trigger ( 'getPanelHeight' ) ;
242242
243243 if ( this . state . isHorizontal ) {
244244 this . actor . height = panelHeight ;
@@ -282,7 +282,7 @@ class AppGroup {
282282 } ) ;
283283 }
284284
285- let oldChild = this . iconBox . get_child ( ) ;
285+ const oldChild = this . iconBox . get_child ( ) ;
286286 this . iconBox . set_child ( icon ) ;
287287
288288 if ( oldChild ) oldChild . destroy ( ) ;
@@ -337,23 +337,21 @@ class AppGroup {
337337 }
338338
339339 getPreferredWidth ( actor , forHeight , alloc ) {
340- let [ iconMinSize , iconNaturalSize ] = this . iconBox . get_preferred_width ( forHeight ) ;
341- let [ labelMinSize , labelNaturalSize ] = this . label . get_preferred_width ( forHeight ) ;
340+ const [ iconMinSize , iconNaturalSize ] = this . iconBox . get_preferred_width ( forHeight ) ;
341+ const [ labelMinSize , labelNaturalSize ] = this . label . get_preferred_width ( forHeight ) ;
342342 // The label text starts in the center of the icon, so we should allocate the space
343343 // needed for the icon plus the space needed for(label - icon/2)
344344 alloc . min_size = 1 * global . ui_scale ;
345345
346- let { appId, metaWindows , lastFocused } = this . groupState ;
346+ const { appId} = this . groupState ;
347347
348- let allocateForLabel = false ;
349-
350- allocateForLabel = this . labelVisiblePref ||
351- ( this . state . settings . titleDisplay == TitleDisplay . Focused &&
348+ const allocateForLabel = this . labelVisiblePref ||
349+ ( this . state . settings . titleDisplay == TitleDisplay . Focused &&
352350 this . listState . lastFocusedApp === appId ) ;
353351
354352 if ( this . state . orientation === St . Side . TOP || this . state . orientation === St . Side . BOTTOM ) {
355353 if ( allocateForLabel ) {
356- let max = this . labelVisiblePref && this . groupState . metaWindows . length > 0 ?
354+ const max = this . labelVisiblePref && this . groupState . metaWindows . length > 0 ?
357355 labelNaturalSize + iconNaturalSize + 6 : 0 ;
358356 alloc . natural_size = Math . min ( iconNaturalSize + Math . max ( max , labelNaturalSize ) , MAX_BUTTON_WIDTH * global . ui_scale ) ;
359357 } else {
@@ -440,10 +438,10 @@ class AppGroup {
440438
441439 // Call set_icon_geometry for support of Cinnamon's minimize animation
442440 if ( this . groupState . metaWindows . length > 0 && this . actor . realized ) {
443- let rect = new Meta . Rectangle ( ) ;
441+ const rect = new Meta . Rectangle ( ) ;
444442 [ rect . x , rect . y ] = this . actor . get_transformed_position ( ) ;
445443 [ rect . width , rect . height ] = this . actor . get_transformed_size ( ) ;
446- each ( this . groupState . metaWindows , ( metaWindow ) => {
444+ this . groupState . metaWindows . forEach ( metaWindow => {
447445 if ( metaWindow ) {
448446 metaWindow . set_icon_geometry ( rect ) ;
449447 }
@@ -462,7 +460,7 @@ class AppGroup {
462460 return ;
463461 }
464462
465- let width = MAX_BUTTON_WIDTH * global . ui_scale ;
463+ const width = MAX_BUTTON_WIDTH * global . ui_scale ;
466464
467465 this . labelVisiblePref = true ;
468466 if ( this . label . text == null ) {
@@ -520,13 +518,7 @@ class AppGroup {
520518 checkFocusStyle ( ) {
521519 if ( this . actor . is_finalized ( ) ) return ;
522520
523- let focused = false ;
524- each ( this . groupState . metaWindows , function ( metaWindow ) {
525- if ( getFocusState ( metaWindow ) ) {
526- focused = true ;
527- return false ;
528- }
529- } ) ;
521+ const focused = this . groupState . metaWindows . some ( metaWindow => getFocusState ( metaWindow ) ) ;
530522
531523 if ( focused ) {
532524 this . actor . add_style_pseudo_class ( 'focus' ) ;
@@ -547,11 +539,11 @@ class AppGroup {
547539 }
548540
549541 averageProgress ( ) {
550- let { metaWindows} = this . groupState ;
542+ const { metaWindows} = this . groupState ;
551543 let total = 0 ;
552544 let count = 0 ;
553- each ( metaWindows , function ( metaWindow ) {
554- let { progress} = metaWindow ;
545+ metaWindows . forEach ( metaWindow => {
546+ const { progress} = metaWindow ;
555547 if ( progress < 1 ) return ;
556548 total += progress ;
557549 count ++ ;
@@ -574,7 +566,7 @@ class AppGroup {
574566 }
575567
576568 onProgressChange ( metaWindow ) {
577- let progress = this . averageProgress ( ) ;
569+ const progress = this . averageProgress ( ) ;
578570 if ( progress !== this . progress ) {
579571 this . progress = progress ;
580572 if ( this . progress > 0 ) {
@@ -587,7 +579,7 @@ class AppGroup {
587579 }
588580
589581 onFocusChange ( hasFocus ) {
590- let { appId, metaWindows, lastFocused} = this . groupState ;
582+ const { appId, metaWindows, lastFocused} = this . groupState ;
591583
592584 if ( hasFocus === undefined ) {
593585 hasFocus = this . listState . lastFocusedApp === appId ;
@@ -599,6 +591,9 @@ class AppGroup {
599591 this . listState . trigger ( 'updateFocusState' , appId ) ;
600592 this . actor . add_style_pseudo_class ( 'focus' ) ;
601593 this . actor . remove_style_class_name ( 'grouped-window-list-item-demands-attention' ) ;
594+ if ( this . hoverMenu ) {
595+ this . hoverMenu . appThumbnails . forEach ( thumbnail => thumbnail . setThumbnailDemandsAttention ( false ) ) ;
596+ }
602597 this . _needsAttention = false ;
603598 } else {
604599 this . actor . remove_style_pseudo_class ( 'focus' ) ;
@@ -615,7 +610,7 @@ class AppGroup {
615610 if ( ! this . groupState || ! this . groupState . groupReady || this . groupState . willUnmount ) {
616611 return ;
617612 }
618- let windows = this . groupState . metaWindows ;
613+ const windows = this . groupState . metaWindows ;
619614 for ( let i = 0 , len = windows . length ; i < len ; i ++ ) {
620615 if ( windows [ i ] === metaWindow ) {
621616 // Even though this may not be the last focused window, we want it to be
@@ -654,7 +649,7 @@ class AppGroup {
654649 || this . state . panelEditMode ) {
655650 return DND . DragMotionResult . CONTINUE ;
656651 }
657- let nWindows = this . groupState . metaWindows . length ;
652+ const nWindows = this . groupState . metaWindows . length ;
658653 if ( nWindows > 0 && this . groupState . lastFocused ) {
659654 if ( nWindows === 1 ) {
660655 Main . activateWindow ( this . groupState . lastFocused , global . get_current_time ( ) ) ;
@@ -705,14 +700,14 @@ class AppGroup {
705700 return ;
706701 }
707702
708- let button = event . get_button ( ) ;
709- let nWindows = this . groupState . metaWindows . length ;
703+ const button = event . get_button ( ) ;
704+ const nWindows = this . groupState . metaWindows . length ;
710705
711- let modifiers = Cinnamon . get_event_state ( event ) ;
712- let ctrlPressed = ( modifiers & Clutter . ModifierType . CONTROL_MASK ) ;
713- let shiftPressed = ( modifiers & Clutter . ModifierType . SHIFT_MASK ) ;
706+ const modifiers = Cinnamon . get_event_state ( event ) ;
707+ const ctrlPressed = ( modifiers & Clutter . ModifierType . CONTROL_MASK ) ;
708+ const shiftPressed = ( modifiers & Clutter . ModifierType . SHIFT_MASK ) ;
714709
715- let shouldStartInstance = (
710+ const shouldStartInstance = (
716711 ( button === 1 && ctrlPressed )
717712 || ( button === 1 && shiftPressed )
718713 || ( button === 1
@@ -723,7 +718,7 @@ class AppGroup {
723718 && this . state . settings . middleClickAction === 2 )
724719 ) ;
725720
726- let shouldEndInstance = button === 2
721+ const shouldEndInstance = button === 2
727722 && this . state . settings . middleClickAction === 3
728723 && this . groupState . lastFocused
729724 && nWindows > 0 ;
@@ -738,7 +733,7 @@ class AppGroup {
738733 return ;
739734 }
740735
741- let handleMinimizeToggle = ( win ) => {
736+ const handleMinimizeToggle = ( win ) => {
742737 if ( this . state . settings . onClickThumbs && nWindows > 1 ) {
743738 if ( ! this . hoverMenu ) this . initThumbnailMenu ( ) ;
744739 if ( this . hoverMenu . isOpen ) {
@@ -819,7 +814,7 @@ class AppGroup {
819814 }
820815
821816 onAppButtonPress ( actor , event ) {
822- let button = event . get_button ( ) ;
817+ const button = event . get_button ( ) ;
823818 this . groupState . pressed = true ;
824819
825820 if ( button === 3 ) return true ;
@@ -878,7 +873,7 @@ class AppGroup {
878873 if ( this . groupState . lastFocused . minimized ) {
879874 this . groupState . lastFocused . unminimize ( ) ;
880875 }
881- let ws = this . groupState . lastFocused . get_workspace ( ) . index ( ) ;
876+ const ws = this . groupState . lastFocused . get_workspace ( ) . index ( ) ;
882877 if ( ws !== global . workspace_manager . get_active_workspace_index ( ) ) {
883878 global . workspace_manager . get_workspace_by_index ( ws ) . activate ( global . get_current_time ( ) ) ;
884879 }
@@ -888,8 +883,8 @@ class AppGroup {
888883 }
889884
890885 windowAdded ( metaWindow ) {
891- let { metaWindows, trigger, set} = this . groupState ;
892- let refWindow = metaWindows . indexOf ( metaWindow ) ;
886+ const { metaWindows, trigger, set} = this . groupState ;
887+ const refWindow = metaWindows . indexOf ( metaWindow ) ;
893888 if ( metaWindow ) {
894889 this . signals . connect ( metaWindow , 'notify::title' , ( ...args ) => this . onWindowTitleChanged ( ...args ) ) ;
895890 this . signals . connect ( metaWindow , 'notify::appears-focused' , ( ...args ) => this . onFocusWindowChange ( ...args ) ) ;
@@ -976,7 +971,7 @@ class AppGroup {
976971 return ;
977972 }
978973
979- let shouldHideLabel = this . state . settings . titleDisplay === TitleDisplay . None
974+ const shouldHideLabel = this . state . settings . titleDisplay === TitleDisplay . None
980975 || ! this . state . isHorizontal ;
981976
982977 if ( shouldHideLabel ) {
@@ -1000,12 +995,12 @@ class AppGroup {
1000995 metaWindow . lastTitle = metaWindow . title ;
1001996
1002997 if ( this . hoverMenu ) {
1003- each ( this . hoverMenu . appThumbnails , ( thumbnail ) => {
1004- if ( thumbnail . metaWindow === metaWindow ) {
1005- thumbnail . labelContainer . child . set_text ( metaWindow . title ) ;
1006- return false ;
1007- }
1008- } ) ;
998+ const thumbnail = this . hoverMenu . appThumbnails . find (
999+ thumbnail => thumbnail . metaWindow === metaWindow
1000+ ) ;
1001+ if ( thumbnail ) {
1002+ thumbnail . labelContainer . child . set_text ( metaWindow . title ) ;
1003+ }
10091004 }
10101005
10111006 this . groupState . set ( {
@@ -1018,7 +1013,7 @@ class AppGroup {
10181013 onFocusWindowChange ( metaWindow ) {
10191014 if ( this . groupState . metaWindows . length === 0 ) return ;
10201015
1021- let hasFocus = getFocusState ( metaWindow ) ;
1016+ const hasFocus = getFocusState ( metaWindow ) ;
10221017 if ( hasFocus && this . groupState . hasOwnProperty ( 'lastFocused' ) ) {
10231018 this . listState . set ( { lastFocusedApp : this . groupState . appId } ) ;
10241019 this . groupState . set ( { lastFocused : metaWindow } ) ;
@@ -1080,7 +1075,7 @@ class AppGroup {
10801075 calcWindowNumber ( ) {
10811076 if ( this . groupState . willUnmount ) return ;
10821077
1083- let windowCount = this . groupState . metaWindows ? this . groupState . metaWindows . length : 0 ;
1078+ const windowCount = this . groupState . metaWindows ? this . groupState . metaWindows . length : 0 ;
10841079 this . numberLabel . text = windowCount . toString ( ) ;
10851080
10861081 this . groupState . set ( { windowCount} ) ;
@@ -1098,13 +1093,13 @@ class AppGroup {
10981093 }
10991094
11001095 handleTitleDisplayChange ( ) {
1101- each ( this . groupState . metaWindows , ( win ) => {
1102- this . onWindowTitleChanged ( win , true ) ;
1103- } ) ;
1096+ this . groupState . metaWindows . forEach (
1097+ win => this . onWindowTitleChanged ( win , true )
1098+ ) ;
11041099 }
11051100
11061101 animate ( ) {
1107- let effect = this . state . settings . launcherAnimationEffect ;
1102+ const effect = this . state . settings . launcherAnimationEffect ;
11081103
11091104 if ( effect === 1 ) return ;
11101105 else if ( effect === 2 ) {
0 commit comments