Bug 715696: Make sure the screen comes on when b2g loads, and when toggling it also set the brightness. r=vingtetun

This commit is contained in:
Chris Jones 2012-01-05 17:04:03 -08:00
parent 7fbe6702dc
commit bbe3bec9f7

View File

@ -1,3 +1,5 @@
/* -*- Mode: Java; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- /
/* vim: set shiftwidth=2 tabstop=2 autoindent cindent expandtab: */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
@ -91,6 +93,9 @@ function addPermissions(urls) {
var shell = {
// FIXME/bug 678695: this should be a system setting
preferredScreenBrightness: 1.0,
get home() {
delete this.home;
return this.home = document.getElementById('homescreen');
@ -195,7 +200,7 @@ var shell = {
this.sendEvent(this.home.contentWindow, 'home');
break;
case evt.DOM_VK_SLEEP:
screen.mozEnabled = !screen.mozEnabled;
this.toggleScreen();
break;
case evt.DOM_VK_ESCAPE:
if (evt.defaultPrevented)
@ -206,6 +211,7 @@ var shell = {
break;
case 'load':
this.home.removeEventListener('load', this, true);
this.turnScreenOn();
this.sendEvent(window, 'ContentStart');
break;
case 'MozApplicationManifest':
@ -248,7 +254,21 @@ var shell = {
let event = content.document.createEvent('CustomEvent');
event.initCustomEvent(type, true, true, details ? details : {});
content.dispatchEvent(event);
}
},
toggleScreen: function shell_toggleScreen() {
if (screen.mozEnabled)
this.turnScreenOff();
else
this.turnScreenOn();
},
turnScreenOff: function shell_turnScreenOff() {
screen.mozEnabled = false;
screen.mozBrightness = 0.0;
},
turnScreenOn: function shell_turnScreenOn() {
screen.mozEnabled = true;
screen.mozBrightness = this.preferredScreenBrightness;
},
};
(function VirtualKeyboardManager() {