Closing the window quits the program. Fix focus issues.
This commit is contained in:
@@ -3,6 +3,7 @@
|
|||||||
#import "DisplayResolutions.h"
|
#import "DisplayResolutions.h"
|
||||||
#import "RageLog.h"
|
#import "RageLog.h"
|
||||||
#import "RageUtil.h"
|
#import "RageUtil.h"
|
||||||
|
#import "arch/ArchHooks/ArchHooks.h"
|
||||||
|
|
||||||
#import <Cocoa/Cocoa.h>
|
#import <Cocoa/Cocoa.h>
|
||||||
#import <OpenGl/OpenGl.h>
|
#import <OpenGl/OpenGl.h>
|
||||||
@@ -25,6 +26,32 @@ public:
|
|||||||
#define POOL1(x) POOL2(x)
|
#define POOL1(x) POOL2(x)
|
||||||
#define POOL POOL1(__LINE__)
|
#define POOL POOL1(__LINE__)
|
||||||
|
|
||||||
|
// Window delegate class
|
||||||
|
@interface SMWindowDelegate : NSObject
|
||||||
|
- (void) windowDidBecomeKey:(NSNotification *)aNotification;
|
||||||
|
- (void) windowDidResignKey:(NSNotification *)aNotification;
|
||||||
|
- (void) windowWillClose:(NSNotification *)aNotification;
|
||||||
|
// XXX maybe use whichever screen contains the window? Hard for me to test though.
|
||||||
|
//- (void) windowDidChangeScreen:(NSNotification *)aNotification;
|
||||||
|
@end
|
||||||
|
|
||||||
|
@implementation SMWindowDelegate
|
||||||
|
- (void) windowDidBecomeKey:(NSNotification *)aNotification
|
||||||
|
{
|
||||||
|
HOOKS->SetHasFocus( true );
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void) windowDidResignKey:(NSNotification *)aNotification
|
||||||
|
{
|
||||||
|
HOOKS->SetHasFocus( false );
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void) windowWillClose:(NSNotification *)aNotification
|
||||||
|
{
|
||||||
|
ArchHooks::SetUserQuit();
|
||||||
|
}
|
||||||
|
@end
|
||||||
|
|
||||||
static NSOpenGLPixelFormat *CreatePixelFormat( int bbp, bool windowed )
|
static NSOpenGLPixelFormat *CreatePixelFormat( int bbp, bool windowed )
|
||||||
{
|
{
|
||||||
NSOpenGLPixelFormatAttribute attrs[] = {
|
NSOpenGLPixelFormatAttribute attrs[] = {
|
||||||
@@ -48,8 +75,12 @@ LowLevelWindow_Cocoa::LowLevelWindow_Cocoa() : mView(nil), mFullScreenContext(ni
|
|||||||
styleMask:g_iStyleMask
|
styleMask:g_iStyleMask
|
||||||
backing:NSBackingStoreNonretained
|
backing:NSBackingStoreNonretained
|
||||||
defer:YES];
|
defer:YES];
|
||||||
|
ASSERT( mWindow != nil );
|
||||||
[mWindow setExcludedFromWindowsMenu:YES];
|
[mWindow setExcludedFromWindowsMenu:YES];
|
||||||
[mWindow useOptimizedDrawing:YES];
|
[mWindow useOptimizedDrawing:YES];
|
||||||
|
[mWindow setReleasedWhenClosed:NO];
|
||||||
|
// setDelegate: does not retain the delegate; however, we didn't (auto)release it.
|
||||||
|
[mWindow setDelegate:[[SMWindowDelegate alloc] init]];
|
||||||
mCurrentParams.windowed = true; // We are essentially windowed to begin with.
|
mCurrentParams.windowed = true; // We are essentially windowed to begin with.
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -57,21 +88,14 @@ LowLevelWindow_Cocoa::~LowLevelWindow_Cocoa()
|
|||||||
{
|
{
|
||||||
POOL;
|
POOL;
|
||||||
ShutDownFullScreen();
|
ShutDownFullScreen();
|
||||||
if( mWindow )
|
// We need to release the window's delegate now.
|
||||||
{
|
// Autorelease to prevent a race condition.
|
||||||
|
[[mWindow delegate] autorelease];
|
||||||
|
[mWindow setDelegate:nil];
|
||||||
[mWindow orderOut:nil];
|
[mWindow orderOut:nil];
|
||||||
[mWindow release];
|
[mWindow release];
|
||||||
}
|
|
||||||
if( mFullScreenContext )
|
|
||||||
{
|
|
||||||
if( !mCurrentParams.windowed )
|
|
||||||
{
|
|
||||||
[mFullScreenContext clearDrawable]; // Exit full screen.
|
|
||||||
CGReleaseAllDisplays();
|
|
||||||
}
|
|
||||||
[mFullScreenContext release];
|
[mFullScreenContext release];
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
void *LowLevelWindow_Cocoa::GetProcAddress( CString s )
|
void *LowLevelWindow_Cocoa::GetProcAddress( CString s )
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user