@@ -32,11 +32,6 @@ class PinnedFavs {
3232 reload ( ) {
3333 const { state, signals, settings} = this . params ;
3434 const appSystem = state . trigger ( 'getAppSystem' ) ;
35- if ( signals . isConnected ( 'changed::pinned-apps' , settings ) ) {
36- signals . disconnect ( 'changed::pinned-apps' , settings ) ;
37- }
38- let cb = ( ) => this . onFavoritesChange ( ) ;
39- signals . connect ( settings , 'changed::pinned-apps' , cb ) ;
4035 this . _favorites = [ ] ;
4136 let ids = [ ] ;
4237 ids = settings . getValue ( 'pinned-apps' ) ;
@@ -150,6 +145,7 @@ class PinnedFavs {
150145 }
151146
152147 this . saveFavorites ( ) ;
148+ this . onFavoritesChange ( ) ;
153149 return true ;
154150 }
155151
@@ -171,6 +167,7 @@ class PinnedFavs {
171167 this . triggerUpdate ( appId , false ) ;
172168 this . _favorites . splice ( refFav , 1 ) ;
173169 this . saveFavorites ( ) ;
170+ this . onFavoritesChange ( ) ;
174171 return true ;
175172 }
176173}
@@ -790,11 +787,18 @@ class GroupedWindowListApplet extends Applet.Applet {
790787 let pos = 0 ;
791788 while ( pos < this . state . dragging . posList . length && axis [ 0 ] > this . state . dragging . posList [ pos ] )
792789 pos ++ ;
790+
791+ let favLength = 0 ;
792+ each ( appList . appList , ( appGroup , i ) => {
793+ if ( appGroup . groupState . isFavoriteApp )
794+ favLength ++ ;
795+ else return false ;
796+ } ) ;
793797
794798 // keep pinned and unpinned items separate
795- if ( ( this . state . dragging . isForeign && pos > this . pinnedFavorites . _favorites . length ) ||
796- ( ! this . state . dragging . isForeign && source . groupState . isFavoriteApp && pos >= this . pinnedFavorites . _favorites . length ) ||
797- ( ! this . state . dragging . isForeign && ! source . groupState . isFavoriteApp && pos < this . pinnedFavorites . _favorites . length ) )
799+ if ( ( this . state . dragging . isForeign && pos > favLength ) ||
800+ ( ! this . state . dragging . isForeign && source . groupState . isFavoriteApp && pos >= favLength ) ||
801+ ( ! this . state . dragging . isForeign && ! source . groupState . isFavoriteApp && pos < favLength ) )
798802 return DND . DragMotionResult . NO_DROP ;
799803
800804 // handle position change
@@ -880,11 +884,11 @@ class GroupedWindowListApplet extends Applet.Applet {
880884 }
881885
882886 moveLauncher ( source ) {
883- let pos = this . state . dragging . pos ;
887+ let appList = this . getCurrentAppList ( ) ;
884888 this . clearDragParameters ( ) ;
885889
886890 Meta . later_add ( Meta . LaterType . BEFORE_REDRAW , ( ) => {
887- this . getCurrentAppList ( ) . updateAppGroupIndexes ( ) ;
891+ appList . updateAppGroupIndexes ( ) ;
888892 // Refresh the group's thumbnails so hoverMenu is aware of the position change
889893 // In the case of dragging a group that has a delay before Cinnamon can grab its
890894 // thumbnail texture, e.g., LibreOffice, defer the refresh.
@@ -894,14 +898,26 @@ class GroupedWindowListApplet extends Applet.Applet {
894898
895899 // Handle favoriting if pin on drag is enabled
896900 if ( ! source . groupState . app . is_window_backed ( ) ) {
897- let opts = {
898- appId : source . groupState . appId ,
899- app : source . groupState . app ,
900- pos
901- } ;
901+
902902 let refFav = findIndex ( this . pinnedFavorites . _favorites , ( favorite ) => favorite . id === source . groupState . appId ) ;
903903 if ( refFav > - 1 ) {
904- this . pinnedFavorites . moveFavoriteToPos ( opts ) ;
904+
905+ let pinned = [ ] ; //pinned apps found before source
906+ each ( appList . appList , ( appGroup , i ) => {
907+ if ( appGroup . groupState . appId == source . groupState . appId ) //
908+ return false ;
909+ else if ( ! pinned . includes ( appGroup . groupState . appId ) )
910+ pinned . push ( appGroup . groupState . appId ) ;
911+ } ) ;
912+
913+ let opts = {
914+ appId : source . groupState . appId ,
915+ app : source . groupState . app ,
916+ pos : pinned . length
917+ } ;
918+
919+ if ( pinned . length != refFav )
920+ this . pinnedFavorites . moveFavoriteToPos ( opts ) ;
905921 }
906922 }
907923
0 commit comments