Deprecate nowx on OS X (but keep it building for sanity checking).

git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@5598 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
Soren Jorvang 2010-06-04 02:58:35 +00:00
parent ad82320107
commit 84c55c3e4e
7 changed files with 7 additions and 229 deletions

View File

@ -381,6 +381,7 @@ if env['USE_WX']:
# gui-less build
if env['nowx']:
env['HAVE_WX'] = 0;
env['USE_WX'] = 0;
else:
if sys.platform == 'darwin':
# 2.9 is needed for 64-bit support on OS X

View File

@ -32,10 +32,6 @@
#include "X11Utils.h"
#endif
#ifdef __APPLE__
#import "cocoaApp.h"
#endif
#include "Core.h"
#include "Globals.h"
#include "Host.h"
@ -259,110 +255,12 @@ void X11_MainLoop()
}
#endif
//for cocoa we need to hijack the main to get event
#ifdef __APPLE__
@interface CocoaThread : NSObject
{
NSThread *Thread;
}
- (void)cocoaThreadStart;
- (void)cocoaThreadRun:(id)sender;
- (void)cocoaThreadQuit:(NSNotification*)note;
- (bool)cocoaThreadRunning;
@end
static NSString *CocoaThreadHaveFinish = @"CocoaThreadHaveFinish";
int cocoaArgc;
char **cocoaArgv;
int appleMain(int argc, char *argv[]);
@implementation CocoaThread
- (void)cocoaThreadStart
{
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(cocoaThreadQuit:) name:CocoaThreadHaveFinish object:nil];
[NSThread detachNewThreadSelector:@selector(cocoaThreadRun:) toTarget:self withObject:nil];
}
- (void)cocoaThreadRun:(id)sender
{
NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
Thread = [NSThread currentThread];
//launch main
appleMain(cocoaArgc,cocoaArgv);
[[NSNotificationCenter defaultCenter] postNotificationName:CocoaThreadHaveFinish object:nil];
[pool release];
}
- (void)cocoaThreadQuit:(NSNotification*)note
{
[[NSNotificationCenter defaultCenter] removeObserver:self];
}
- (bool)cocoaThreadRunning
{
if([Thread isFinished])
return false;
else
return true;
}
@end
int main(int argc, char *argv[])
{
cocoaArgc = argc;
cocoaArgv = argv;
cocoaCreateApp();
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
CocoaThread *thread = [[CocoaThread alloc] init];
NSEvent *event = [[NSEvent alloc] init];
[thread cocoaThreadStart];
//cocoa event loop
while(1)
{
event = [NSApp nextEventMatchingMask:NSAnyEventMask untilDate:[NSDate distantPast] inMode:NSDefaultRunLoopMode dequeue:YES ];
if(cocoaSendEvent(event))
{
Core::Stop();
break;
}
if(![thread cocoaThreadRunning])
break;
}
[event release];
[thread release];
[pool release];
}
int appleMain(int argc, char *argv[])
#else
// Include SDL header so it can hijack main().
#if defined(USE_SDL) && USE_SDL
#include <SDL.h>
#endif
int main(int argc, char* argv[])
#endif
{
gengetopt_args_info args_info;

View File

@ -56,8 +56,6 @@ if wxenv['HAVE_WX']:
if sys.platform == 'darwin':
files += [ 'cocoaApp.m', ]
compileFlags = [
'-x',
'objective-c++',

View File

@ -1,15 +0,0 @@
#import <Cocoa/Cocoa.h>
#ifdef __cplusplus
extern "C"
{
#endif
bool cocoaSendEvent(NSEvent *event);
void cocoaCreateApp();
#ifdef __cplusplus
}
#endif

View File

@ -1,109 +0,0 @@
#import "cocoaApp.h"
@implementation NSApplication(i)
- (void)appRunning
{
_running = 1;
}
@end
@interface cocoaAppDelegate : NSObject
- (NSApplicationTerminateReply)applicationShouldTerminate:(NSApplication *)sender;
@end
@implementation cocoaAppDelegate : NSObject
- (NSApplicationTerminateReply)applicationShouldTerminate:(NSApplication *)sender
{
return NSTerminateCancel;
}
@end
void cocoaCreateApp()
{
ProcessSerialNumber psn;
NSAutoreleasePool *pool;
if (!GetCurrentProcess(&psn)) {
TransformProcessType(&psn, kProcessTransformToForegroundApplication);
SetFrontProcess(&psn);
}
pool = [[NSAutoreleasePool alloc] init];
if (NSApp == nil) {
[NSApplication sharedApplication];
//TODO : Create menu
[NSApp finishLaunching];
}
if ([NSApp delegate] == nil) {
[NSApp setDelegate:[[cocoaAppDelegate alloc] init]];
}
[NSApp appRunning];
[pool release];
}
bool cocoaKeyCode(NSEvent *event)
{
static bool CMDDown = false, QDown = false;
bool Return = false;
NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
NSConnection *connec = [[NSConnection new] autorelease];
[connec setRootObject: event];
if ([connec registerName: @"DolphinCocoaEvent"] == NO)
{
//printf("error creating nsconnection\n");
}
if( [event type] != NSFlagsChanged )
{
const char *Keys = [[event characters] UTF8String];
if( Keys[0] == 'q' && [event type] == NSKeyDown )
QDown = true;
if( Keys[0] == 'q' && [event type] == NSKeyUp )
QDown = false;
}
else
if( [event modifierFlags] & NSCommandKeyMask )
CMDDown = true;
else
CMDDown = false;
if( QDown && CMDDown )
Return = true;
[pool release];
return Return;
}
bool cocoaSendEvent(NSEvent *event)
{
NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
if ( event != nil ) {
switch ([event type]) {
case NSKeyDown:
case NSKeyUp:
case NSFlagsChanged: // For Command
return cocoaKeyCode(event);
break;
default:
[NSApp sendEvent:event];
break;
}
}
[pool release];
return false;
}

View File

@ -48,6 +48,9 @@
#elif defined(USE_SDL) && USE_SDL
#include <GL/glew.h>
#include <SDL.h>
#else
#include <GL/glew.h>
#endif // end USE_WX
#if defined(__APPLE__)

View File

@ -50,6 +50,8 @@
#elif defined(USE_SDL) && USE_SDL
#include <GL/glew.h>
#include <SDL.h>
#else
#include <GL/glew.h>
#endif // end USE_WX
#if defined(__APPLE__)