]> khamidou — GitHub mirrors - electron.git/commitdiff
Discard fullscreen support on OS X 10.6.
authorCheng Zhao <zcbenz@gmail.com>
Tue, 4 Jun 2013 10:15:03 +0000 (18:15 +0800)
committerCheng Zhao <zcbenz@gmail.com>
Tue, 4 Jun 2013 10:15:03 +0000 (18:15 +0800)
browser/default_app/main.js
browser/native_window_mac.h
browser/native_window_mac.mm

index ca7d753ec6e4776c519f49109c4454891b5a35da..7bef852e78fcdbe959753a6d8390397db23c8330 100644 (file)
@@ -111,6 +111,10 @@ delegate.browserMainParts.preMainMessageLoopRun = function() {
           accelerator: 'Command+R',
           click: function() { BrowserWindow.getFocusedWindow().reloadIgnoringCache(); }
         },
+        {
+          label: 'Enter Fullscreen',
+          click: function() { BrowserWindow.getFocusedWindow().setFullscreen(true); }
+        },
         {
           label: 'Toggle DevTools',
           accelerator: 'Alt+Command+I',
index ea20ef92ee03060ef372f624a0b094efad35c746..d2684735455565beca50babe940ad84e015e1bb5 100644 (file)
@@ -57,8 +57,6 @@ class NativeWindowMac : public NativeWindow {
   void NotifyWindowBlur() { NativeWindow::NotifyWindowBlur(); }
 
  protected:
-  void SetNonLionFullscreen(bool fullscreen);
-
   // Implementations of content::WebContentsDelegate.
   virtual void HandleKeyboardEvent(
       content::WebContents*,
@@ -70,9 +68,7 @@ class NativeWindowMac : public NativeWindow {
 
   NSWindow* window_;
 
-  bool is_fullscreen_;
   bool is_kiosk_;
-  NSRect restored_bounds_;
 
   NSInteger attention_request_id_;  // identifier from requestUserAttention
 
index f1436794eede0427f46b2d7996191c077a9dcd06..194b38b7d391d262be011b0453dedfe96447e038 100644 (file)
@@ -85,7 +85,6 @@ namespace atom {
 NativeWindowMac::NativeWindowMac(content::WebContents* web_contents,
                                  base::DictionaryValue* options)
     : NativeWindow(web_contents, options),
-      is_fullscreen_(false),
       is_kiosk_(false),
       attention_request_id_(0) {
   int width, height;
@@ -187,72 +186,19 @@ void NativeWindowMac::Restore() {
 }
 
 void NativeWindowMac::SetFullscreen(bool fullscreen) {
-  if (fullscreen == is_fullscreen_)
+  if (fullscreen == IsFullscreen())
     return;
 
-  if (base::mac::IsOSLionOrLater()) {
-    is_fullscreen_ = fullscreen;
-    [window() toggleFullScreen:nil];
+  if (!base::mac::IsOSLionOrLater()) {
+    LOG(ERROR) << "Fullscreen mode is only supported above Lion";
     return;
   }
 
-  DCHECK(base::mac::IsOSSnowLeopard());
-
-  SetNonLionFullscreen(fullscreen);
+  [window() toggleFullScreen:nil];
 }
 
 bool NativeWindowMac::IsFullscreen() {
-  return is_fullscreen_;
-}
-
-void NativeWindowMac::SetNonLionFullscreen(bool fullscreen) {
-  if (fullscreen == is_fullscreen_)
-    return;
-
-  is_fullscreen_ = fullscreen;
-
-  // Fade to black.
-  const CGDisplayReservationInterval kFadeDurationSeconds = 0.6;
-  bool did_fade_out = false;
-  CGDisplayFadeReservationToken token;
-  if (CGAcquireDisplayFadeReservation(kFadeDurationSeconds, &token) ==
-      kCGErrorSuccess) {
-    did_fade_out = true;
-    CGDisplayFade(token, kFadeDurationSeconds / 2, kCGDisplayBlendNormal,
-        kCGDisplayBlendSolidColor, 0.0, 0.0, 0.0, /*synchronous=*/true);
-  }
-
-  // Since frameless windows insert the WebContentsView into the NSThemeFrame
-  // ([[window contentView] superview]), and since that NSThemeFrame is
-  // destroyed and recreated when we change the styleMask of the window, we
-  // need to remove the view from the window when we change the style, and
-  // add it back afterwards.
-  UninstallView();
-  if (fullscreen) {
-    restored_bounds_ = [window() frame];
-    [window() setStyleMask:NSBorderlessWindowMask];
-    [window() setFrame:[window()
-        frameRectForContentRect:[[window() screen] frame]]
-               display:YES];
-    base::mac::RequestFullScreen(base::mac::kFullScreenModeAutoHideAll);
-  } else {
-    base::mac::ReleaseFullScreen(base::mac::kFullScreenModeAutoHideAll);
-    NSUInteger style_mask = NSTitledWindowMask | NSClosableWindowMask |
-                            NSMiniaturizableWindowMask | NSResizableWindowMask |
-                            NSTexturedBackgroundWindowMask;
-    [window() setStyleMask:style_mask];
-    [window() setFrame:restored_bounds_ display:YES];
-  }
-  InstallView();
-
-  // Fade back in.
-  if (did_fade_out) {
-    CGDisplayFade(token, kFadeDurationSeconds / 2, kCGDisplayBlendSolidColor,
-        kCGDisplayBlendNormal, 0.0, 0.0, 0.0, /*synchronous=*/false);
-    CGReleaseDisplayFadeReservation(token);
-  }
-
-  is_fullscreen_ = fullscreen;
+  return [window() styleMask] & NSFullScreenWindowMask;
 }
 
 void NativeWindowMac::SetSize(const gfx::Size& size) {
@@ -362,11 +308,11 @@ void NativeWindowMac::SetKiosk(bool kiosk) {
         NSApplicationPresentationDisableHideApplication;
     [NSApp setPresentationOptions:options];
     is_kiosk_ = true;
-    SetNonLionFullscreen(true);
+    SetFullscreen(true);
   } else {
     [NSApp setPresentationOptions:[NSApp currentSystemPresentationOptions]];
     is_kiosk_  = false;
-    SetNonLionFullscreen(false);
+    SetFullscreen(false);
   }
 }