| Index: chrome/browser/fullscreen_mac.mm
|
| diff --git a/chrome/browser/fullscreen_mac.mm b/chrome/browser/fullscreen_mac.mm
|
| index 303f6f240779a48d8d8e7e004bebe0a158df79af..d40ce0a4fb2e677741402bf945897e1794f0db76 100644
|
| --- a/chrome/browser/fullscreen_mac.mm
|
| +++ b/chrome/browser/fullscreen_mac.mm
|
| @@ -4,97 +4,39 @@
|
|
|
| #import "chrome/browser/fullscreen.h"
|
|
|
| -#import <Carbon/Carbon.h>
|
| #import <Cocoa/Cocoa.h>
|
|
|
| -#import "base/logging.h"
|
| +// Replicate specific 10.7 SDK declarations for building with prior SDKs.
|
| +#if !defined(MAC_OS_X_VERSION_10_7) || \
|
| + MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_7
|
|
|
| -@interface FullScreenMonitor : NSObject {
|
| - @private
|
| - BOOL fullScreen_;
|
| - EventHandlerRef eventHandler_;
|
| -}
|
| -
|
| -@property (nonatomic, getter=isFullScreen) BOOL fullScreen;
|
| -
|
| -@end
|
| -
|
| -static OSStatus handleAppEvent(EventHandlerCallRef myHandler,
|
| - EventRef event,
|
| - void* userData) {
|
| - DCHECK(userData);
|
| -
|
| - FullScreenMonitor* fullScreenMonitor =
|
| - reinterpret_cast<FullScreenMonitor*>(userData);
|
| -
|
| - UInt32 mode = 0;
|
| - OSStatus status = GetEventParameter(event,
|
| - kEventParamSystemUIMode,
|
| - typeUInt32,
|
| - NULL,
|
| - sizeof(UInt32),
|
| - NULL,
|
| - &mode);
|
| - if (status != noErr)
|
| - return status;
|
| - BOOL isFullScreenMode = mode == kUIModeAllHidden;
|
| - [fullScreenMonitor setFullScreen:isFullScreenMode];
|
| - return noErr;
|
| -}
|
| -
|
| -@implementation FullScreenMonitor
|
| -
|
| -@synthesize fullScreen = fullScreen_;
|
| -
|
| -- (id)init {
|
| - if ((self = [super init])) {
|
| - // Check if the user is in presentation mode initially.
|
| - SystemUIMode currentMode;
|
| - GetSystemUIMode(¤tMode, NULL);
|
| - fullScreen_ = currentMode == kUIModeAllHidden;
|
| +enum {
|
| + NSApplicationPresentationFullScreen = 1 << 10
|
| +};
|
|
|
| - // Register a Carbon event to receive the notification about the login
|
| - // session's UI mode change.
|
| - EventTypeSpec events[] =
|
| - {{ kEventClassApplication, kEventAppSystemUIModeChanged }};
|
| - OSStatus status = InstallApplicationEventHandler(
|
| - NewEventHandlerUPP(handleAppEvent),
|
| - GetEventTypeCount(events),
|
| - events,
|
| - self,
|
| - &eventHandler_);
|
| - if (status) {
|
| - [self release];
|
| - self = nil;
|
| - }
|
| - }
|
| - return self;
|
| -}
|
| +#endif // MAC_OS_X_VERSION_10_7
|
|
|
| -- (void)dealloc {
|
| - if (eventHandler_)
|
| - RemoveEventHandler(eventHandler_);
|
| - [super dealloc];
|
| -}
|
| +bool IsFullScreenMode() {
|
| + // Check if the main display has been captured (by games in particular).
|
| + if (CGDisplayIsCaptured(CGMainDisplayID()))
|
| + return true;
|
|
|
| -@end
|
| + NSApplicationPresentationOptions options =
|
| + [NSApp currentSystemPresentationOptions];
|
|
|
| -static FullScreenMonitor* g_fullScreenMonitor = nil;
|
| + bool dock_hidden = (options & NSApplicationPresentationHideDock) ||
|
| + (options & NSApplicationPresentationAutoHideDock);
|
|
|
| -void InitFullScreenMonitor() {
|
| - if (!g_fullScreenMonitor)
|
| - g_fullScreenMonitor = [[FullScreenMonitor alloc] init];
|
| -}
|
| + bool menu_hidden = (options & NSApplicationPresentationHideMenuBar) ||
|
| + (options & NSApplicationPresentationAutoHideMenuBar);
|
|
|
| -void StopFullScreenMonitor() {
|
| - [g_fullScreenMonitor release];
|
| - g_fullScreenMonitor = nil;
|
| -}
|
| + // If both dock and menu bar are hidden, that is the equivalent of the Carbon
|
| + // SystemUIMode (or Info.plist's LSUIPresentationMode) kUIModeAllHidden.
|
| + if (dock_hidden && menu_hidden)
|
| + return true;
|
|
|
| -bool IsFullScreenMode() {
|
| - // Check if the main display has been captured (game in particular).
|
| - if (CGDisplayIsCaptured(CGMainDisplayID()))
|
| + if (options & NSApplicationPresentationFullScreen)
|
| return true;
|
|
|
| - return [g_fullScreenMonitor isFullScreen];
|
| + return false;
|
| }
|
|
|