mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-29 07:42:04 +00:00
Bug 912951 - Implement supportsSwitching in inputMethod based on content events from gaia. r=yxl
This commit is contained in:
parent
caa5867022
commit
c285b0ca12
@ -700,6 +700,9 @@ var CustomEventManager = {
|
||||
case 'captive-portal-login-cancel':
|
||||
CaptivePortalLoginHelper.handleEvent(detail);
|
||||
break;
|
||||
case 'inputmethod-update-layouts':
|
||||
KeyboardHelper.handleEvent(detail);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1052,6 +1055,14 @@ let RemoteDebugger = {
|
||||
}
|
||||
}
|
||||
|
||||
let KeyboardHelper = {
|
||||
handleEvent: function keyboard_handleEvent(aMessage) {
|
||||
let data = aMessage.data;
|
||||
|
||||
Keyboard.setLayouts(data.layouts);
|
||||
}
|
||||
};
|
||||
|
||||
// This is the backend for Gaia's screenshot feature. Gaia requests a
|
||||
// screenshot by sending a mozContentEvent with detail.type set to
|
||||
// 'take-screenshot'. Then we take a screenshot and send a
|
||||
|
@ -238,6 +238,10 @@ let Keyboard = {
|
||||
},
|
||||
|
||||
getContext: function keyboardGetContext(msg) {
|
||||
if (this._layouts) {
|
||||
ppmm.broadcastAsyncMessage('Keyboard:LayoutsChange', this._layouts);
|
||||
}
|
||||
|
||||
this.sendAsyncMessage('Forms:GetContext', msg.data);
|
||||
},
|
||||
|
||||
@ -247,6 +251,19 @@ let Keyboard = {
|
||||
|
||||
endComposition: function keyboardEndComposition(msg) {
|
||||
this.sendAsyncMessage('Forms:EndComposition', msg.data);
|
||||
},
|
||||
|
||||
/**
|
||||
* Get the number of keyboard layouts active from keyboard_manager
|
||||
*/
|
||||
_layouts: null,
|
||||
setLayouts: function keyboardSetLayoutCount(layouts) {
|
||||
// The input method plugins may not have loaded yet,
|
||||
// cache the layouts so on init we can respond immediately instead
|
||||
// of going back and forth between keyboard_manager
|
||||
this._layouts = layouts;
|
||||
|
||||
ppmm.broadcastAsyncMessage('Keyboard:LayoutsChange', layouts);
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -207,6 +207,8 @@ MozKeyboard.prototype = {
|
||||
function MozInputMethodManager() { }
|
||||
|
||||
MozInputMethodManager.prototype = {
|
||||
_supportsSwitching: false,
|
||||
|
||||
classID: Components.ID("{7e9d7280-ef86-11e2-b778-0800200c9a66}"),
|
||||
|
||||
QueryInterface: XPCOMUtils.generateQI([
|
||||
@ -230,7 +232,7 @@ MozInputMethodManager.prototype = {
|
||||
},
|
||||
|
||||
supportsSwitching: function() {
|
||||
return true;
|
||||
return this._supportsSwitching;
|
||||
},
|
||||
|
||||
hide: function() {
|
||||
@ -247,6 +249,7 @@ function MozInputMethod() { }
|
||||
|
||||
MozInputMethod.prototype = {
|
||||
_inputcontext: null,
|
||||
_layouts: {},
|
||||
|
||||
classID: Components.ID("{4607330d-e7d2-40a4-9eb8-43967eae0142}"),
|
||||
|
||||
@ -284,6 +287,7 @@ MozInputMethod.prototype = {
|
||||
cpmm.addMessageListener('Keyboard:FocusChange', this);
|
||||
cpmm.addMessageListener('Keyboard:SelectionChange', this);
|
||||
cpmm.addMessageListener('Keyboard:GetContext:Result:OK', this);
|
||||
cpmm.addMessageListener('Keyboard:LayoutsChange', this);
|
||||
|
||||
// If there already is an active context, then this will trigger
|
||||
// a GetContext:Result:OK event, and we can initialize ourselves.
|
||||
@ -296,6 +300,7 @@ MozInputMethod.prototype = {
|
||||
cpmm.removeMessageListener('Keyboard:FocusChange', this);
|
||||
cpmm.removeMessageListener('Keyboard:SelectionChange', this);
|
||||
cpmm.removeMessageListener('Keyboard:GetContext:Result:OK', this);
|
||||
cpmm.removeMessageListener('Keyboard:LayoutsChange', this);
|
||||
|
||||
this._window = null;
|
||||
this._mgmt = null;
|
||||
@ -320,6 +325,9 @@ MozInputMethod.prototype = {
|
||||
case 'Keyboard:GetContext:Result:OK':
|
||||
this.setInputContext(json);
|
||||
break;
|
||||
case 'Keyboard:LayoutsChange':
|
||||
this._layouts = json;
|
||||
break;
|
||||
}
|
||||
},
|
||||
|
||||
@ -349,9 +357,14 @@ MozInputMethod.prototype = {
|
||||
if (this._inputcontext) {
|
||||
this._inputcontext.destroy();
|
||||
this._inputcontext = null;
|
||||
this._mgmt._supportsSwitching = false;
|
||||
}
|
||||
|
||||
if (data) {
|
||||
this._mgmt._supportsSwitching = this._layouts[data.type] ?
|
||||
this._layouts[data.type] > 1 :
|
||||
false;
|
||||
|
||||
this._inputcontext = new MozInputContext(data);
|
||||
this._inputcontext.init(this._window);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user