From c8a9fd2bd4ae66dc256af8969d50806398150ec8 Mon Sep 17 00:00:00 2001 From: ehofman Date: Fri, 25 Jul 2008 08:39:28 +0000 Subject: [PATCH] Some Mac / __APPLE___ cleanups: - remove the OSX_BUNDLE crap *I* introduced years ago - we're always a a bun dle on Mac now. - fix up the default fg-root on Mac to be FlightGear.app/Contents/Resources/ data - i.e the location used by the macflightgear.org distro, and indeed the obv ious 'correct' location. Not sure why I didn't use that in the first place, back in the day. - remove the CPSForegroundEnable hack. For one thing, we're a bundle and don 't need it, and for another, osgViewer on Mac does the same logic using a newer, public API rather than a hack into the OS. - remove the strange logic for doing fgOSInit 'early' (in bootstrap rather t han main) when running from the command line on Mac; again this is obsolete, and no one seems to know why it was ever necessary. I guess it was an interaction w ith SDL when running without a bundle. - (not Mac related) remove obsolete code bracketed by ENABLE_PLIB_JOYSTICK a nd USE_GLIDE (neither of which are ever set, even from config.h that I can see) in main.cxx --- src/Main/bootstrap.cxx | 34 ---------------------------------- src/Main/fg_init.cxx | 20 ++++++++------------ src/Main/main.cxx | 23 ----------------------- 3 files changed, 8 insertions(+), 69 deletions(-) diff --git a/src/Main/bootstrap.cxx b/src/Main/bootstrap.cxx index 89354c8f3..f82b64143 100644 --- a/src/Main/bootstrap.cxx +++ b/src/Main/bootstrap.cxx @@ -88,25 +88,6 @@ handleFPE (int num) } #endif -#ifdef __APPLE__ - -typedef struct -{ - int lo; - int hi; -} PSN; - -extern "C" { - short CPSGetCurrentProcess(PSN *psn); - short CPSSetProcessName (PSN *psn, char *processname); - short CPSEnableForegroundOperation(PSN *psn, int _arg2, int _arg3, int _arg4, int _arg5); - short CPSSetFrontProcess(PSN *psn); -}; - -#define CPSEnableFG(psn) CPSEnableForegroundOperation(psn,0x03,0x3C,0x2C,0x1103) - -#endif - #ifdef _MSC_VER int main ( int argc, char **argv ); int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, @@ -194,21 +175,6 @@ int main ( int argc, char **argv ) { _control87(MCW_EM, MCW_EM); /* defined in float.h */ #endif - // Keyboard focus hack -#if defined(__APPLE__) && !defined(OSX_BUNDLE) - { - PSN psn; - - fgOSInit (&argc, argv); - _bootstrap_OSInit++; - - CPSGetCurrentProcess(&psn); - CPSSetProcessName(&psn, "FlightGear"); - CPSEnableFG(&psn); - CPSSetFrontProcess(&psn); - } -#endif - // FIXME: add other, more specific // exceptions. try { diff --git a/src/Main/fg_init.cxx b/src/Main/fg_init.cxx index be441417b..fdac2e800 100644 --- a/src/Main/fg_init.cxx +++ b/src/Main/fg_init.cxx @@ -270,25 +270,21 @@ bool fgInitFGRoot ( int argc, char **argv ) { root = "/FlightGear"; #elif defined( WIN32 ) root = "\\FlightGear"; -#elif defined(OSX_BUNDLE) - /* the following code looks for the base package directly inside - the application bundle. This can be changed fairly easily by - fiddling with the code below. And yes, I know it's ugly and verbose. +#elif defined(__APPLE__) + /* + The following code looks for the base package inside the application + bundle, in the standard Contents/Resources location. */ - CFBundleRef appBundle = CFBundleGetMainBundle(); - CFURLRef appUrl = CFBundleCopyBundleURL(appBundle); - CFRelease(appBundle); + CFURLRef resourcesUrl = CFBundleCopyResourcesDirectoryURL(CFBundleGetMainBundle()); - // look for a 'data' subdir directly inside the bundle : is there - // a better place? maybe in Resources? I don't know ... - CFURLRef dataDir = CFURLCreateCopyAppendingPathComponent(NULL, appUrl, CFSTR("data"), true); + // look for a 'data' subdir + CFURLRef dataDir = CFURLCreateCopyAppendingPathComponent(NULL, resourcesUrl, CFSTR("data"), true); // now convert down to a path, and the a c-string CFStringRef path = CFURLCopyFileSystemPath(dataDir, kCFURLPOSIXPathStyle); root = CFStringGetCStringPtr(path, CFStringGetSystemEncoding()); - // tidy up. - CFRelease(appBundle); + CFRelease(resourcesUrl); CFRelease(dataDir); CFRelease(path); #else diff --git a/src/Main/main.cxx b/src/Main/main.cxx index 90d96b4e3..ba2483da0 100644 --- a/src/Main/main.cxx +++ b/src/Main/main.cxx @@ -340,14 +340,6 @@ static void fgMainLoop( void ) { SG_LOG( SG_ALL, SG_DEBUG, "Running Main Loop"); SG_LOG( SG_ALL, SG_DEBUG, "======= ==== ===="); -#if defined( ENABLE_PLIB_JOYSTICK ) - // Read joystick and update control settings - // if ( fgGetString("/sim/control-mode") == "joystick" ) - // { - // fgJoystickRead(); - // } -#endif - // Fix elevation. I'm just sticking this here for now, it should // probably move eventually @@ -879,16 +871,6 @@ static void fgIdleFunction ( void ) { system ( command.c_str() ); } #endif - - // These are a few miscellaneous things that aren't really - // "subsystems" but still need to be initialized. - -#ifdef USE_GLIDE - if ( strstr ( general.get_glRenderer(), "Glide" ) ) { - grTexLodBiasValue ( GR_TMU0, 1.0 ) ; - } -#endif - // This is the top level init routine which calls all the // other subsystem initialization routines. If you are adding // a subsystem to flightgear, its initialization call should be @@ -1011,13 +993,8 @@ bool fgMainInit( int argc, char **argv ) { } // Initialize the Window/Graphics environment. -#if !defined(__APPLE__) || defined(OSX_BUNDLE) - // Mac OS X command line ("non-bundle") applications call this - // from main(), in bootstrap.cxx. Andy doesn't know why, someone - // feel free to add comments... fgOSInit(&argc, argv); _bootstrap_OSInit++; -#endif fgRegisterWindowResizeHandler( &FGRenderer::resize ); fgRegisterIdleHandler( &fgIdleFunction );