window-list: Sort buttons by stable sequence

Currently the initial set of buttons is in stack/MRU order. To
avoid shuffling around the list each time it is disabled/re-enabled
(lock screen) or the group-mode settings changes, sort it by the
stable sequence.

https://bugzilla.gnome.org/show_bug.cgi?id=719933
This commit is contained in:
Florian Müllner
2014-04-08 19:39:38 +02:00
parent 110e747e04
commit d8eb2273c0

View File

@@ -57,6 +57,12 @@ function _onMenuStateChanged(menu, isOpen) {
actor.sync_hover();
}
function _getAppStableSequence(app) {
return app.get_windows().reduce(function(prev, cur) {
return Math.min(prev, cur.get_stable_sequence());
}, 0);
}
const WindowContextMenu = new Lang.Class({
Name: 'WindowContextMenu',
@@ -892,11 +898,19 @@ const WindowList = new Lang.Class({
this._windowList.destroy_all_children();
if (!this._grouped) {
let windows = Meta.get_window_actors(global.screen);
let windows = Meta.get_window_actors(global.screen).sort(
function(w1, w2) {
return w1.metaWindow.get_stable_sequence() -
w2.metaWindow.get_stable_sequence();
});
for (let i = 0; i < windows.length; i++)
this._onWindowAdded(null, windows[i].metaWindow);
} else {
let apps = this._appSystem.get_running();
let apps = this._appSystem.get_running().sort(
function(a1, a2) {
return _getAppStableSequence(a1) -
_getAppStableSequence(a2);
});
for (let i = 0; i < apps.length; i++)
this._addApp(apps[i]);
}