Skip to content

Commit 087efed

Browse files
authored
gwl: fix reload dragging pinned apps when group windows setting is disabled (#11191)
1 parent 6c76516 commit 087efed

File tree

2 files changed

+48
-22
lines changed

2 files changed

+48
-22
lines changed

files/usr/share/cinnamon/applets/[email protected]/appList.js

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -287,10 +287,13 @@ class AppList {
287287
let refFav = findIndex(this.state.trigger('getFavorites'), (favorite) => {
288288
return favorite.app === app;
289289
});
290-
if (refFav > -1) transientFavorite = true;
290+
if (refFav > -1) {
291+
isFavoriteApp = true;
292+
transientFavorite = true;
293+
}
291294
}
292295

293-
let initApp = () => {
296+
let initApp = (idx) => {
294297
let appGroup = new AppGroup({
295298
state: this.state,
296299
listState: this.listState,
@@ -300,20 +303,27 @@ class AppList {
300303
metaWindow,
301304
appId
302305
});
303-
this.actor.add_child(appGroup.actor);
304-
this.appList.push(appGroup);
306+
307+
if(idx > -1) {
308+
this.actor.insert_child_at_index(appGroup.actor, idx);
309+
this.appList.splice(idx, 0, appGroup);
310+
}
311+
else {
312+
this.actor.add_child(appGroup.actor);
313+
this.appList.push(appGroup);
314+
}
305315
appGroup.windowAdded(metaWindow);
306316
};
307317

308318
if (refApp === -1) {
309-
initApp(metaWindow);
319+
initApp(-1);
310320
} else if (metaWindow) {
311321
if (this.state.settings.groupApps) {
312322
this.appList[refApp].windowAdded(metaWindow);
313323
} else if (transientFavorite && this.appList[refApp].groupState.metaWindows.length === 0) {
314324
this.appList[refApp].windowAdded(metaWindow);
315325
} else if (refWindow === -1) {
316-
initApp();
326+
initApp(refApp+1);
317327
}
318328
}
319329
}

files/usr/share/cinnamon/applets/[email protected]/applet.js

Lines changed: 32 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)