Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Switch to Cocoa APIs for fullscreen.

BUG=170189
TEST=no change


Review URL: https://chromiumcodereview.appspot.com/12052012

git-svn-id: http://src.chromium.org/svn/trunk/src/chrome/browser@178470 4ff67af0-8c30-449e-8e8b-ad334ec8d88c
  • Loading branch information...
commit 63a1f22f4e5459ecbe11c246d1d0713dcb02b5d4 1 parent 5363e29
avi@chromium.org authored
View
7 fullscreen.h
@@ -7,13 +7,6 @@
#include "build/build_config.h"
-// For MacOSX, InitFullScreenMonitor needs to be called first to setup the
-// monitor. StopFullScreenMonitor should be called if it is not needed any more.
-#if defined(OS_MACOSX)
-void InitFullScreenMonitor();
-void StopFullScreenMonitor();
-#endif
-
bool IsFullScreenMode();
#endif // CHROME_BROWSER_FULLSCREEN_H_
View
104 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(&currentMode, 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;
}
View
2  notifications/notification_ui_manager_impl.cc
@@ -51,7 +51,6 @@ NotificationUIManagerImpl::NotificationUIManagerImpl()
registrar_.Add(this, chrome::NOTIFICATION_APP_TERMINATING,
content::NotificationService::AllSources());
#if defined(OS_MACOSX)
- InitFullScreenMonitor();
InitIdleMonitor();
#endif
}
@@ -60,7 +59,6 @@ NotificationUIManagerImpl::~NotificationUIManagerImpl() {
STLDeleteElements(&show_queue_);
#if defined(OS_MACOSX)
StopIdleMonitor();
- StopFullScreenMonitor();
#endif
}
Please sign in to comment.
Something went wrong with that request. Please try again.