Discard fullscreen support on OS X 10.6.
This commit is contained in:
parent
a1dc4b88be
commit
556e84f53a
3 changed files with 11 additions and 65 deletions
|
@ -111,6 +111,10 @@ delegate.browserMainParts.preMainMessageLoopRun = function() {
|
||||||
accelerator: 'Command+R',
|
accelerator: 'Command+R',
|
||||||
click: function() { BrowserWindow.getFocusedWindow().reloadIgnoringCache(); }
|
click: function() { BrowserWindow.getFocusedWindow().reloadIgnoringCache(); }
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
label: 'Enter Fullscreen',
|
||||||
|
click: function() { BrowserWindow.getFocusedWindow().setFullscreen(true); }
|
||||||
|
},
|
||||||
{
|
{
|
||||||
label: 'Toggle DevTools',
|
label: 'Toggle DevTools',
|
||||||
accelerator: 'Alt+Command+I',
|
accelerator: 'Alt+Command+I',
|
||||||
|
|
|
@ -57,8 +57,6 @@ class NativeWindowMac : public NativeWindow {
|
||||||
void NotifyWindowBlur() { NativeWindow::NotifyWindowBlur(); }
|
void NotifyWindowBlur() { NativeWindow::NotifyWindowBlur(); }
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void SetNonLionFullscreen(bool fullscreen);
|
|
||||||
|
|
||||||
// Implementations of content::WebContentsDelegate.
|
// Implementations of content::WebContentsDelegate.
|
||||||
virtual void HandleKeyboardEvent(
|
virtual void HandleKeyboardEvent(
|
||||||
content::WebContents*,
|
content::WebContents*,
|
||||||
|
@ -70,9 +68,7 @@ class NativeWindowMac : public NativeWindow {
|
||||||
|
|
||||||
NSWindow* window_;
|
NSWindow* window_;
|
||||||
|
|
||||||
bool is_fullscreen_;
|
|
||||||
bool is_kiosk_;
|
bool is_kiosk_;
|
||||||
NSRect restored_bounds_;
|
|
||||||
|
|
||||||
NSInteger attention_request_id_; // identifier from requestUserAttention
|
NSInteger attention_request_id_; // identifier from requestUserAttention
|
||||||
|
|
||||||
|
|
|
@ -85,7 +85,6 @@ namespace atom {
|
||||||
NativeWindowMac::NativeWindowMac(content::WebContents* web_contents,
|
NativeWindowMac::NativeWindowMac(content::WebContents* web_contents,
|
||||||
base::DictionaryValue* options)
|
base::DictionaryValue* options)
|
||||||
: NativeWindow(web_contents, options),
|
: NativeWindow(web_contents, options),
|
||||||
is_fullscreen_(false),
|
|
||||||
is_kiosk_(false),
|
is_kiosk_(false),
|
||||||
attention_request_id_(0) {
|
attention_request_id_(0) {
|
||||||
int width, height;
|
int width, height;
|
||||||
|
@ -187,72 +186,19 @@ void NativeWindowMac::Restore() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void NativeWindowMac::SetFullscreen(bool fullscreen) {
|
void NativeWindowMac::SetFullscreen(bool fullscreen) {
|
||||||
if (fullscreen == is_fullscreen_)
|
if (fullscreen == IsFullscreen())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (base::mac::IsOSLionOrLater()) {
|
if (!base::mac::IsOSLionOrLater()) {
|
||||||
is_fullscreen_ = fullscreen;
|
LOG(ERROR) << "Fullscreen mode is only supported above Lion";
|
||||||
[window() toggleFullScreen:nil];
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
DCHECK(base::mac::IsOSSnowLeopard());
|
[window() toggleFullScreen:nil];
|
||||||
|
|
||||||
SetNonLionFullscreen(fullscreen);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool NativeWindowMac::IsFullscreen() {
|
bool NativeWindowMac::IsFullscreen() {
|
||||||
return is_fullscreen_;
|
return [window() styleMask] & NSFullScreenWindowMask;
|
||||||
}
|
|
||||||
|
|
||||||
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;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void NativeWindowMac::SetSize(const gfx::Size& size) {
|
void NativeWindowMac::SetSize(const gfx::Size& size) {
|
||||||
|
@ -362,11 +308,11 @@ void NativeWindowMac::SetKiosk(bool kiosk) {
|
||||||
NSApplicationPresentationDisableHideApplication;
|
NSApplicationPresentationDisableHideApplication;
|
||||||
[NSApp setPresentationOptions:options];
|
[NSApp setPresentationOptions:options];
|
||||||
is_kiosk_ = true;
|
is_kiosk_ = true;
|
||||||
SetNonLionFullscreen(true);
|
SetFullscreen(true);
|
||||||
} else {
|
} else {
|
||||||
[NSApp setPresentationOptions:[NSApp currentSystemPresentationOptions]];
|
[NSApp setPresentationOptions:[NSApp currentSystemPresentationOptions]];
|
||||||
is_kiosk_ = false;
|
is_kiosk_ = false;
|
||||||
SetNonLionFullscreen(false);
|
SetFullscreen(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue