Full screen on a display other than the main display
Full screen on a display other than the main display
- Subject: Full screen on a display other than the main display
- From: Matias Piipari <email@hidden>
- Date: Mon, 26 Jan 2009 13:21:33 +0000
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 (email@hidden)
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:
This email sent to email@hidden