ibusManager: Disable IBus input sources on password entries
Input method preedit text needs to be disabled on password entries for security and usability reasons. IBus 1.5.7 provides the signal set-content-type so that panel UIs can handle these special purpose input entries: https://github.com/ibus/ibus/commit/6ca5ddb302c9 Unfortunately IBus versions older than 1.5.10 have a bug which causes spurious set-content-type emissions when switching input focus that temporarily lose purpose and hints defeating its intended semantics and confusing users. We thus don't use it in that case. https://bugzilla.gnome.org/show_bug.cgi?id=730628
This commit is contained in:

committed by
Rui Matos

parent
19c7da7b08
commit
d8ca374a06
@ -155,6 +155,7 @@ const InputSourceManager = new Lang.Class({
|
||||
this._ibusSources = {};
|
||||
|
||||
this._currentSource = null;
|
||||
this._backupSource = null;
|
||||
|
||||
// All valid input sources currently in the gsettings
|
||||
// KEY_INPUT_SOURCES list ordered by most recently used
|
||||
@ -183,6 +184,7 @@ const InputSourceManager = new Lang.Class({
|
||||
this._ibusManager.connect('ready', Lang.bind(this, this._ibusReadyCallback));
|
||||
this._ibusManager.connect('properties-registered', Lang.bind(this, this._ibusPropertiesRegistered));
|
||||
this._ibusManager.connect('property-updated', Lang.bind(this, this._ibusPropertyUpdated));
|
||||
this._ibusManager.connect('set-content-type', Lang.bind(this, this._ibusSetContentType));
|
||||
|
||||
global.display.connect('modifiers-accelerator-activated', Lang.bind(this, this._modifiersSwitcher));
|
||||
|
||||
@ -192,6 +194,7 @@ const InputSourceManager = new Lang.Class({
|
||||
this._overviewHiddenId = 0;
|
||||
this._settings.connect('changed::per-window', Lang.bind(this, this._sourcesPerWindowChanged));
|
||||
this._sourcesPerWindowChanged();
|
||||
this._disableIBus = false;
|
||||
},
|
||||
|
||||
reload: function() {
|
||||
@ -309,6 +312,8 @@ const InputSourceManager = new Lang.Class({
|
||||
[exists, displayName, shortName, , ] =
|
||||
this._xkbInfo.get_layout_info(id);
|
||||
} else if (type == INPUT_SOURCE_TYPE_IBUS) {
|
||||
if (this._disableIBus)
|
||||
continue;
|
||||
let engineDesc = this._ibusManager.getEngineDesc(id);
|
||||
if (engineDesc) {
|
||||
let language = IBus.get_language_name(engineDesc.get_language());
|
||||
@ -379,8 +384,20 @@ const InputSourceManager = new Lang.Class({
|
||||
}
|
||||
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();
|
||||
}
|
||||
|
||||
// All ibus engines are preloaded here to reduce the launching time
|
||||
// when users switch the input sources.
|
||||
@ -437,6 +454,27 @@ const InputSourceManager = new Lang.Class({
|
||||
return false;
|
||||
},
|
||||
|
||||
_ibusSetContentType: function(im, purpose, hints) {
|
||||
if (purpose == IBus.InputPurpose.PASSWORD) {
|
||||
if (Object.keys(this._inputSources).length == Object.keys(this._ibusSources).length)
|
||||
return;
|
||||
|
||||
if (this._disableIBus)
|
||||
return;
|
||||
this._disableIBus = true;
|
||||
this._backupSource = this._currentSource;
|
||||
} else {
|
||||
if (!this._disableIBus)
|
||||
return;
|
||||
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();
|
||||
},
|
||||
|
||||
_getNewInputSource: function(current) {
|
||||
for (let i in this._inputSources) {
|
||||
let is = this._inputSources[i];
|
||||
|
Reference in New Issue
Block a user