Fixed problem with fullscreen/windowed display mode. Added check for Cocoa window import.
git-svn-id: https://sfml.svn.sourceforge.net/svnroot/sfml/trunk@1094 4e206d99-4929-0410-ac5d-dfc041789085
This commit is contained in:
parent
60e14e75b7
commit
cb511644db
@ -44,6 +44,8 @@ static AppController *shared = nil;
|
|||||||
@end
|
@end
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#define ENABLE_FADE_OPERATIONS 1
|
||||||
|
|
||||||
@implementation NSApplication (SFML)
|
@implementation NSApplication (SFML)
|
||||||
|
|
||||||
- (void)setRunning:(BOOL)flag
|
- (void)setRunning:(BOOL)flag
|
||||||
@ -388,7 +390,7 @@ static AppController *shared = nil;
|
|||||||
- (void)setFullscreenWindow:(WindowWrapper *)aWrapper mode:(sf::VideoMode *)fullscreenMode
|
- (void)setFullscreenWindow:(WindowWrapper *)aWrapper mode:(sf::VideoMode *)fullscreenMode
|
||||||
{
|
{
|
||||||
// If we have a fullscreen window and want to remove it
|
// If we have a fullscreen window and want to remove it
|
||||||
if (myFullscreenWrapper && aWrapper == nil)
|
if (aWrapper == nil && myFullscreenWrapper)
|
||||||
{
|
{
|
||||||
// Get the CoreGraphics display mode according to the desktop mode
|
// Get the CoreGraphics display mode according to the desktop mode
|
||||||
CFDictionaryRef displayMode = CGDisplayBestModeForParameters (kCGDirectMainDisplay,
|
CFDictionaryRef displayMode = CGDisplayBestModeForParameters (kCGDirectMainDisplay,
|
||||||
@ -397,8 +399,10 @@ static AppController *shared = nil;
|
|||||||
myDesktopMode.Height,
|
myDesktopMode.Height,
|
||||||
NULL);
|
NULL);
|
||||||
|
|
||||||
|
#if ENABLE_FADE_OPERATIONS
|
||||||
// Fade to black screen
|
// Fade to black screen
|
||||||
[self doFadeOperation:FillScreen time:0.2f sync:true];
|
[self doFadeOperation:FillScreen time:0.2f sync:true];
|
||||||
|
#endif
|
||||||
|
|
||||||
// Switch to the desktop display mode
|
// Switch to the desktop display mode
|
||||||
CGDisplaySwitchToMode(kCGDirectMainDisplay, displayMode);
|
CGDisplaySwitchToMode(kCGDirectMainDisplay, displayMode);
|
||||||
@ -409,13 +413,15 @@ static AppController *shared = nil;
|
|||||||
// Show the menu bar
|
// Show the menu bar
|
||||||
[NSMenu setMenuBarVisible:YES];
|
[NSMenu setMenuBarVisible:YES];
|
||||||
|
|
||||||
|
#if ENABLE_FADE_OPERATIONS
|
||||||
// Fade to normal screen
|
// Fade to normal screen
|
||||||
[self doFadeOperation:CleanScreen time:0.5f sync:true];
|
[self doFadeOperation:CleanScreen time:0.5f sync:true];
|
||||||
|
#endif
|
||||||
|
|
||||||
// Release the saved window wrapper
|
// Release the saved window wrapper
|
||||||
[myFullscreenWrapper release], myFullscreenWrapper = nil;
|
myFullscreenWrapper = nil;
|
||||||
}
|
}
|
||||||
else if (myFullscreenWrapper == nil && aWrapper)
|
else if (aWrapper)
|
||||||
{
|
{
|
||||||
assert(fullscreenMode != NULL);
|
assert(fullscreenMode != NULL);
|
||||||
|
|
||||||
@ -426,24 +432,39 @@ static AppController *shared = nil;
|
|||||||
fullscreenMode->Height,
|
fullscreenMode->Height,
|
||||||
NULL);
|
NULL);
|
||||||
|
|
||||||
|
#if ENABLE_FADE_OPERATIONS
|
||||||
// Fade to a black screen
|
// Fade to a black screen
|
||||||
[self doFadeOperation:FillScreen time:0.5f sync:true];
|
[self doFadeOperation:FillScreen time:0.5f sync:true];
|
||||||
|
#endif
|
||||||
|
|
||||||
// Hide to the main menu bar
|
if (!myFullscreenWrapper)
|
||||||
|
{
|
||||||
|
// Hide the main menu bar
|
||||||
[NSMenu setMenuBarVisible:NO];
|
[NSMenu setMenuBarVisible:NO];
|
||||||
|
}
|
||||||
|
|
||||||
|
if (myPrevMode != *fullscreenMode)
|
||||||
|
{
|
||||||
// Switch to the wished display mode
|
// Switch to the wished display mode
|
||||||
CGDisplaySwitchToMode(kCGDirectMainDisplay, displayMode);
|
CGDisplaySwitchToMode(kCGDirectMainDisplay, displayMode);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (myFullscreenWrapper)
|
||||||
|
{
|
||||||
|
[[myFullscreenWrapper window] close];
|
||||||
|
}
|
||||||
|
|
||||||
// Open and center the window
|
// Open and center the window
|
||||||
[[aWrapper window] makeKeyAndOrderFront:nil];
|
[[aWrapper window] makeKeyAndOrderFront:nil];
|
||||||
[[aWrapper window] center];
|
[[aWrapper window] center];
|
||||||
|
|
||||||
|
#if ENABLE_FADE_OPERATIONS
|
||||||
// Fade to normal screen
|
// Fade to normal screen
|
||||||
[self doFadeOperation:CleanScreen time:0.2f sync:false];
|
[self doFadeOperation:CleanScreen time:0.2f sync:false];
|
||||||
|
#endif
|
||||||
|
|
||||||
// Save the fullscreen wrapper
|
// Save the fullscreen wrapper
|
||||||
myFullscreenWrapper = [aWrapper retain];
|
myFullscreenWrapper = aWrapper;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -502,10 +502,6 @@ static GLContext *sharedCtx = nil;
|
|||||||
NSRect frame = NSMakeRect (0.0f, 0.0f, (float) mode.Width, (float) mode.Height);
|
NSRect frame = NSMakeRect (0.0f, 0.0f, (float) mode.Width, (float) mode.Height);
|
||||||
unsigned int mask = 0;
|
unsigned int mask = 0;
|
||||||
|
|
||||||
// We grab options from WindowStyle and add them to our window mask
|
|
||||||
if (style & sf::Style::None || style & sf::Style::Fullscreen) {
|
|
||||||
mask |= NSBorderlessWindowMask;
|
|
||||||
|
|
||||||
if (style & sf::Style::Fullscreen) {
|
if (style & sf::Style::Fullscreen) {
|
||||||
myIsFullscreen = true;
|
myIsFullscreen = true;
|
||||||
|
|
||||||
@ -534,6 +530,12 @@ static GLContext *sharedCtx = nil;
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// We grab options from WindowStyle and add them to our window mask
|
||||||
|
if (style & sf::Style::None || style & sf::Style::Fullscreen) {
|
||||||
|
mask |= NSBorderlessWindowMask;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
if (style & sf::Style::Titlebar) {
|
if (style & sf::Style::Titlebar) {
|
||||||
mask |= NSTitledWindowMask;
|
mask |= NSTitledWindowMask;
|
||||||
@ -638,9 +640,8 @@ static GLContext *sharedCtx = nil;
|
|||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
- (void)dealloc
|
- (void)dealloc
|
||||||
{
|
{
|
||||||
|
|
||||||
// Remove the notification observer
|
// Remove the notification observer
|
||||||
if (myView)
|
|
||||||
[[NSNotificationCenter defaultCenter] removeObserver:myView];
|
|
||||||
[[NSNotificationCenter defaultCenter] removeObserver:self];
|
[[NSNotificationCenter defaultCenter] removeObserver:self];
|
||||||
|
|
||||||
// Close the window
|
// Close the window
|
||||||
|
@ -93,6 +93,14 @@ myWheelStatus(0.0f)
|
|||||||
{
|
{
|
||||||
if (Handle)
|
if (Handle)
|
||||||
{
|
{
|
||||||
|
if (![(NSWindow *)Handle isKindOfClass:[NSWindow class]])
|
||||||
|
std::cerr << "Cannot import this Window Handle because it is not a <NSWindow *> object"
|
||||||
|
<< "(or one of its subclasses). You gave a <"
|
||||||
|
<< [[(NSWindow *)Handle className] UTF8String]
|
||||||
|
<< "> object." << std::endl;
|
||||||
|
else
|
||||||
|
{
|
||||||
|
|
||||||
// We create the window according to the given handle
|
// We create the window according to the given handle
|
||||||
myWrapper = [[WindowWrapper alloc] initWithWindow:(NSWindow *)Handle
|
myWrapper = [[WindowWrapper alloc] initWithWindow:(NSWindow *)Handle
|
||||||
settings:params
|
settings:params
|
||||||
@ -111,6 +119,7 @@ myWheelStatus(0.0f)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
|
Loading…
x
Reference in New Issue
Block a user