[gnome-shell] appDisplay: Process application display in chunks instead of all at once
- From: Colin Walters <walters src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-shell] appDisplay: Process application display in chunks instead of all at once
- Date: Mon, 25 Apr 2011 21:20:13 +0000 (UTC)
commit 7813c5b93f6bcde8c4beae286e82bfc472b2b656
Author: Colin Walters <walters verbum org>
Date: Mon Apr 25 15:42:03 2011 -0400
appDisplay: Process application display in chunks instead of all at once
Layout here can be slow for multiple reasons; better to avoid blocking
the whole UI until we're done with layout.
https://bugzilla.gnome.org/show_bug.cgi?id=647778
js/ui/appDisplay.js | 36 +++++++++++++++++++++++++++++++++---
1 files changed, 33 insertions(+), 3 deletions(-)
---
diff --git a/js/ui/appDisplay.js b/js/ui/appDisplay.js
index 3161a78..cd502ef 100644
--- a/js/ui/appDisplay.js
+++ b/js/ui/appDisplay.js
@@ -6,6 +6,7 @@ const Gtk = imports.gi.Gtk;
const Shell = imports.gi.Shell;
const Lang = imports.lang;
const Signals = imports.signals;
+const Meta = imports.gi.Meta;
const St = imports.gi.St;
const Mainloop = imports.mainloop;
const Gettext = imports.gettext.domain('gnome-shell');
@@ -22,6 +23,7 @@ const Tweener = imports.ui.tweener;
const Workspace = imports.ui.workspace;
const Params = imports.misc.params;
+const MAX_APPLICATION_WORK_MILLIS = 75;
const MENU_POPUP_TIMEOUT = 600;
const SCROLL_TIME = 0.1;
@@ -34,6 +36,7 @@ AlphabeticalView.prototype = {
this._grid = new IconGrid.IconGrid({ xAlign: St.Align.START });
this._appSystem = Shell.AppSystem.get_default();
+ this._pendingAppLaterId = 0;
this._apps = [];
this._filterApp = null;
@@ -110,6 +113,30 @@ AlphabeticalView.prototype = {
this._apps[i].actor.visible = filter(this._apps[i]._appInfo);
},
+ // Create actors for the applications in an idle to avoid blocking
+ // for too long; see bug 647778
+ _addPendingApps: function() {
+ let i;
+ let startTimeMillis = new Date().getTime();
+ for (i = 0; i < this._pendingAppIds.length; i++) {
+ let id = this._pendingAppIds[i];
+ this._addApp(this._pendingApps[id]);
+
+ let currentTimeMillis = new Date().getTime();
+ if (currentTimeMillis - startTimeMillis > MAX_APPLICATION_WORK_MILLIS)
+ break;
+ }
+ this._pendingAppIds.splice(0, i);
+ if (this._pendingAppIds.length > 0) {
+ return true;
+ } else {
+ this._pendingAppLaterId = 0;
+ this._pendingAppIds = null;
+ this._pendingApps = null;
+ return false;
+ }
+ },
+
refresh: function(apps) {
let ids = [];
for (let i in apps)
@@ -120,9 +147,12 @@ AlphabeticalView.prototype = {
this._removeAll();
- for (let i = 0; i < ids.length; i++) {
- this._addApp(apps[ids[i]]);
- }
+ this._pendingAppIds = ids;
+ this._pendingApps = apps;
+ if (this._pendingAppLaterId)
+ Meta.later_remove(this._pendingAppLaterId);
+ this._pendingAppLaterId = Meta.later_add(Meta.LaterType.BEFORE_REDRAW,
+ Lang.bind(this, this._addPendingApps));
}
};
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]