From 84c55c3e4e8e4c0d0180b40ceac747cbcba4fab8 Mon Sep 17 00:00:00 2001 From: Soren Jorvang Date: Fri, 4 Jun 2010 02:58:35 +0000 Subject: [PATCH] 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 --- SConstruct | 1 + Source/Core/DolphinWX/Src/MainNoGUI.cpp | 104 +---------------- Source/Core/DolphinWX/Src/SConscript | 2 - Source/Core/DolphinWX/Src/cocoaApp.h | 15 --- Source/Core/DolphinWX/Src/cocoaApp.m | 109 ------------------ Source/Plugins/Plugin_VideoOGL/Src/GLUtil.h | 3 + .../Plugins/Plugin_VideoSoftware/Src/GLUtil.h | 2 + 7 files changed, 7 insertions(+), 229 deletions(-) delete mode 100644 Source/Core/DolphinWX/Src/cocoaApp.h delete mode 100644 Source/Core/DolphinWX/Src/cocoaApp.m diff --git a/SConstruct b/SConstruct index 999add6e5f..db6a0306d6 100644 --- a/SConstruct +++ b/SConstruct @@ -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 diff --git a/Source/Core/DolphinWX/Src/MainNoGUI.cpp b/Source/Core/DolphinWX/Src/MainNoGUI.cpp index 66e976310f..32684d1d16 100644 --- a/Source/Core/DolphinWX/Src/MainNoGUI.cpp +++ b/Source/Core/DolphinWX/Src/MainNoGUI.cpp @@ -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 #endif + int main(int argc, char* argv[]) -#endif { gengetopt_args_info args_info; diff --git a/Source/Core/DolphinWX/Src/SConscript b/Source/Core/DolphinWX/Src/SConscript index c352f14f64..c002d3f681 100644 --- a/Source/Core/DolphinWX/Src/SConscript +++ b/Source/Core/DolphinWX/Src/SConscript @@ -56,8 +56,6 @@ if wxenv['HAVE_WX']: if sys.platform == 'darwin': - files += [ 'cocoaApp.m', ] - compileFlags = [ '-x', 'objective-c++', diff --git a/Source/Core/DolphinWX/Src/cocoaApp.h b/Source/Core/DolphinWX/Src/cocoaApp.h deleted file mode 100644 index 81e3d17704..0000000000 --- a/Source/Core/DolphinWX/Src/cocoaApp.h +++ /dev/null @@ -1,15 +0,0 @@ -#import - -#ifdef __cplusplus -extern "C" -{ -#endif - -bool cocoaSendEvent(NSEvent *event); - -void cocoaCreateApp(); - -#ifdef __cplusplus -} -#endif - diff --git a/Source/Core/DolphinWX/Src/cocoaApp.m b/Source/Core/DolphinWX/Src/cocoaApp.m deleted file mode 100644 index 5c5402cf89..0000000000 --- a/Source/Core/DolphinWX/Src/cocoaApp.m +++ /dev/null @@ -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; - -} - - diff --git a/Source/Plugins/Plugin_VideoOGL/Src/GLUtil.h b/Source/Plugins/Plugin_VideoOGL/Src/GLUtil.h index 12c53fe8e2..b75cf3ba84 100644 --- a/Source/Plugins/Plugin_VideoOGL/Src/GLUtil.h +++ b/Source/Plugins/Plugin_VideoOGL/Src/GLUtil.h @@ -48,6 +48,9 @@ #elif defined(USE_SDL) && USE_SDL #include #include + +#else +#include #endif // end USE_WX #if defined(__APPLE__) diff --git a/Source/Plugins/Plugin_VideoSoftware/Src/GLUtil.h b/Source/Plugins/Plugin_VideoSoftware/Src/GLUtil.h index c4a7434471..a69307cafb 100644 --- a/Source/Plugins/Plugin_VideoSoftware/Src/GLUtil.h +++ b/Source/Plugins/Plugin_VideoSoftware/Src/GLUtil.h @@ -50,6 +50,8 @@ #elif defined(USE_SDL) && USE_SDL #include #include +#else +#include #endif // end USE_WX #if defined(__APPLE__)