Bug 1097814 - Fix fake hardware buttons in mulet. r=paul, r=vingtetun

This commit is contained in:
Alexandre Poirot 2014-11-20 10:48:00 -05:00
Родитель a2bee51132
Коммит 9b02c5402d
2 изменённых файлов: 23 добавлений и 17 удалений

Просмотреть файл

@ -89,10 +89,16 @@ let SystemAppProxy = {
}, },
// Now deprecated, use sendCustomEvent with a custom event name // Now deprecated, use sendCustomEvent with a custom event name
dispatchEvent: function systemApp_sendChromeEvent(details, target) { dispatchEvent: function systemApp_dispatchEvent(details, target) {
return this._sendCustomEvent('mozChromeEvent', details, false, target); return this._sendCustomEvent('mozChromeEvent', details, false, target);
}, },
dispatchKeyboardEvent: function systemApp_dispatchKeyboardEvent(type, details) {
let content = this._frame ? this._frame.contentWindow : null;
let e = new content.KeyboardEvent(type, details);
content.dispatchEvent(e);
},
// Listen for dom events on the system app // Listen for dom events on the system app
addEventListener: function systemApp_addEventListener() { addEventListener: function systemApp_addEventListener() {
let content = this._frame ? this._frame.contentWindow : null; let content = this._frame ? this._frame.contentWindow : null;

Просмотреть файл

@ -482,11 +482,11 @@ ResponsiveUI.prototype = {
sleepButton.className = "devtools-responsiveui-sleep-button"; sleepButton.className = "devtools-responsiveui-sleep-button";
sleepButton.setAttribute("top", 0); sleepButton.setAttribute("top", 0);
sleepButton.setAttribute("right", 0); sleepButton.setAttribute("right", 0);
sleepButton.addEventListener("mousedown", function() { sleepButton.addEventListener("mousedown", () => {
SystemAppProxy.dispatchEvent({type: "sleep-button-press"}); SystemAppProxy.dispatchKeyboardEvent("keydown", {key: "Power"});
}); });
sleepButton.addEventListener("mouseup", function() { sleepButton.addEventListener("mouseup", () => {
SystemAppProxy.dispatchEvent({type: "sleep-button-release"}); SystemAppProxy.dispatchKeyboardEvent("keyup", {key: "Power"});
}); });
this.stack.appendChild(sleepButton); this.stack.appendChild(sleepButton);
@ -497,20 +497,20 @@ ResponsiveUI.prototype = {
let volumeUp = this.chromeDoc.createElement("button"); let volumeUp = this.chromeDoc.createElement("button");
volumeUp.className = "devtools-responsiveui-volume-up-button"; volumeUp.className = "devtools-responsiveui-volume-up-button";
volumeUp.addEventListener("mousedown", function() { volumeUp.addEventListener("mousedown", () => {
SystemAppProxy.dispatchEvent({type: "volume-up-button-press"}); SystemAppProxy.dispatchKeyboardEvent("keydown", {key: "VolumeUp"});
}); });
volumeUp.addEventListener("mouseup", function() { volumeUp.addEventListener("mouseup", () => {
SystemAppProxy.dispatchEvent({type: "volume-up-button-release"}); SystemAppProxy.dispatchKeyboardEvent("keyup", {key: "VolumeUp"});
}); });
let volumeDown = this.chromeDoc.createElement("button"); let volumeDown = this.chromeDoc.createElement("button");
volumeDown.className = "devtools-responsiveui-volume-down-button"; volumeDown.className = "devtools-responsiveui-volume-down-button";
volumeDown.addEventListener("mousedown", function() { volumeDown.addEventListener("mousedown", () => {
SystemAppProxy.dispatchEvent({type: "volume-down-button-press"}); SystemAppProxy.dispatchKeyboardEvent("keydown", {key: "VolumeDown"});
}); });
volumeDown.addEventListener("mouseup", function() { volumeDown.addEventListener("mouseup", () => {
SystemAppProxy.dispatchEvent({type: "volume-down-button-release"}); SystemAppProxy.dispatchKeyboardEvent("keyup", {key: "VolumeDown"});
}); });
volumeButtons.appendChild(volumeUp); volumeButtons.appendChild(volumeUp);
@ -524,11 +524,11 @@ ResponsiveUI.prototype = {
let homeButton = this.chromeDoc.createElement("toolbarbutton"); let homeButton = this.chromeDoc.createElement("toolbarbutton");
homeButton.className = "devtools-responsiveui-toolbarbutton devtools-responsiveui-home-button"; homeButton.className = "devtools-responsiveui-toolbarbutton devtools-responsiveui-home-button";
homeButton.addEventListener("mousedown", function() { homeButton.addEventListener("mousedown", () => {
SystemAppProxy.dispatchEvent({type: "home-button-press"}); SystemAppProxy.dispatchKeyboardEvent("keydown", {key: "Home"});
}); });
homeButton.addEventListener("mouseup", function() { homeButton.addEventListener("mouseup", () => {
SystemAppProxy.dispatchEvent({type: "home-button-release"}); SystemAppProxy.dispatchKeyboardEvent("keyup", {key: "Home"});
}); });
bottomToolbar.appendChild(homeButton); bottomToolbar.appendChild(homeButton);
this.bottomToolbar = bottomToolbar; this.bottomToolbar = bottomToolbar;