Commit 7f8549a7 authored by mark@chromium.org's avatar mark@chromium.org

Fix OS full-screen button on FutureCat. The full-screen button should trigger

Chrome's full-screen mode. This should work properly even on subsequent
clicks, when a window was already full-screened and then not-full-screened.

BUG=85196
TEST=On FutureCat, use the full-screen button to go full-screen, then exit
     full-screen, then re-enter full-screen with the OS button again. Both
     times, Chrome's full-screen mode should be activated in the same way.
Review URL: http://codereview.chromium.org/7003036

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@88533 0039d316-1c4b-4281-b951-d872f2087c98
parent df6ecd31
...@@ -157,19 +157,9 @@ ...@@ -157,19 +157,9 @@
MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_7 MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_7
@interface NSWindow (LionSDKDeclarations) @interface NSWindow (LionSDKDeclarations)
- (void)toggleFullScreen:(id)sender;
- (void)setRestorable:(BOOL)flag; - (void)setRestorable:(BOOL)flag;
@end @end
enum {
NSWindowCollectionBehaviorFullScreenPrimary = 1 << 7,
NSWindowCollectionBehaviorFullScreenAuxiliary = 1 << 8
};
enum {
NSWindowFullScreenButton = 7
};
#endif // MAC_OS_X_VERSION_10_7 #endif // MAC_OS_X_VERSION_10_7
// IncognitoImageView subclasses NSView to allow mouse events to pass through it // IncognitoImageView subclasses NSView to allow mouse events to pass through it
...@@ -417,20 +407,7 @@ enum { ...@@ -417,20 +407,7 @@ enum {
if ([self hasToolbar]) // Do not create the buttons in popups. if ([self hasToolbar]) // Do not create the buttons in popups.
[toolbarController_ createBrowserActionButtons]; [toolbarController_ createBrowserActionButtons];
// For versions of Mac OS that provide an "enter fullscreen" button, make [self setUpOSFullScreenButton];
// one appear (in a rather hacky manner). http://crbug.com/74065 : When
// switching the fullscreen implementation to the new API, revisit how much
// of this hacky code is necessary.
if ([window respondsToSelector:@selector(toggleFullScreen:)]) {
NSWindowCollectionBehavior behavior = [window collectionBehavior];
behavior |= NSWindowCollectionBehaviorFullScreenPrimary;
[window setCollectionBehavior:behavior];
NSButton* fullscreenButton =
[window standardWindowButton:NSWindowFullScreenButton];
[fullscreenButton setAction:@selector(enterFullscreen:)];
[fullscreenButton setTarget:self];
}
// We are done initializing now. // We are done initializing now.
initializing_ = NO; initializing_ = NO;
...@@ -2060,6 +2037,10 @@ willAnimateFromState:(bookmarks::VisualState)oldState ...@@ -2060,6 +2037,10 @@ willAnimateFromState:(bookmarks::VisualState)oldState
// We're done moving focus, so re-enable bar visibility changes. // We're done moving focus, so re-enable bar visibility changes.
[self enableBarVisibilityUpdates]; [self enableBarVisibilityUpdates];
// This needs to be done when leaving full-screen mode to ensure that the
// button's action is set properly.
[self setUpOSFullScreenButton];
// Fade back in. // Fade back in.
if (didFadeOut) { if (didFadeOut) {
CGDisplayFade(token, kFadeDurationSeconds / 2, kCGDisplayBlendSolidColor, CGDisplayFade(token, kFadeDurationSeconds / 2, kCGDisplayBlendSolidColor,
......
// Copyright (c) 2010 The Chromium Authors. All rights reserved. // Copyright (c) 2011 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
...@@ -113,6 +113,12 @@ ...@@ -113,6 +113,12 @@
- (void)enableBarVisibilityUpdates; - (void)enableBarVisibilityUpdates;
- (void)disableBarVisibilityUpdates; - (void)disableBarVisibilityUpdates;
// For versions of Mac OS that provide an "enter fullscreen" button, make one
// appear (in a rather hacky manner). http://crbug.com/74065 : When switching
// the fullscreen implementation to the new API, revisit how much of this
// hacky code is necessary.
- (void)setUpOSFullScreenButton;
@end // @interface BrowserWindowController(Private) @end // @interface BrowserWindowController(Private)
......
...@@ -30,6 +30,26 @@ ...@@ -30,6 +30,26 @@
#include "content/browser/tab_contents/tab_contents.h" #include "content/browser/tab_contents/tab_contents.h"
#include "content/browser/tab_contents/tab_contents_view.h" #include "content/browser/tab_contents/tab_contents_view.h"
// Provide the forward-declarations of new 10.7 SDK symbols so they can be
// called when building with the 10.5 SDK.
#if !defined(MAC_OS_X_VERSION_10_7) || \
MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_7
@interface NSWindow (LionSDKDeclarations)
- (void)toggleFullScreen:(id)sender;
@end
enum {
NSWindowCollectionBehaviorFullScreenPrimary = 1 << 7,
NSWindowCollectionBehaviorFullScreenAuxiliary = 1 << 8
};
enum {
NSWindowFullScreenButton = 7
};
#endif // MAC_OS_X_VERSION_10_7
namespace { namespace {
// Space between the incognito badge and the right edge of the window. // Space between the incognito badge and the right edge of the window.
...@@ -42,22 +62,7 @@ const CGFloat kLocBarLeftRightInset = 1; ...@@ -42,22 +62,7 @@ const CGFloat kLocBarLeftRightInset = 1;
const CGFloat kLocBarTopInset = 0; const CGFloat kLocBarTopInset = 0;
const CGFloat kLocBarBottomInset = 1; const CGFloat kLocBarBottomInset = 1;
} // end namespace } // namespace
// 10.7 adds public APIs for full-screen support. Provide the declaration so it
// can be called below when building with the 10.5 SDK.
#if !defined(MAC_OS_X_VERSION_10_7) || \
MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_7
@interface NSWindow (LionSDKDeclarations)
- (void)toggleFullScreen:(id)sender;
@end
enum {
NSWindowFullScreenButton = 7
};
#endif // MAC_OS_X_VERSION_10_7
@implementation BrowserWindowController(Private) @implementation BrowserWindowController(Private)
...@@ -538,4 +543,18 @@ willPositionSheet:(NSWindow*)sheet ...@@ -538,4 +543,18 @@ willPositionSheet:(NSWindow*)sheet
[fullscreenController_ cancelAnimationAndTimers]; [fullscreenController_ cancelAnimationAndTimers];
} }
- (void)setUpOSFullScreenButton {
NSWindow* window = [self window];
if ([window respondsToSelector:@selector(toggleFullScreen:)]) {
NSWindowCollectionBehavior behavior = [window collectionBehavior];
behavior |= NSWindowCollectionBehaviorFullScreenPrimary;
[window setCollectionBehavior:behavior];
NSButton* fullscreenButton =
[window standardWindowButton:NSWindowFullScreenButton];
[fullscreenButton setAction:@selector(enterFullscreen:)];
[fullscreenButton setTarget:self];
}
}
@end // @implementation BrowserWindowController(Private) @end // @implementation BrowserWindowController(Private)
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment