status/keyboard: Backup the whole MRU list while in password mode
Instead of saving only the current input source when entering password mode, let's save the whole MRU list so that we can restore it when returning to normal mode. This is closer to user expectations since password mode is a transient and short lived state. https://bugzilla.gnome.org/show_bug.cgi?id=746605
This commit is contained in:
parent
8521556723
commit
2f228e21da
@ -295,11 +295,11 @@ const InputSourceManager = new Lang.Class({
|
|||||||
this._ibusSources = {};
|
this._ibusSources = {};
|
||||||
|
|
||||||
this._currentSource = null;
|
this._currentSource = null;
|
||||||
this._backupSource = null;
|
|
||||||
|
|
||||||
// All valid input sources currently in the gsettings
|
// All valid input sources currently in the gsettings
|
||||||
// KEY_INPUT_SOURCES list ordered by most recently used
|
// KEY_INPUT_SOURCES list ordered by most recently used
|
||||||
this._mruSources = [];
|
this._mruSources = [];
|
||||||
|
this._mruSourcesBackup = null;
|
||||||
this._keybindingAction =
|
this._keybindingAction =
|
||||||
Main.wm.addKeybinding('switch-input-source',
|
Main.wm.addKeybinding('switch-input-source',
|
||||||
new Gio.Settings({ schema_id: "org.gnome.desktop.wm.keybindings" }),
|
new Gio.Settings({ schema_id: "org.gnome.desktop.wm.keybindings" }),
|
||||||
@ -516,6 +516,11 @@ const InputSourceManager = new Lang.Class({
|
|||||||
|
|
||||||
this._keyboardManager.setUserLayouts(sourcesList.map(function(x) { return x.xkbId; }));
|
this._keyboardManager.setUserLayouts(sourcesList.map(function(x) { return x.xkbId; }));
|
||||||
|
|
||||||
|
if (!this._disableIBus && this._mruSourcesBackup) {
|
||||||
|
this._mruSources = this._mruSourcesBackup;
|
||||||
|
this._mruSourcesBackup = null;
|
||||||
|
}
|
||||||
|
|
||||||
let mruSources = [];
|
let mruSources = [];
|
||||||
for (let i = 0; i < this._mruSources.length; i++) {
|
for (let i = 0; i < this._mruSources.length; i++) {
|
||||||
for (let j = 0; j < sourcesList.length; j++)
|
for (let j = 0; j < sourcesList.length; j++)
|
||||||
@ -527,20 +532,8 @@ const InputSourceManager = new Lang.Class({
|
|||||||
}
|
}
|
||||||
this._mruSources = mruSources.concat(sourcesList);
|
this._mruSources = mruSources.concat(sourcesList);
|
||||||
|
|
||||||
if (this._mruSources.length > 0) {
|
if (this._mruSources.length > 0)
|
||||||
if (!this._disableIBus && this._backupSource) {
|
|
||||||
for (let i = 0; i < this._mruSources.length; i++) {
|
|
||||||
if (this._mruSources[i].type == this._backupSource.type &&
|
|
||||||
this._mruSources[i].id == this._backupSource.id) {
|
|
||||||
let currentSource = this._mruSources.splice(i, 1);
|
|
||||||
this._mruSources = currentSource.concat(this._mruSources);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
this._backupSource = null;
|
|
||||||
}
|
|
||||||
this._mruSources[0].activate();
|
this._mruSources[0].activate();
|
||||||
}
|
|
||||||
|
|
||||||
// All ibus engines are preloaded here to reduce the launching time
|
// All ibus engines are preloaded here to reduce the launching time
|
||||||
// when users switch the input sources.
|
// when users switch the input sources.
|
||||||
@ -605,16 +598,12 @@ const InputSourceManager = new Lang.Class({
|
|||||||
if (this._disableIBus)
|
if (this._disableIBus)
|
||||||
return;
|
return;
|
||||||
this._disableIBus = true;
|
this._disableIBus = true;
|
||||||
this._backupSource = this._currentSource;
|
this._mruSourcesBackup = this._mruSources.slice();
|
||||||
} else {
|
} else {
|
||||||
if (!this._disableIBus)
|
if (!this._disableIBus)
|
||||||
return;
|
return;
|
||||||
this._disableIBus = false;
|
this._disableIBus = false;
|
||||||
}
|
}
|
||||||
// If this._mruSources is not cleared before this.reload() is called,
|
|
||||||
// the order is different from the original one as IM sources will
|
|
||||||
// be appended to XKB sources.
|
|
||||||
this._mruSources = [];
|
|
||||||
this.reload();
|
this.reload();
|
||||||
},
|
},
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user