Bug 728373 - Ensure the xul window handle keypress when the screen goes fullscreen r=cjones

This commit is contained in:
Vivien Nicolas 2012-02-17 22:37:53 +01:00
parent 39bb4f69c4
commit 2f365eb1c3

View File

@ -26,11 +26,18 @@ XPCOMUtils.defineLazyGetter(Services, 'ss', function() {
return Cc['@mozilla.org/content/style-sheet-service;1']
.getService(Ci.nsIStyleSheetService);
});
XPCOMUtils.defineLazyGetter(Services, 'idle', function() {
return Cc['@mozilla.org/widget/idleservice;1']
.getService(Ci.nsIIdleService);
});
XPCOMUtils.defineLazyServiceGetter(Services, 'fm', function(){
return Cc['@mozilla.org/focus-managr;1']
.getService(Ci.nsFocusManager);
});
// In order to use http:// scheme instead of file:// scheme
// (that is much more restricted) the following code kick-off
// a local http server listening on http://127.0.0.1:7777 and
@ -106,6 +113,7 @@ var shell = {
window.addEventListener('keypress', this);
window.addEventListener('MozApplicationManifest', this);
window.addEventListener("AppCommand", this);
window.addEventListener('mozfullscreenchange', this);
this.contentBrowser.addEventListener('load', this, true);
try {
@ -244,6 +252,14 @@ var shell = {
break;
}
break;
case 'mozfullscreenchange':
// When the screen goes fullscreen make sure to set the focus to the
// main window so noboby can prevent the ESC key to get out fullscreen
// mode
if (document.mozFullScreen)
Services.fm.focusedWindow = window;
break;
case 'load':
this.contentBrowser.removeEventListener('load', this, true);
this.turnScreenOn();
@ -410,3 +426,4 @@ Services.obs.addObserver(function onConsoleAPILogEvent(subject, topic, data) {
dump('Opened socket on ' + serverSocket.port + '\n');
serverSocket.asyncListen(listener);
})();