]> khamidou — GitHub mirrors - electron.git/commitdiff
check if window is html or forced fullscreen
authordeepak1556 <hop2deep@gmail.com>
Tue, 19 May 2015 08:36:19 +0000 (14:06 +0530)
committerdeepak1556 <hop2deep@gmail.com>
Thu, 21 May 2015 04:46:11 +0000 (10:16 +0530)
atom/browser/api/atom_api_web_contents.cc
atom/browser/lib/guest-view-manager.coffee
atom/browser/native_window.cc
atom/browser/native_window.h
atom/renderer/lib/web-view/guest-view-internal.coffee
docs/api/web-view-tag.md

index b0a6217988bcba75004de759e23fde9bd53a2a69..f72a4c4d168375860efb91d286dabee0f53daa18 100644 (file)
@@ -221,6 +221,7 @@ void WebContents::EnterFullscreenModeForTab(content::WebContents* source,
   if (window) {
     window->SetHtmlApiFullscreen(true);
     source->GetRenderViewHost()->WasResized();
+    Emit("enter-html-full-screen");
   }
 }
 
@@ -229,6 +230,7 @@ void WebContents::ExitFullscreenModeForTab(content::WebContents* source) {
   if (window) {
     window->SetHtmlApiFullscreen(false);
     source->GetRenderViewHost()->WasResized();
+    Emit("leave-html-full-screen");
   }
 }
 
index 9403466f27a7a626d9692a991b94278117bf8344..f0d2a89318d6203f6fd49636707d65792427b6c9 100644 (file)
@@ -20,6 +20,8 @@ supportedWebViewEvents = [
   'destroyed'
   'page-title-set'
   'page-favicon-updated'
+  'enter-html-full-screen'
+  'leave-html-full-screen'
 ]
 
 nextInstanceId = 0
index 7d00483b20cc10b9f223188decdc74240077eef0..79ea407f3da4bfb88e937af585a40637728f5a36 100644 (file)
@@ -99,7 +99,7 @@ NativeWindow::NativeWindow(content::WebContents* web_contents,
       is_closed_(false),
       node_integration_(true),
       has_dialog_attached_(false),
-      fullscreen_(false),
+      html_fullscreen_(false),
       zoom_factor_(1.0),
       weak_factory_(this),
       inspectable_web_contents_(
@@ -806,8 +806,22 @@ void NativeWindow::ScheduleUnresponsiveEvent(int ms) {
 }
 
 void NativeWindow::SetHtmlApiFullscreen(bool enter_fullscreen) {
+  // Window is already in fullscreen mode, save the state.
+  if (enter_fullscreen && IsFullscreen()) {
+    forced_fullscreen_ = true;
+    html_fullscreen_ = true;
+    return;
+  }
+
+  // Exit html fullscreen state but not window's fullscreen mode.
+  if (!enter_fullscreen && forced_fullscreen_) {
+    html_fullscreen_ = false;
+    return;
+  }
+
   SetFullScreen(enter_fullscreen);
-  fullscreen_ = enter_fullscreen;
+  html_fullscreen_ = enter_fullscreen;
+  forced_fullscreen_ = false;
 }
 
 void NativeWindow::NotifyWindowUnresponsive() {
index ae53fba76f1ef2b6622003f64ad7d9db35a6a55c..f23c27ebf7701d053e3e7104b64574eb910805f2 100644 (file)
@@ -220,7 +220,7 @@ class NativeWindow : public brightray::DefaultWebContentsDelegate,
 
   bool has_frame() const { return has_frame_; }
 
-  bool IsHtmlApiFullscreen() const { return fullscreen_; }
+  bool IsHtmlApiFullscreen() const { return html_fullscreen_; }
 
   void set_has_dialog_attached(bool has_dialog_attached) {
     has_dialog_attached_ = has_dialog_attached;
@@ -349,7 +349,10 @@ class NativeWindow : public brightray::DefaultWebContentsDelegate,
   bool has_dialog_attached_;
 
   // Whether window is fullscreened by HTML5 api.
-  bool fullscreen_;
+  bool html_fullscreen_;
+
+  // Whether window is fullscreened by window api.
+  bool forced_fullscreen_;
 
   // Closure that would be called when window is unresponsive when closing,
   // it should be cancelled when we can prove that the window is responsive.
index fb1b40d27e1fdb8e26dd4f3e7ee7f681175be152..e856896ae61d98d62efce76d9efc8521b08f1a4b 100644 (file)
@@ -22,6 +22,8 @@ WEB_VIEW_EVENTS =
   'destroyed': []
   'page-title-set': ['title', 'explicitSet']
   'page-favicon-updated': ['favicons']
+  'enter-html-full-screen': []
+  'leave-html-full-screen': []
 
 dispatchEvent = (webView, event, args...) ->
   throw new Error("Unkown event #{event}") unless WEB_VIEW_EVENTS[event]?
index 5536920c5b7b83c4f83151f6248ef8d12a5e13da..f607f0d225bab2cba5cd560008cb92ddb37639b9 100644 (file)
@@ -361,6 +361,14 @@ url.
 
 Fired when page receives favicon urls.
 
+### enter-html-full-screen
+
+Fired when page enters fullscreen triggered by html api.
+
+### leave-html-full-screen
+
+Fired when page leaves fullscreen triggered by html api.
+
 ### console-message
 
 * `level` Integer