Bug 772743 - Add pref to not make the widget fullscreen when entering fullscreen. Set it to true for b2g desktop client. r=mounir
authorChris Pearce <cpearce@mozilla.com>
Fri, 13 Jul 2012 22:21:23 +1200
changeset 101894 e3f2d02b21b98e4a683404cc96d55133f97db24c
parent 101893 14e984035ca5bcbd98cd8af7808c54977f7c9cb3
child 101895 6c7c4782f088dfa7ab895d5cb04acdbb80b7d3ec
push idunknown
push userunknown
push dateunknown
reviewersmounir
bugs772743
milestone16.0a1
Bug 772743 - Add pref to not make the widget fullscreen when entering fullscreen. Set it to true for b2g desktop client. r=mounir
b2g/app/b2g.js
dom/base/nsGlobalWindow.cpp
--- a/b2g/app/b2g.js
+++ b/b2g/app/b2g.js
@@ -404,16 +404,26 @@ pref("b2g.remote-js.port", 9999);
 // Handle hardware buttons in the b2g chrome package
 pref("b2g.keys.menu.enabled", true);
 
 // Screen timeout in seconds
 pref("power.screen.timeout", 60);
 
 pref("full-screen-api.enabled", true);
 
+#ifndef MOZ_WIDGET_GONK
+// If we're not actually on physical hardware, don't make the top level widget
+// fullscreen when transitioning to fullscreen. This means in emulated
+// environments (like the b2g desktop client) we won't make the client window
+// fill the whole screen, we'll just make the content fill the client window,
+// i.e. it won't give the impression to content that the number of device
+// screen pixels changes!
+pref("full-screen-api.ignore-widgets", true);
+#endif
+
 pref("media.volume.steps", 10);
 
 //Enable/disable marionette server, set listening port
 pref("marionette.defaultPrefs.enabled", true);
 pref("marionette.defaultPrefs.port", 2828);
 
 #ifdef MOZ_UPDATER
 pref("app.update.enabled", true);
--- a/dom/base/nsGlobalWindow.cpp
+++ b/dom/base/nsGlobalWindow.cpp
@@ -4481,19 +4481,25 @@ nsGlobalWindow::SetFullScreenInternal(bo
   if (aFullScreen && xulWin) {
     xulWin->SetIntrinsicallySized(false);
   }
 
   // Set this before so if widget sends an event indicating its
   // gone full screen, the state trap above works.
   mFullScreen = aFullScreen;
 
-  nsCOMPtr<nsIWidget> widget = GetMainWidget();
-  if (widget)
-    widget->MakeFullScreen(aFullScreen);
+  // Sometimes we don't want the top-level widget to actually go fullscreen,
+  // for example in the B2G desktop client, we don't want the emulated screen
+  // dimensions to appear to increase when entering fullscreen mode; we just
+  // want the content to fill the entire client area of the emulator window.
+  if (!Preferences::GetBool("full-screen-api.ignore-widgets", false)) {
+    nsCOMPtr<nsIWidget> widget = GetMainWidget();
+    if (widget)
+      widget->MakeFullScreen(aFullScreen);
+  }
 
   if (!mFullScreen) {
     // Force exit from DOM full-screen mode. This is so that if we're in
     // DOM full-screen mode and the user exits full-screen mode with
     // the browser full-screen mode toggle keyboard-shortcut, we'll detect
     // that and leave DOM API full-screen mode too.
     nsIDocument::ExitFullScreen(false);
   }