Based on @Chuck's suggestion, I came up with a solution that works somewhat, but cannot be reliable.
The solution is based on the assumption that the new full-screen mode for windows 10.7 transfers these windows to a new screen space. Therefore, we subscribe to notifications of changes in the active space. In this notification handler, we check the list of windows to determine if the menu bar is enabled. If this is not the case, it probably means that we are in full-screen space.
Checking for the presence of the Menubar window is the best test I could find based on Chuck's idea. I donβt like it very much because it makes assumptions about the names and the presence of internal managed windows.
Here's the test code that goes into AppDelegate.m, which also includes a test for another full-screen mode in the application:
- (void)applicationDidFinishLaunching:(NSNotification *)aNotification { NSApplication *app = [NSApplication sharedApplication]; // Observe full screen mode from apps setting SystemUIMode // or invoking 'setPresentationOptions' [app addObserver:self forKeyPath:@"currentSystemPresentationOptions" options:NSKeyValueObservingOptionNew context:NULL]; // Observe full screen mode from apps using a separate space // (ie those providing the fullscreen widget at the right // of their window title bar). [[[NSWorkspace sharedWorkspace] notificationCenter] addObserverForName:NSWorkspaceActiveSpaceDidChangeNotification object:NULL queue:NULL usingBlock:^(NSNotification *note) { // The active space changed. // Now we need to detect if this is a fullscreen space. // Let look at the windows... NSArray *windows = CFBridgingRelease(CGWindowListCopyWindowInfo (kCGWindowListOptionOnScreenOnly, kCGNullWindowID)); //NSLog(@"active space change: %@", windows); // We detect full screen spaces by checking if there a menubar // in the window list. // If not, we assume it in fullscreen mode. BOOL hasMenubar = NO; for (NSDictionary *d in windows) { if ([d[@"kCGWindowOwnerName"] isEqualToString:@"Window Server"] && [d[@"kCGWindowName"] isEqualToString:@"Menubar"]) { hasMenubar = YES; break; } } NSLog(@"fullscreen: %@", hasMenubar ? @"No" : @"Yes"); } ]; } - (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context { if ([keyPath isEqual:@"currentSystemPresentationOptions"]) { NSLog(@"currentSystemPresentationOptions: %@", [change objectForKey:NSKeyValueChangeNewKey]); // a value of 4 indicates fullscreen mode } }
source share