Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(6973)

Unified Diff: chrome/browser/fullscreen_mac.mm

Issue 6359008: Do not show notifications when in fullscreen or screensaver mode.... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 9 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/browser/fullscreen_mac.mm
===================================================================
--- chrome/browser/fullscreen_mac.mm (revision 0)
+++ chrome/browser/fullscreen_mac.mm (revision 0)
@@ -0,0 +1,107 @@
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#import "chrome/browser/fullscreen.h"
+
+#import "base/logging.h"
dmac 2011/01/21 19:34:44 base/logging should be under system imports.
jianli 2011/01/21 20:21:00 Done.
+#import <Carbon/Carbon.h>
+#import <Cocoa/Cocoa.h>
+
+@interface FullScreenMonitor : NSObject {
+ @private
+ BOOL isFullScreen_;
+ EventHandlerRef eventHandler_;
+}
+
+- (BOOL) isFullScreen;
dmac 2011/01/21 19:34:44 no space between ) and i (same on line below)
jianli 2011/01/21 20:21:00 Done.
+- (void) setIsFullScreen:(BOOL)newIsFullScreen;
dmac 2011/01/21 19:34:44 cocoa naming would be isFullScreen and setFullScre
jianli 2011/01/21 20:21:00 Done.
+
+@end
+
+static OSStatus handleAppEvent(EventHandlerCallRef myHandler,
+ EventRef event,
+ void* userData) {
+ DCHECK(userData);
+
+ FullScreenMonitor* fullScreenMonitor =
+ reinterpret_cast<FullScreenMonitor*>(userData);
+
+ UInt32 mode = 0;
+ (void) GetEventParameter(event,
+ kEventParamSystemUIMode,
+ typeUInt32,
+ /*outActualType*/ NULL,
dmac 2011/01/21 19:34:44 get rid of /*value*/ and do you want to check for
jianli 2011/01/21 20:21:00 Done.
+ sizeof(UInt32),
+ /*outActualSize*/ NULL,
+ &mode);
+ BOOL isFullScreenMode = mode == kUIModeAllHidden;
+ [fullScreenMonitor setIsFullScreen:isFullScreenMode];
+ return noErr;
+}
+
+@implementation FullScreenMonitor
+
+- (id)init {
+ if ((self = [super init])) {
+ // Check if the user is in presentation mode initially. We do this by
dmac 2011/01/21 19:34:44 When this is initialized, do we expect Chrome to b
jianli 2011/01/21 20:21:00 No. InitFullScreenMonitor is called when Notificat
+ // checking if the menu bar is visible.
+ NSArray* screens = [NSScreen screens];
+ if ([screens count] > 0) {
+ NSScreen* screen = [screens objectAtIndex:0];
+ NSRect fullBounds = [screen frame];
+ NSRect workBounds = [screen visibleFrame];
+ if (NSMaxY(fullBounds) == NSMaxY(workBounds))
+ isFullScreen_ = YES;
+ }
+
+ // Register a Carbon event to receive the notification about the login
+ // session's UI mode change.
+ EventTypeSpec events[] =
+ {{ kEventClassApplication, kEventAppSystemUIModeChanged }};
+ OSStatus res = InstallApplicationEventHandler(
+ NewEventHandlerUPP(handleAppEvent),
+ GetEventTypeCount(events),
+ events,
+ self,
+ &eventHandler_);
+ DCHECK(res == noErr);
+ (void) res; // Work around unused variable warning.
+ }
+ return self;
+}
+
+- (void)dealloc {
+ if (eventHandler_)
+ RemoveEventHandler(eventHandler_);
+ [super dealloc];
+}
+
+- (BOOL)isFullScreen {
+ return isFullScreen_;
+}
+
+- (void)setIsFullScreen:(BOOL)newIsFullScreen {
+ isFullScreen_ = newIsFullScreen;
+}
+
+@end
+
+FullScreenMonitor* g_fullScreenMonitor = nil;
+
+void InitFullScreenMonitor() {
+ if (!g_fullScreenMonitor)
+ g_fullScreenMonitor = [[FullScreenMonitor alloc] init];
+}
+
+void StopFullScreenMonitor() {
+ g_fullScreenMonitor = nil;
dmac 2011/01/21 19:34:44 [g_fullScreenMonitor release]; ?
jianli 2011/01/21 20:21:00 Done.
+}
+
+bool IsFullScreenMode() {
+ // Check if the main display has been captured (game in particular).
+ if (CGDisplayIsCaptured(CGMainDisplayID()))
+ return true;
+
+ return [g_fullScreenMonitor isFullScreen];
+}
Property changes on: chrome\browser\fullscreen_mac.mm
___________________________________________________________________
Added: svn:eol-style
+ LF

Powered by Google App Engine
This is Rietveld 408576698