keyboard: Do not create widgetry for all keyboard groups at once

Instead do this on demand based on the current group. It is less
taxing at the time of initially creating the Keyboard object.
This commit is contained in:
Carlos Garnacho 2018-01-23 17:03:02 +01:00
parent 82cecf2e36
commit 8fdf47ea5b

View File

@ -680,7 +680,8 @@ var Keyboard = new Lang.Class({
{ x_align: St.Align.MIDDLE, { x_align: St.Align.MIDDLE,
x_fill: false }); x_fill: false });
this._addKeys(); this._ensureKeysForGroup(this._keyboardController.getCurrentGroup());
this._setActiveLayer(0);
// Keyboard models are defined in LTR, we must override // Keyboard models are defined in LTR, we must override
// the locale setting in order to avoid flipping the // the locale setting in order to avoid flipping the
@ -744,14 +745,9 @@ var Keyboard = new Lang.Class({
return layers; return layers;
}, },
_addKeys: function () { _ensureKeysForGroup: function(group) {
let groups = this._keyboardController.getGroups(); if (!this._groups[group])
for (let i = 0; i < groups.length; ++i) { this._groups[group] = this._createLayersForGroup(group);
let gname = groups[i];
this._groups[gname] = this._createLayersForGroup(gname);
}
this._setActiveLayer(0);
}, },
_addRowKeys : function (keys, layout) { _addRowKeys : function (keys, layout) {
@ -911,6 +907,7 @@ var Keyboard = new Lang.Class({
}, },
_onGroupChanged: function () { _onGroupChanged: function () {
this._ensureKeysForGroup(this._keyboardController.getCurrentGroup());
this._setActiveLayer(0); this._setActiveLayer(0);
}, },