[gnome-shell] iconGrid: Only recreate icons when needed
- From: Jasper St. Pierre <jstpierre src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-shell] iconGrid: Only recreate icons when needed
- Date: Fri, 14 Dec 2012 08:32:31 +0000 (UTC)
commit 429f9e1d15b416f83ab7d4cf82ae1e1d7ce32925
Author: Jasper St. Pierre <jstpierre mecheye net>
Date: Fri Nov 30 20:35:04 2012 -0500
iconGrid: Only recreate icons when needed
Recreating icons on every style change -- like hover, can have
disasterous effects. Not only is the quick creation/destruction of
the actors bad, but adding/removing actors at runtime queues many
relayouts, which makes the whole system slower as a lot of unnecessary
reallocations are figured out.
While an optimization was here before, it was broken because it
broke high-contrast themes. Connect explicitly to the texture cache
to know when the icon theme has changed, instead of removing a valuable
optimization.
https://bugzilla.gnome.org/show_bug.cgi?id=672941
js/ui/iconGrid.js | 20 ++++++++++++++++++++
1 files changed, 20 insertions(+), 0 deletions(-)
---
diff --git a/js/ui/iconGrid.js b/js/ui/iconGrid.js
index 04b8caf..2b63865 100644
--- a/js/ui/iconGrid.js
+++ b/js/ui/iconGrid.js
@@ -23,6 +23,8 @@ const BaseIcon = new Lang.Class({
this.actor._delegate = this;
this.actor.connect('style-changed',
Lang.bind(this, this._onStyleChanged));
+ this.actor.connect('destroy',
+ Lang.bind(this, this._onDestroy));
this._spacing = 0;
@@ -52,6 +54,9 @@ const BaseIcon = new Lang.Class({
this._setSizeManually = params.setSizeManually;
this.icon = null;
+
+ let cache = St.TextureCache.get_default();
+ this._iconThemeChangedId = cache.connect('icon-theme-changed', Lang.bind(this, this._onIconThemeChanged));
},
_allocate: function(actor, box, flags) {
@@ -146,7 +151,22 @@ const BaseIcon = new Lang.Class({
size = found ? len : ICON_SIZE;
}
+ if (this.iconSize == size && this._iconBin.child)
+ return;
+
this._createIconTexture(size);
+ },
+
+ _onDestroy: function() {
+ if (this._iconThemeChangedId > 0) {
+ let cache = St.TextureCache.get_default();
+ cache.disconnect(this._iconThemeChangedId);
+ this._iconThemeChangedId = 0;
+ }
+ },
+
+ _onIconThemeChanged: function() {
+ this._createIconTexture(this.iconSize);
}
});
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]