I tried making my application work in full screen with the method I've
attached below. This however only works correctly on the main display -- if
I try triggering this when the main window is any other screen I get just
black on that screen. What am I doing wrong?

- (IBAction) toggleFullScreenMode:(id) sender {
    if (fullScreenMainWindow != nil) {
        [self goAwayFromFullScreenMode: self];
        return;
    }

    mainWindowBeforeGoingFullScreen = [[NSApplication sharedApplication]
mainWindow];
    mainWindowBeforeGoingFullScreenRect =
mainWindowBeforeGoingFullScreen.frame;
    mainWindowBeforeGoingFullScreenView =
mainWindowBeforeGoingFullScreen.contentView;

    // Capture the screen that contains the window
    displayID = [[[mainWindowBeforeGoingFullScreen.screen deviceDescription]
objectForKey:@"NSScreenNumber"] intValue];

    if (CGDisplayCapture(displayID) != kCGErrorSuccess) {
        NSLog(@"WARNING!  could not capture the display!");
        // Note: you'll probably want to display a proper error dialog here
    }
    // Get the shielding window level
    int windowLevel = CGShieldingWindowLevel();

    // Get the screen rect of our main display
    NSRect screenRect = mainWindowBeforeGoingFullScreen.screen.frame;

    // Put up a new window
    fullScreenMainWindow = [[NSWindow alloc] initWithContentRect: screenRect
                                                       styleMask:
NSBorderlessWindowMask
                                                         backing:
NSBackingStoreBuffered
                                                           defer: NO
                                                          screen:
mainWindowBeforeGoingFullScreen.screen];
    [fullScreenMainWindow setLevel:windowLevel];
    [fullScreenMainWindow makeKeyAndOrderFront:nil];

    [mainWindowBeforeGoingFullScreen setFrame:screenRect display:YES];
    [fullScreenMainWindow
setContentView:mainWindowBeforeGoingFullScreen.contentView];
}
_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to