diff --git a/extras/audio plugins/wrapper/juce_PluginHostType.h b/extras/audio plugins/wrapper/juce_PluginHostType.h index 11fca45d04..8e712801b2 100644 --- a/extras/audio plugins/wrapper/juce_PluginHostType.h +++ b/extras/audio plugins/wrapper/juce_PluginHostType.h @@ -23,9 +23,6 @@ ============================================================================== */ -#if JUCE_MAC - #include -#endif //============================================================================== class PluginHostType @@ -103,7 +100,7 @@ public: private: static HostType getHostType() throw() { - const String hostPath (getHostPath()); + const String hostPath (File::getSpecialLocation (File::hostApplicationPath).getFullPath()); const String hostFilename (File (hostPath).getFileName()); #if JUCE_MAC @@ -144,25 +141,4 @@ private: #endif return UnknownHost; } - - static const String getHostPath() throw() - { - unsigned int size = 8192; - HeapBlock buffer; - buffer.calloc (size + 8); - -#if JUCE_WINDOWS - WCHAR* w = reinterpret_cast (buffer.getData()); - GetModuleFileNameW (0, w, size / sizeof (WCHAR)); - return String (w, size); -#elif JUCE_MAC - _NSGetExecutablePath (buffer.getData(), &size); - return String::fromUTF8 (buffer, size); -#elif JUCE_LINUX - readlink ("/proc/self/exe", buffer.getData(), size); - return String::fromUTF8 (buffer, size); -#else - #error -#endif - } }; diff --git a/juce_amalgamated.cpp b/juce_amalgamated.cpp index 7a3043d3b3..a5cabf0d15 100644 --- a/juce_amalgamated.cpp +++ b/juce_amalgamated.cpp @@ -864,6 +864,7 @@ protected: #include #include #include +#include #if MACOS_10_4_OR_EARLIER #include @@ -17282,7 +17283,7 @@ JUCEApplication::JUCEApplication() : appReturnValue (0), stillInitialising (true) { - jassert (isStandaloneApp && appInstance == 0); + jassert (isStandaloneApp() && appInstance == 0); appInstance = this; } @@ -17298,7 +17299,7 @@ JUCEApplication::~JUCEApplication() appInstance = 0; } -bool JUCEApplication::isStandaloneApp = false; +JUCEApplication::CreateInstanceFunction JUCEApplication::createInstance = 0; JUCEApplication* JUCEApplication::appInstance = 0; bool JUCEApplication::moreThanOneInstanceAllowed() @@ -17432,9 +17433,12 @@ int JUCEApplication::shutdownApp() return getApplicationReturnValue(); } -int JUCEApplication::main (const String& commandLine, JUCEApplication* const app) +int JUCEApplication::main (const String& commandLine) { - const ScopedPointer appDeleter (app); + ScopedJuceInitialiser_GUI libraryInitialiser; + + jassert (createInstance != 0); + const ScopedPointer app (createInstance()); if (! app->initialiseApp (commandLine)) return 0; @@ -17457,23 +17461,23 @@ int JUCEApplication::main (const String& commandLine, JUCEApplication* const app extern const char* juce_Argv0; #endif -int JUCEApplication::main (int argc, const char* argv[], JUCEApplication* const newApp) +int JUCEApplication::main (int argc, const char* argv[]) { JUCE_AUTORELEASEPOOL #if ! JUCE_WINDOWS + jassert (createInstance != 0); juce_Argv0 = argv[0]; #endif #if JUCE_IOS - const ScopedPointer appDeleter (newApp); return juce_iOSMain (argc, argv); #else String cmd; for (int i = 1; i < argc; ++i) cmd << argv[i] << ' '; - return JUCEApplication::main (cmd, newApp); + return JUCEApplication::main (cmd); #endif } @@ -70687,7 +70691,7 @@ public: Component* current = getComponentUnderMouse(); if (current != 0) Desktop::setMousePosition (current->getScreenBounds() - .getConstrainedPoint (current->getMouseXYRelative())); + .getConstrainedPoint (lastScreenPos)); } isUnboundedMouseModeOn = enable; @@ -75812,7 +75816,7 @@ AlertWindow::AlertWindow (const String& title, } } - if (! JUCEApplication::isStandaloneApp) + if (! JUCEApplication::isStandaloneApp()) setAlwaysOnTop (true); // for a plugin, make it always-on-top because the host windows are often top-level lookAndFeelChanged(); @@ -77174,7 +77178,7 @@ public: TempDialogWindow (const String& title, const Colour& colour, const bool escapeCloses) : DialogWindow (title, colour, escapeCloses, true) { - if (! JUCEApplication::isStandaloneApp) + if (! JUCEApplication::isStandaloneApp()) setAlwaysOnTop (true); // for a plugin, make it always-on-top because the host windows are often top-level } @@ -84776,7 +84780,10 @@ public: { const float fontHeight = font.getHeight(); const AffineTransform transform (AffineTransform::scale (fontHeight * font.getHorizontalScale(), fontHeight) - .translated (0.0f, -0.5f)); +#if JUCE_MAC || JUCE_IOS + .translated (0.0f, -0.5f) +#endif + ); edgeTable = new EdgeTable (glyphPath.getBoundsTransformed (transform).getSmallestIntegerContainer().expanded (1, 0), glyphPath, transform); @@ -237878,7 +237885,14 @@ const File JUCE_CALLTYPE File::getSpecialLocation (const SpecialLocationType typ GetModuleFileName (moduleHandle, dest, numElementsInArray (dest)); return File (String (dest)); } - break; + + case hostApplicationPath: + { + WCHAR dest [MAX_PATH + 256]; + dest[0] = 0; + GetModuleFileName (0, dest, numElementsInArray (dest)); + return File (String (dest)); + } default: jassertfalse; // unknown type? @@ -253551,6 +253565,16 @@ const File File::getSpecialLocation (const SpecialLocationType type) case currentApplicationFile: return juce_getExecutableFile(); + case hostApplicationPath: + { + unsigned int size = 8192; + HeapBlock buffer; + buffer.calloc (size + 8); + + readlink ("/proc/self/exe", buffer.getData(), size); + return String::fromUTF8 (buffer, size); + } + default: jassertfalse; // unknown type? break; @@ -255205,7 +255229,7 @@ namespace LinuxErrorHandling { DBG ("ERROR: connection to X server broken.. terminating."); - if (JUCEApplication::isStandaloneApp) + if (JUCEApplication::isStandaloneApp()) MessageManager::getInstance()->stopDispatchLoop(); errorOccurred = true; @@ -255272,7 +255296,7 @@ void MessageManager::doPlatformSpecificInitialisation() // This is fatal! Print error and closedown Logger::outputDebugString ("Failed to initialise xlib thread support."); - if (JUCEApplication::isStandaloneApp) + if (JUCEApplication::isStandaloneApp()) Process::terminate(); return; @@ -255374,7 +255398,7 @@ bool juce_dispatchNextMessageOnSystemQueue (bool returnIfNoPendingMessages) { LinuxErrorHandling::errorOccurred = true; - if (JUCEApplication::isStandaloneApp) + if (JUCEApplication::isStandaloneApp()) Process::terminate(); break; @@ -261867,13 +261891,25 @@ const String SystemStats::getOperatingSystemName() return "Mac OS X"; } +#if ! JUCE_IOS +int PlatformUtilities::getOSXMinorVersionNumber() +{ + SInt32 versionMinor = 0; + OSErr err = Gestalt (gestaltSystemVersionMinor, &versionMinor); + (void) err; + jassert (err == noErr); + return (int) versionMinor; +} +#endif + bool SystemStats::isOperatingSystem64Bit() { -#if JUCE_64BIT +#if JUCE_IOS + return false; +#elif JUCE_64BIT return true; #else - //xxx not sure how to find this out?.. - return false; + return PlatformUtilities::getOSXMinorVersionNumber() >= 6; #endif } @@ -263440,6 +263476,16 @@ const File File::getSpecialLocation (const SpecialLocationType type) : exe; } + case hostApplicationPath: + { + unsigned int size = 8192; + HeapBlock buffer; + buffer.calloc (size + 8); + + _NSGetExecutablePath (buffer.getData(), &size); + return String::fromUTF8 (buffer, size); + } + default: jassertfalse; // unknown type? break; @@ -263736,17 +263782,17 @@ END_JUCE_NAMESPACE - (void) applicationDidFinishLaunching: (UIApplication*) application { - String dummy; + initialiseJuce_GUI(); - if (! JUCEApplication::getInstance()->initialiseApp (dummy)) + if (! JUCEApplication::createInstance()->initialiseApp (String::empty)) exit (0); } - (void) applicationWillTerminate: (UIApplication*) application { + jassert (JUCEApplication::getInstance() != 0); JUCEApplication::getInstance()->shutdownApp(); - // need to do this stuff because the OS kills the process before our scope-based cleanup code gets executed.. delete JUCEApplication::getInstance(); shutdownJuce_GUI(); } @@ -263920,15 +263966,6 @@ void PlatformUtilities::addItemToDock (const File& file) } } -int PlatformUtilities::getOSXMinorVersionNumber() -{ - SInt32 versionMinor = 0; - OSErr err = Gestalt (gestaltSystemVersionMinor, &versionMinor); - (void) err; - jassert (err == noErr); - return (int) versionMinor; -} - #if ! JUCE_ONLY_BUILD_CORE_LIBRARY bool AlertWindow::showNativeDialogBox (const String& title, @@ -266346,6 +266383,7 @@ void MessageManager::runDispatchLoop() void MessageManager::stopDispatchLoop() { + [[[UIApplication sharedApplication] delegate] applicationWillTerminate: [UIApplication sharedApplication]]; exit (0); // iPhone apps get no mercy.. } @@ -266925,7 +266963,7 @@ void OpenGLPixelFormat::getAvailablePixelFormats (Component* /*component*/, p = aglNextPixelFormat (p); }*/ - //jassertfalse //xxx can't see how you do this in cocoa! + //jassertfalse // can't see how you do this in cocoa! } #else @@ -270311,7 +270349,7 @@ END_JUCE_NAMESPACE - (void) mouseDown: (NSEvent*) ev { - if (JUCEApplication::isStandaloneApp) + if (JUCEApplication::isStandaloneApp()) [self asyncMouseDown: ev]; else // In some host situations, the host will stop modal loops from working @@ -270330,7 +270368,7 @@ END_JUCE_NAMESPACE - (void) mouseUp: (NSEvent*) ev { - if (! JUCEApplication::isStandaloneApp) + if (! JUCEApplication::isStandaloneApp()) [self asyncMouseUp: ev]; else // In some host situations, the host will stop modal loops from working @@ -272505,7 +272543,7 @@ void OpenGLPixelFormat::getAvailablePixelFormats (Component* /*component*/, p = aglNextPixelFormat (p); }*/ - //jassertfalse //xxx can't see how you do this in cocoa! + //jassertfalse // can't see how you do this in cocoa! } #else @@ -273186,7 +273224,7 @@ static NSMenu* createStandardAppMenu (NSMenu* menu, const String& appName, static void rebuildMainMenu (const PopupMenu* extraItems) { // this can't be used in a plugin! - jassert (JUCEApplication::isStandaloneApp); + jassert (JUCEApplication::isStandaloneApp()); if (JUCEApplication::getInstance() != 0) { @@ -274663,7 +274701,7 @@ using namespace JUCE_NAMESPACE; NSNotificationCenter* center = [NSNotificationCenter defaultCenter]; - if (JUCEApplication::isStandaloneApp) + if (JUCEApplication::isStandaloneApp()) { oldDelegate = [NSApp delegate]; [NSApp setDelegate: self]; diff --git a/juce_amalgamated.h b/juce_amalgamated.h index 22301f0d8a..4e146b0e38 100644 --- a/juce_amalgamated.h +++ b/juce_amalgamated.h @@ -64,7 +64,7 @@ */ #define JUCE_MAJOR_VERSION 1 #define JUCE_MINOR_VERSION 52 -#define JUCE_BUILDNUMBER 43 +#define JUCE_BUILDNUMBER 44 /** Current Juce version number. @@ -9039,6 +9039,9 @@ public: */ invokedExecutableFile, + /** In a plugin, this will return the path of the host executable. */ + hostApplicationPath, + /** The directory in which applications normally get installed. So on windows, this would be something like "c:\program files", on the @@ -13740,39 +13743,39 @@ public: #if defined (JUCE_GCC) || defined (__MWERKS__) #define START_JUCE_APPLICATION(AppClass) \ + static JUCE_NAMESPACE::JUCEApplication* juce_CreateApplication() { return new AppClass(); } \ int main (int argc, char* argv[]) \ { \ - JUCE_NAMESPACE::JUCEApplication::isStandaloneApp = true; \ - JUCE_NAMESPACE::ScopedJuceInitialiser_GUI libraryInitialiser; \ - return JUCE_NAMESPACE::JUCEApplication::main (argc, (const char**) argv, new AppClass()); \ + JUCE_NAMESPACE::JUCEApplication::createInstance = &juce_CreateApplication; \ + return JUCE_NAMESPACE::JUCEApplication::main (argc, (const char**) argv); \ } #elif JUCE_WINDOWS #ifdef _CONSOLE #define START_JUCE_APPLICATION(AppClass) \ + static JUCE_NAMESPACE::JUCEApplication* juce_CreateApplication() { return new AppClass(); } \ int main (int, char* argv[]) \ { \ - JUCE_NAMESPACE::JUCEApplication::isStandaloneApp = true; \ - JUCE_NAMESPACE::ScopedJuceInitialiser_GUI libraryInitialiser; \ - return JUCE_NAMESPACE::JUCEApplication::main (JUCE_NAMESPACE::PlatformUtilities::getCurrentCommandLineParams(), new AppClass()); \ + JUCE_NAMESPACE::JUCEApplication::createInstance = &juce_CreateApplication; \ + return JUCE_NAMESPACE::JUCEApplication::main (JUCE_NAMESPACE::PlatformUtilities::getCurrentCommandLineParams()); \ } #elif ! defined (_AFXDLL) #ifdef _WINDOWS_ #define START_JUCE_APPLICATION(AppClass) \ + static JUCE_NAMESPACE::JUCEApplication* juce_CreateApplication() { return new AppClass(); } \ int WINAPI WinMain (HINSTANCE, HINSTANCE, LPSTR, int) \ { \ - JUCE_NAMESPACE::JUCEApplication::isStandaloneApp = true; \ - JUCE_NAMESPACE::ScopedJuceInitialiser_GUI libraryInitialiser; \ - return JUCE_NAMESPACE::JUCEApplication::main (JUCE_NAMESPACE::PlatformUtilities::getCurrentCommandLineParams(), new AppClass()); \ + JUCE_NAMESPACE::JUCEApplication::createInstance = &juce_CreateApplication; \ + return JUCE_NAMESPACE::JUCEApplication::main (JUCE_NAMESPACE::PlatformUtilities::getCurrentCommandLineParams()); \ } #else #define START_JUCE_APPLICATION(AppClass) \ + static JUCE_NAMESPACE::JUCEApplication* juce_CreateApplication() { return new AppClass(); } \ int __stdcall WinMain (int, int, const char*, int) \ { \ - JUCE_NAMESPACE::JUCEApplication::isStandaloneApp = true; \ - JUCE_NAMESPACE::ScopedJuceInitialiser_GUI libraryInitialiser; \ - return JUCE_NAMESPACE::JUCEApplication::main (JUCE_NAMESPACE::PlatformUtilities::getCurrentCommandLineParams(), new AppClass()); \ + JUCE_NAMESPACE::JUCEApplication::createInstance = &juce_CreateApplication; \ + return JUCE_NAMESPACE::JUCEApplication::main (JUCE_NAMESPACE::PlatformUtilities::getCurrentCommandLineParams()); \ } #endif #endif @@ -14076,7 +14079,7 @@ private: ScopedAutoReleasePool& operator= (const ScopedAutoReleasePool&); }; -#define JUCE_AUTORELEASEPOOL const ScopedAutoReleasePool pool; +#define JUCE_AUTORELEASEPOOL const JUCE_NAMESPACE::ScopedAutoReleasePool pool; #else @@ -28136,12 +28139,16 @@ public: // These are used by the START_JUCE_APPLICATION() macro and aren't for public use. /** @internal */ - static int main (const String& commandLine, JUCEApplication* newApp); + static int main (const String& commandLine); /** @internal */ - static int main (int argc, const char* argv[], JUCEApplication* newApp); + static int main (int argc, const char* argv[]); /** @internal */ static void sendUnhandledException (const std::exception* e, const char* sourceFile, int lineNumber); + /** Returns true if this executable is running as an app (as opposed to being a plugin + or other kind of shared library. */ + static inline bool isStandaloneApp() throw() { return createInstance != 0; } + /** @internal */ ApplicationCommandTarget* getNextCommandTarget(); /** @internal */ @@ -28157,7 +28164,9 @@ public: /** @internal */ int shutdownApp(); /** @internal */ - static bool isStandaloneApp; + typedef JUCEApplication* (*CreateInstanceFunction)(); + /** @internal */ + static CreateInstanceFunction createInstance; private: diff --git a/src/application/juce_Application.cpp b/src/application/juce_Application.cpp index f6c4f72f92..bf6242153e 100644 --- a/src/application/juce_Application.cpp +++ b/src/application/juce_Application.cpp @@ -45,7 +45,7 @@ JUCEApplication::JUCEApplication() : appReturnValue (0), stillInitialising (true) { - jassert (isStandaloneApp && appInstance == 0); + jassert (isStandaloneApp() && appInstance == 0); appInstance = this; } @@ -61,7 +61,7 @@ JUCEApplication::~JUCEApplication() appInstance = 0; } -bool JUCEApplication::isStandaloneApp = false; +JUCEApplication::CreateInstanceFunction JUCEApplication::createInstance = 0; JUCEApplication* JUCEApplication::appInstance = 0; //============================================================================== @@ -200,9 +200,12 @@ int JUCEApplication::shutdownApp() } //============================================================================== -int JUCEApplication::main (const String& commandLine, JUCEApplication* const app) +int JUCEApplication::main (const String& commandLine) { - const ScopedPointer appDeleter (app); + ScopedJuceInitialiser_GUI libraryInitialiser; + + jassert (createInstance != 0); + const ScopedPointer app (createInstance()); if (! app->initialiseApp (commandLine)) return 0; @@ -225,23 +228,23 @@ int JUCEApplication::main (const String& commandLine, JUCEApplication* const app extern const char* juce_Argv0; #endif -int JUCEApplication::main (int argc, const char* argv[], JUCEApplication* const newApp) +int JUCEApplication::main (int argc, const char* argv[]) { JUCE_AUTORELEASEPOOL #if ! JUCE_WINDOWS + jassert (createInstance != 0); juce_Argv0 = argv[0]; #endif #if JUCE_IOS - const ScopedPointer appDeleter (newApp); return juce_iOSMain (argc, argv); #else String cmd; for (int i = 1; i < argc; ++i) cmd << argv[i] << ' '; - return JUCEApplication::main (cmd, newApp); + return JUCEApplication::main (cmd); #endif } diff --git a/src/application/juce_Application.h b/src/application/juce_Application.h index 3927305e04..0e28d722b7 100644 --- a/src/application/juce_Application.h +++ b/src/application/juce_Application.h @@ -248,12 +248,16 @@ public: // These are used by the START_JUCE_APPLICATION() macro and aren't for public use. /** @internal */ - static int main (const String& commandLine, JUCEApplication* newApp); + static int main (const String& commandLine); /** @internal */ - static int main (int argc, const char* argv[], JUCEApplication* newApp); + static int main (int argc, const char* argv[]); /** @internal */ static void sendUnhandledException (const std::exception* e, const char* sourceFile, int lineNumber); + /** Returns true if this executable is running as an app (as opposed to being a plugin + or other kind of shared library. */ + static inline bool isStandaloneApp() throw() { return createInstance != 0; } + /** @internal */ ApplicationCommandTarget* getNextCommandTarget(); /** @internal */ @@ -269,7 +273,9 @@ public: /** @internal */ int shutdownApp(); /** @internal */ - static bool isStandaloneApp; + typedef JUCEApplication* (*CreateInstanceFunction)(); + /** @internal */ + static CreateInstanceFunction createInstance; private: //============================================================================== diff --git a/src/core/juce_Initialisation.h b/src/core/juce_Initialisation.h index 69d799ad89..83b4f05770 100644 --- a/src/core/juce_Initialisation.h +++ b/src/core/juce_Initialisation.h @@ -137,39 +137,39 @@ public: #if defined (JUCE_GCC) || defined (__MWERKS__) #define START_JUCE_APPLICATION(AppClass) \ + static JUCE_NAMESPACE::JUCEApplication* juce_CreateApplication() { return new AppClass(); } \ int main (int argc, char* argv[]) \ { \ - JUCE_NAMESPACE::JUCEApplication::isStandaloneApp = true; \ - JUCE_NAMESPACE::ScopedJuceInitialiser_GUI libraryInitialiser; \ - return JUCE_NAMESPACE::JUCEApplication::main (argc, (const char**) argv, new AppClass()); \ + JUCE_NAMESPACE::JUCEApplication::createInstance = &juce_CreateApplication; \ + return JUCE_NAMESPACE::JUCEApplication::main (argc, (const char**) argv); \ } #elif JUCE_WINDOWS #ifdef _CONSOLE #define START_JUCE_APPLICATION(AppClass) \ + static JUCE_NAMESPACE::JUCEApplication* juce_CreateApplication() { return new AppClass(); } \ int main (int, char* argv[]) \ { \ - JUCE_NAMESPACE::JUCEApplication::isStandaloneApp = true; \ - JUCE_NAMESPACE::ScopedJuceInitialiser_GUI libraryInitialiser; \ - return JUCE_NAMESPACE::JUCEApplication::main (JUCE_NAMESPACE::PlatformUtilities::getCurrentCommandLineParams(), new AppClass()); \ + JUCE_NAMESPACE::JUCEApplication::createInstance = &juce_CreateApplication; \ + return JUCE_NAMESPACE::JUCEApplication::main (JUCE_NAMESPACE::PlatformUtilities::getCurrentCommandLineParams()); \ } #elif ! defined (_AFXDLL) #ifdef _WINDOWS_ #define START_JUCE_APPLICATION(AppClass) \ + static JUCE_NAMESPACE::JUCEApplication* juce_CreateApplication() { return new AppClass(); } \ int WINAPI WinMain (HINSTANCE, HINSTANCE, LPSTR, int) \ { \ - JUCE_NAMESPACE::JUCEApplication::isStandaloneApp = true; \ - JUCE_NAMESPACE::ScopedJuceInitialiser_GUI libraryInitialiser; \ - return JUCE_NAMESPACE::JUCEApplication::main (JUCE_NAMESPACE::PlatformUtilities::getCurrentCommandLineParams(), new AppClass()); \ + JUCE_NAMESPACE::JUCEApplication::createInstance = &juce_CreateApplication; \ + return JUCE_NAMESPACE::JUCEApplication::main (JUCE_NAMESPACE::PlatformUtilities::getCurrentCommandLineParams()); \ } #else #define START_JUCE_APPLICATION(AppClass) \ + static JUCE_NAMESPACE::JUCEApplication* juce_CreateApplication() { return new AppClass(); } \ int __stdcall WinMain (int, int, const char*, int) \ { \ - JUCE_NAMESPACE::JUCEApplication::isStandaloneApp = true; \ - JUCE_NAMESPACE::ScopedJuceInitialiser_GUI libraryInitialiser; \ - return JUCE_NAMESPACE::JUCEApplication::main (JUCE_NAMESPACE::PlatformUtilities::getCurrentCommandLineParams(), new AppClass()); \ + JUCE_NAMESPACE::JUCEApplication::createInstance = &juce_CreateApplication; \ + return JUCE_NAMESPACE::JUCEApplication::main (JUCE_NAMESPACE::PlatformUtilities::getCurrentCommandLineParams()); \ } #endif #endif diff --git a/src/core/juce_PlatformUtilities.h b/src/core/juce_PlatformUtilities.h index 118442e7b7..b01e1c2424 100644 --- a/src/core/juce_PlatformUtilities.h +++ b/src/core/juce_PlatformUtilities.h @@ -226,7 +226,7 @@ private: ScopedAutoReleasePool& operator= (const ScopedAutoReleasePool&); }; -#define JUCE_AUTORELEASEPOOL const ScopedAutoReleasePool pool; +#define JUCE_AUTORELEASEPOOL const JUCE_NAMESPACE::ScopedAutoReleasePool pool; #else diff --git a/src/core/juce_StandardHeader.h b/src/core/juce_StandardHeader.h index cdfa767d64..8587c95df1 100644 --- a/src/core/juce_StandardHeader.h +++ b/src/core/juce_StandardHeader.h @@ -33,7 +33,7 @@ */ #define JUCE_MAJOR_VERSION 1 #define JUCE_MINOR_VERSION 52 -#define JUCE_BUILDNUMBER 43 +#define JUCE_BUILDNUMBER 44 /** Current Juce version number. diff --git a/src/gui/components/mouse/juce_MouseInputSource.cpp b/src/gui/components/mouse/juce_MouseInputSource.cpp index e5d55bdb8e..01afb5c636 100644 --- a/src/gui/components/mouse/juce_MouseInputSource.cpp +++ b/src/gui/components/mouse/juce_MouseInputSource.cpp @@ -375,7 +375,7 @@ public: Component* current = getComponentUnderMouse(); if (current != 0) Desktop::setMousePosition (current->getScreenBounds() - .getConstrainedPoint (current->getMouseXYRelative())); + .getConstrainedPoint (lastScreenPos)); } isUnboundedMouseModeOn = enable; diff --git a/src/gui/components/windows/juce_AlertWindow.cpp b/src/gui/components/windows/juce_AlertWindow.cpp index e0207865cf..2d4acf90a6 100644 --- a/src/gui/components/windows/juce_AlertWindow.cpp +++ b/src/gui/components/windows/juce_AlertWindow.cpp @@ -106,7 +106,7 @@ AlertWindow::AlertWindow (const String& title, } } - if (! JUCEApplication::isStandaloneApp) + if (! JUCEApplication::isStandaloneApp()) setAlwaysOnTop (true); // for a plugin, make it always-on-top because the host windows are often top-level lookAndFeelChanged(); diff --git a/src/gui/components/windows/juce_DialogWindow.cpp b/src/gui/components/windows/juce_DialogWindow.cpp index d102daac60..4d12ab0b88 100644 --- a/src/gui/components/windows/juce_DialogWindow.cpp +++ b/src/gui/components/windows/juce_DialogWindow.cpp @@ -68,7 +68,7 @@ public: TempDialogWindow (const String& title, const Colour& colour, const bool escapeCloses) : DialogWindow (title, colour, escapeCloses, true) { - if (! JUCEApplication::isStandaloneApp) + if (! JUCEApplication::isStandaloneApp()) setAlwaysOnTop (true); // for a plugin, make it always-on-top because the host windows are often top-level } diff --git a/src/gui/graphics/contexts/juce_LowLevelGraphicsSoftwareRenderer.cpp b/src/gui/graphics/contexts/juce_LowLevelGraphicsSoftwareRenderer.cpp index 52199228d7..b81bae94cc 100644 --- a/src/gui/graphics/contexts/juce_LowLevelGraphicsSoftwareRenderer.cpp +++ b/src/gui/graphics/contexts/juce_LowLevelGraphicsSoftwareRenderer.cpp @@ -2176,7 +2176,10 @@ public: { const float fontHeight = font.getHeight(); const AffineTransform transform (AffineTransform::scale (fontHeight * font.getHorizontalScale(), fontHeight) - .translated (0.0f, -0.5f)); +#if JUCE_MAC || JUCE_IOS + .translated (0.0f, -0.5f) +#endif + ); edgeTable = new EdgeTable (glyphPath.getBoundsTransformed (transform).getSmallestIntegerContainer().expanded (1, 0), glyphPath, transform); diff --git a/src/io/files/juce_File.h b/src/io/files/juce_File.h index 4c67c297db..435639b71c 100644 --- a/src/io/files/juce_File.h +++ b/src/io/files/juce_File.h @@ -814,6 +814,9 @@ public: */ invokedExecutableFile, + /** In a plugin, this will return the path of the host executable. */ + hostApplicationPath, + /** The directory in which applications normally get installed. So on windows, this would be something like "c:\program files", on the diff --git a/src/native/linux/juce_linux_Files.cpp b/src/native/linux/juce_linux_Files.cpp index 7cd643c0e1..c5cc6db850 100644 --- a/src/native/linux/juce_linux_Files.cpp +++ b/src/native/linux/juce_linux_Files.cpp @@ -166,6 +166,16 @@ const File File::getSpecialLocation (const SpecialLocationType type) case currentApplicationFile: return juce_getExecutableFile(); + case hostApplicationPath: + { + unsigned int size = 8192; + HeapBlock buffer; + buffer.calloc (size + 8); + + readlink ("/proc/self/exe", buffer.getData(), size); + return String::fromUTF8 (buffer, size); + } + default: jassertfalse; // unknown type? break; diff --git a/src/native/linux/juce_linux_Messaging.cpp b/src/native/linux/juce_linux_Messaging.cpp index 6fcfc0a779..2574865fa0 100644 --- a/src/native/linux/juce_linux_Messaging.cpp +++ b/src/native/linux/juce_linux_Messaging.cpp @@ -253,7 +253,7 @@ namespace LinuxErrorHandling { DBG ("ERROR: connection to X server broken.. terminating."); - if (JUCEApplication::isStandaloneApp) + if (JUCEApplication::isStandaloneApp()) MessageManager::getInstance()->stopDispatchLoop(); errorOccurred = true; @@ -322,7 +322,7 @@ void MessageManager::doPlatformSpecificInitialisation() // This is fatal! Print error and closedown Logger::outputDebugString ("Failed to initialise xlib thread support."); - if (JUCEApplication::isStandaloneApp) + if (JUCEApplication::isStandaloneApp()) Process::terminate(); return; @@ -424,7 +424,7 @@ bool juce_dispatchNextMessageOnSystemQueue (bool returnIfNoPendingMessages) { LinuxErrorHandling::errorOccurred = true; - if (JUCEApplication::isStandaloneApp) + if (JUCEApplication::isStandaloneApp()) Process::terminate(); break; diff --git a/src/native/mac/juce_iphone_MessageManager.mm b/src/native/mac/juce_iphone_MessageManager.mm index 93113eb683..30391f7ae6 100644 --- a/src/native/mac/juce_iphone_MessageManager.mm +++ b/src/native/mac/juce_iphone_MessageManager.mm @@ -80,6 +80,7 @@ void MessageManager::runDispatchLoop() void MessageManager::stopDispatchLoop() { + [[[UIApplication sharedApplication] delegate] applicationWillTerminate: [UIApplication sharedApplication]]; exit (0); // iPhone apps get no mercy.. } diff --git a/src/native/mac/juce_iphone_MiscUtilities.mm b/src/native/mac/juce_iphone_MiscUtilities.mm index 7dda6ea9df..2852feaebe 100644 --- a/src/native/mac/juce_iphone_MiscUtilities.mm +++ b/src/native/mac/juce_iphone_MiscUtilities.mm @@ -44,17 +44,17 @@ END_JUCE_NAMESPACE - (void) applicationDidFinishLaunching: (UIApplication*) application { - String dummy; + initialiseJuce_GUI(); - if (! JUCEApplication::getInstance()->initialiseApp (dummy)) + if (! JUCEApplication::createInstance()->initialiseApp (String::empty)) exit (0); } - (void) applicationWillTerminate: (UIApplication*) application { + jassert (JUCEApplication::getInstance() != 0); JUCEApplication::getInstance()->shutdownApp(); - // need to do this stuff because the OS kills the process before our scope-based cleanup code gets executed.. delete JUCEApplication::getInstance(); shutdownJuce_GUI(); } diff --git a/src/native/mac/juce_mac_Files.mm b/src/native/mac/juce_mac_Files.mm index 6e01f2b25a..01fa1ce62d 100644 --- a/src/native/mac/juce_mac_Files.mm +++ b/src/native/mac/juce_mac_Files.mm @@ -200,6 +200,16 @@ const File File::getSpecialLocation (const SpecialLocationType type) : exe; } + case hostApplicationPath: + { + unsigned int size = 8192; + HeapBlock buffer; + buffer.calloc (size + 8); + + _NSGetExecutablePath (buffer.getData(), &size); + return String::fromUTF8 (buffer, size); + } + default: jassertfalse; // unknown type? break; diff --git a/src/native/mac/juce_mac_MainMenu.mm b/src/native/mac/juce_mac_MainMenu.mm index ffb917797c..f8f5964676 100644 --- a/src/native/mac/juce_mac_MainMenu.mm +++ b/src/native/mac/juce_mac_MainMenu.mm @@ -485,7 +485,7 @@ static NSMenu* createStandardAppMenu (NSMenu* menu, const String& appName, static void rebuildMainMenu (const PopupMenu* extraItems) { // this can't be used in a plugin! - jassert (JUCEApplication::isStandaloneApp); + jassert (JUCEApplication::isStandaloneApp()); if (JUCEApplication::getInstance() != 0) { diff --git a/src/native/mac/juce_mac_MessageManager.mm b/src/native/mac/juce_mac_MessageManager.mm index e5903d07ed..15bd255976 100644 --- a/src/native/mac/juce_mac_MessageManager.mm +++ b/src/native/mac/juce_mac_MessageManager.mm @@ -204,7 +204,7 @@ using namespace JUCE_NAMESPACE; NSNotificationCenter* center = [NSNotificationCenter defaultCenter]; - if (JUCEApplication::isStandaloneApp) + if (JUCEApplication::isStandaloneApp()) { oldDelegate = [NSApp delegate]; [NSApp setDelegate: self]; diff --git a/src/native/mac/juce_mac_MiscUtilities.mm b/src/native/mac/juce_mac_MiscUtilities.mm index e3a6fee0e3..13835b5034 100644 --- a/src/native/mac/juce_mac_MiscUtilities.mm +++ b/src/native/mac/juce_mac_MiscUtilities.mm @@ -59,15 +59,6 @@ void PlatformUtilities::addItemToDock (const File& file) } } -int PlatformUtilities::getOSXMinorVersionNumber() -{ - SInt32 versionMinor = 0; - OSErr err = Gestalt (gestaltSystemVersionMinor, &versionMinor); - (void) err; - jassert (err == noErr); - return (int) versionMinor; -} - //============================================================================== #if ! JUCE_ONLY_BUILD_CORE_LIBRARY diff --git a/src/native/mac/juce_mac_NSViewComponentPeer.mm b/src/native/mac/juce_mac_NSViewComponentPeer.mm index 3c6d4ec87d..d76bb14ccc 100644 --- a/src/native/mac/juce_mac_NSViewComponentPeer.mm +++ b/src/native/mac/juce_mac_NSViewComponentPeer.mm @@ -328,7 +328,7 @@ END_JUCE_NAMESPACE //============================================================================== - (void) mouseDown: (NSEvent*) ev { - if (JUCEApplication::isStandaloneApp) + if (JUCEApplication::isStandaloneApp()) [self asyncMouseDown: ev]; else // In some host situations, the host will stop modal loops from working @@ -347,7 +347,7 @@ END_JUCE_NAMESPACE - (void) mouseUp: (NSEvent*) ev { - if (! JUCEApplication::isStandaloneApp) + if (! JUCEApplication::isStandaloneApp()) [self asyncMouseUp: ev]; else // In some host situations, the host will stop modal loops from working diff --git a/src/native/mac/juce_mac_NativeIncludes.h b/src/native/mac/juce_mac_NativeIncludes.h index fe21b3f2f2..d8fdebc62e 100644 --- a/src/native/mac/juce_mac_NativeIncludes.h +++ b/src/native/mac/juce_mac_NativeIncludes.h @@ -78,6 +78,7 @@ #include #include #include +#include #if MACOS_10_4_OR_EARLIER #include diff --git a/src/native/mac/juce_mac_OpenGLComponent.mm b/src/native/mac/juce_mac_OpenGLComponent.mm index 0e8448db83..8b3f5c8671 100644 --- a/src/native/mac/juce_mac_OpenGLComponent.mm +++ b/src/native/mac/juce_mac_OpenGLComponent.mm @@ -317,7 +317,7 @@ void OpenGLPixelFormat::getAvailablePixelFormats (Component* /*component*/, p = aglNextPixelFormat (p); }*/ - //jassertfalse //xxx can't see how you do this in cocoa! + //jassertfalse // can't see how you do this in cocoa! } #else diff --git a/src/native/mac/juce_mac_SystemStats.mm b/src/native/mac/juce_mac_SystemStats.mm index 868d915087..4e862c6abf 100644 --- a/src/native/mac/juce_mac_SystemStats.mm +++ b/src/native/mac/juce_mac_SystemStats.mm @@ -132,13 +132,25 @@ const String SystemStats::getOperatingSystemName() return "Mac OS X"; } +#if ! JUCE_IOS +int PlatformUtilities::getOSXMinorVersionNumber() +{ + SInt32 versionMinor = 0; + OSErr err = Gestalt (gestaltSystemVersionMinor, &versionMinor); + (void) err; + jassert (err == noErr); + return (int) versionMinor; +} +#endif + bool SystemStats::isOperatingSystem64Bit() { -#if JUCE_64BIT +#if JUCE_IOS + return false; +#elif JUCE_64BIT return true; #else - //xxx not sure how to find this out?.. - return false; + return PlatformUtilities::getOSXMinorVersionNumber() >= 6; #endif } diff --git a/src/native/windows/juce_win32_Files.cpp b/src/native/windows/juce_win32_Files.cpp index cbf77af455..a927858f1d 100644 --- a/src/native/windows/juce_win32_Files.cpp +++ b/src/native/windows/juce_win32_Files.cpp @@ -439,7 +439,14 @@ const File JUCE_CALLTYPE File::getSpecialLocation (const SpecialLocationType typ GetModuleFileName (moduleHandle, dest, numElementsInArray (dest)); return File (String (dest)); } - break; + + case hostApplicationPath: + { + WCHAR dest [MAX_PATH + 256]; + dest[0] = 0; + GetModuleFileName (0, dest, numElementsInArray (dest)); + return File (String (dest)); + } default: jassertfalse; // unknown type?