From 1edb9f7525a4bb1dd0f183267be2ba5c6bc29479 Mon Sep 17 00:00:00 2001 From: "Jasper St. Pierre" Date: Mon, 9 Sep 2013 16:53:44 -0400 Subject: [PATCH] altTab: Only create one settings instance per window switcher popup Every settings instance we create is a round-trip to the dconf daemon, so we need to be careful of not creating them too haphazardly. https://bugzilla.gnome.org/show_bug.cgi?id=707806 --- js/ui/altTab.js | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/js/ui/altTab.js b/js/ui/altTab.js index 9d47d1e5f..779ae7b55 100644 --- a/js/ui/altTab.js +++ b/js/ui/altTab.js @@ -355,10 +355,13 @@ const WindowSwitcherPopup = new Lang.Class({ Name: 'WindowSwitcherPopup', Extends: SwitcherPopup.SwitcherPopup, + _init: function(items) { + this.parent(items); + this._settings = new Gio.Settings({ schema: 'org.gnome.shell.window-switcher' }); + }, + _getWindowList: function() { - let settings = new Gio.Settings({ schema: 'org.gnome.shell.window-switcher' }); - let workspace = settings.get_boolean('current-workspace-only') ? global.screen.get_active_workspace() - : null; + let workspace = this._settings.get_boolean('current-workspace-only') ? global.screen.get_active_workspace() : null; return global.display.get_tab_list(Meta.TabList.NORMAL, global.screen, workspace); }, @@ -368,7 +371,8 @@ const WindowSwitcherPopup = new Lang.Class({ if (windows.length == 0) return false; - this._switcherList = new WindowList(windows); + let mode = this._settings.get_enum('app-icon-mode'); + this._switcherList = new WindowList(windows, mode); this._items = this._switcherList.icons; return true; @@ -663,7 +667,7 @@ const ThumbnailList = new Lang.Class({ const WindowIcon = new Lang.Class({ Name: 'WindowIcon', - _init: function(window) { + _init: function(window, mode) { this.window = window; this.actor = new St.BoxLayout({ style_class: 'alt-tab-app', @@ -681,8 +685,7 @@ const WindowIcon = new Lang.Class({ this._icon.destroy_all_children(); - let settings = new Gio.Settings({ schema: 'org.gnome.shell.window-switcher' }); - switch (settings.get_enum('app-icon-mode')) { + switch (mode) { case AppIconMode.THUMBNAIL_ONLY: size = WINDOW_PREVIEW_SIZE; this._icon.add_actor(_createWindowClone(mutterWindow, WINDOW_PREVIEW_SIZE)); @@ -720,7 +723,7 @@ const WindowList = new Lang.Class({ Name: 'WindowList', Extends: SwitcherPopup.SwitcherList, - _init : function(windows) { + _init : function(windows, mode) { this.parent(true); this._label = new St.Label({ x_align: Clutter.ActorAlign.CENTER, @@ -732,7 +735,7 @@ const WindowList = new Lang.Class({ for (let i = 0; i < windows.length; i++) { let win = windows[i]; - let icon = new WindowIcon(win); + let icon = new WindowIcon(win, mode); this.addItem(icon.actor, icon.label); this.icons.push(icon);