| Index: chrome/browser/cocoa/fullscreen_controller.mm
|
| ===================================================================
|
| --- chrome/browser/cocoa/fullscreen_controller.mm (revision 58173)
|
| +++ chrome/browser/cocoa/fullscreen_controller.mm (working copy)
|
| @@ -7,6 +7,8 @@
|
| #include <algorithm>
|
|
|
| #import "chrome/browser/cocoa/browser_window_controller.h"
|
| +#import "chrome/browser/cocoa/floating_bar_backing_view.h"
|
| +#import "chrome/browser/cocoa/fullscreen_window.h"
|
| #import "third_party/GTM/AppKit/GTMNSAnimation+Duration.h"
|
|
|
| NSString* const kWillEnterFullscreenNotification =
|
| @@ -167,6 +169,12 @@
|
| if ((self == [super init])) {
|
| browserController_ = controller;
|
| currentFullscreenMode_ = mac_util::kFullScreenModeNormal;
|
| +
|
| + NSScreen* screen = [[browserController_ window] screen];
|
| + fullscreenWindow_.reset([[FullscreenWindow alloc] initForScreen:screen]);
|
| +
|
| + floatingBarBackingView_.reset(
|
| + [[FloatingBarBackingView alloc] initWithFrame:NSZeroRect]);
|
| }
|
|
|
| // Let the world know what we're up to.
|
| @@ -192,21 +200,20 @@
|
|
|
| // Register for notifications. Self is removed as an observer in |-cleanup|.
|
| NSNotificationCenter* nc = [NSNotificationCenter defaultCenter];
|
| - NSWindow* window = [browserController_ window];
|
| [nc addObserver:self
|
| selector:@selector(windowDidChangeScreen:)
|
| name:NSWindowDidChangeScreenNotification
|
| - object:window];
|
| + object:fullscreenWindow_];
|
|
|
| [nc addObserver:self
|
| selector:@selector(windowDidBecomeMain:)
|
| name:NSWindowDidBecomeMainNotification
|
| - object:window];
|
| + object:fullscreenWindow_];
|
|
|
| [nc addObserver:self
|
| selector:@selector(windowDidResignMain:)
|
| name:NSWindowDidResignMainNotification
|
| - object:window];
|
| + object:fullscreenWindow_];
|
| }
|
|
|
| - (void)exitFullscreen {
|
| @@ -218,6 +225,18 @@
|
| isFullscreen_ = NO;
|
| }
|
|
|
| +- (FullscreenWindow*)window {
|
| + return fullscreenWindow_.get();
|
| +}
|
| +
|
| +- (BOOL)hasFloatingBarBackingView {
|
| + return floatingBarBackingView_.get() != nil;
|
| +}
|
| +
|
| +- (NSView*)floatingBarBackingView {
|
| + return floatingBarBackingView_.get();
|
| +}
|
| +
|
| - (void)windowDidChangeScreen:(NSNotification*)notification {
|
| [browserController_ resizeFullscreenWindow];
|
| }
|
| @@ -300,11 +319,11 @@
|
| }
|
|
|
| - (CGFloat)floatingBarShownFraction {
|
| - return [browserController_ floatingBarShownFraction];
|
| + return floatingBarShownFraction_;
|
| }
|
|
|
| - (void)changeFloatingBarShownFraction:(CGFloat)fraction {
|
| - [browserController_ setFloatingBarShownFraction:fraction];
|
| + floatingBarShownFraction_ = fraction;
|
|
|
| mac_util::FullScreenMode desiredMode = [self desiredFullscreenMode];
|
| if (desiredMode != currentFullscreenMode_ && [self shouldToggleMenuBar]) {
|
| @@ -314,6 +333,8 @@
|
| mac_util::SwitchFullScreenModes(currentFullscreenMode_, desiredMode);
|
| currentFullscreenMode_ = desiredMode;
|
| }
|
| +
|
| + [browserController_ floatingBarShownFractionChanged];
|
| }
|
|
|
| // Used to activate the floating bar in fullscreen mode.
|
| @@ -386,18 +407,17 @@
|
| @implementation FullscreenController (PrivateMethods)
|
|
|
| - (BOOL)isWindowOnPrimaryScreen {
|
| - NSScreen* screen = [[browserController_ window] screen];
|
| + NSScreen* screen = [fullscreenWindow_ screen];
|
| NSScreen* primaryScreen = [[NSScreen screens] objectAtIndex:0];
|
| return (screen == primaryScreen);
|
| }
|
|
|
| - (BOOL)shouldToggleMenuBar {
|
| - return [self isWindowOnPrimaryScreen] &&
|
| - [[browserController_ window] isMainWindow];
|
| + return [self isWindowOnPrimaryScreen] && [fullscreenWindow_ isMainWindow];
|
| }
|
|
|
| - (mac_util::FullScreenMode)desiredFullscreenMode {
|
| - if ([browserController_ floatingBarShownFraction] >= 1.0)
|
| + if (floatingBarShownFraction_ >= 1.0)
|
| return mac_util::kFullScreenModeHideDock;
|
| return mac_util::kFullScreenModeHideAll;
|
| }
|
| @@ -422,7 +442,7 @@
|
|
|
| // Now, if it happens to already be in the right state, there's nothing more
|
| // to do.
|
| - if ([browserController_ floatingBarShownFraction] == fraction)
|
| + if (floatingBarShownFraction_ == fraction)
|
| return;
|
|
|
| // Create the animation and set it up.
|
| @@ -485,8 +505,7 @@
|
| }
|
|
|
| - (BOOL)mouseInsideTrackingRect {
|
| - NSWindow* window = [browserController_ window];
|
| - NSPoint mouseLoc = [window mouseLocationOutsideOfEventStream];
|
| + NSPoint mouseLoc = [fullscreenWindow_ mouseLocationOutsideOfEventStream];
|
| NSPoint mousePos = [contentView_ convertPoint:mouseLoc fromView:nil];
|
| return NSMouseInRect(mousePos, trackingAreaBounds_, [contentView_ isFlipped]);
|
| }
|
| @@ -594,6 +613,9 @@
|
| // notifications.
|
| [self hideActiveWindowUI];
|
|
|
| + // Just in case.
|
| + [floatingBarBackingView_ removeFromSuperview];
|
| +
|
| // No more calls back up to the BWC.
|
| browserController_ = nil;
|
| }
|
|
|