From eb7415d33803bccd77f674bbc620c93dc3a0c067 Mon Sep 17 00:00:00 2001 From: Alexandre Poirot Date: Wed, 22 Jan 2014 14:06:46 -0500 Subject: [PATCH] Bug 961784 - Fix system app event listening in the mulet. r=fabrice --- b2g/chrome/content/desktop.js | 9 ++++++++- b2g/chrome/content/shell.js | 14 +++++++++++--- 2 files changed, 19 insertions(+), 4 deletions(-) diff --git a/b2g/chrome/content/desktop.js b/b2g/chrome/content/desktop.js index 311d2e886c8..9224678503a 100644 --- a/b2g/chrome/content/desktop.js +++ b/b2g/chrome/content/desktop.js @@ -1,3 +1,6 @@ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this file, + * You can obtain one at http://mozilla.org/MPL/2.0/. */ window.addEventListener("ContentStart", function(evt) { // Enable touch event shim on desktop that translates mouse events @@ -5,6 +8,10 @@ window.addEventListener("ContentStart", function(evt) { let require = Cu.import("resource://gre/modules/devtools/Loader.jsm", {}) .devtools.require; let { TouchEventHandler } = require("devtools/touch-events"); - let touchEventHandler = new TouchEventHandler(shell.contentBrowser); + let chromeEventHandler = window.QueryInterface(Ci.nsIInterfaceRequestor) + .getInterface(Ci.nsIWebNavigation) + .QueryInterface(Ci.nsIDocShell) + .chromeEventHandler || window; + let touchEventHandler = new TouchEventHandler(chromeEventHandler); touchEventHandler.start(); }); diff --git a/b2g/chrome/content/shell.js b/b2g/chrome/content/shell.js index d48980d8635..ca7ac4978a0 100644 --- a/b2g/chrome/content/shell.js +++ b/b2g/chrome/content/shell.js @@ -294,14 +294,22 @@ var shell = { .sessionHistory = Cc["@mozilla.org/browser/shistory;1"] .createInstance(Ci.nsISHistory); + // On firefox mulet, shell.html is loaded in a tab + // and we have to listen on the chrome event handler + // to catch key events + let chromeEventHandler = window.QueryInterface(Ci.nsIInterfaceRequestor) + .getInterface(Ci.nsIWebNavigation) + .QueryInterface(Ci.nsIDocShell) + .chromeEventHandler || window; // Capture all key events so we can filter out hardware buttons // And send them to Gaia via mozChromeEvents. // Ideally, hardware buttons wouldn't generate key events at all, or // if they did, they would use keycodes that conform to DOM 3 Events. // See discussion in https://bugzilla.mozilla.org/show_bug.cgi?id=762362 - window.addEventListener('keydown', this, true); - window.addEventListener('keypress', this, true); - window.addEventListener('keyup', this, true); + chromeEventHandler.addEventListener('keydown', this, true); + chromeEventHandler.addEventListener('keypress', this, true); + chromeEventHandler.addEventListener('keyup', this, true); + window.addEventListener('MozApplicationManifest', this); window.addEventListener('mozfullscreenchange', this); window.addEventListener('MozAfterPaint', this);