diff --git a/extras/Jucer (experimental)/Source/Project/jucer_ProjectExport_XCode.h b/extras/Jucer (experimental)/Source/Project/jucer_ProjectExport_XCode.h index 6bda1d0d78..0cf136f217 100644 --- a/extras/Jucer (experimental)/Source/Project/jucer_ProjectExport_XCode.h +++ b/extras/Jucer (experimental)/Source/Project/jucer_ProjectExport_XCode.h @@ -164,18 +164,13 @@ private: addFrameworks(); const String productName (project.getConfiguration (0).getTargetBinaryName().toString()); - if (project.isGUIApplication()) - addBuildProduct ("wrapper.application", productName + ".app"); - else if (project.isCommandLineApp()) - addBuildProduct ("compiled.mach-o.executable", productName); - else if (project.isLibrary()) - addBuildProduct ("archive.ar", getLibbedFilename (productName)); - else if (project.isAudioPlugin()) - addBuildProduct ("wrapper.cfbundle", productName + "." + getAudioPluginBundleExtension()); - else if (project.isBrowserPlugin()) - addBuildProduct ("wrapper.cfbundle", productName + ".plugin"); - else - jassert (productName.isEmpty()); + + if (project.isGUIApplication()) addBuildProduct ("wrapper.application", productName + ".app"); + else if (project.isCommandLineApp()) addBuildProduct ("compiled.mach-o.executable", productName); + else if (project.isLibrary()) addBuildProduct ("archive.ar", getLibbedFilename (productName)); + else if (project.isAudioPlugin()) addBuildProduct ("wrapper.cfbundle", productName + "." + getAudioPluginBundleExtension()); + else if (project.isBrowserPlugin()) addBuildProduct ("wrapper.cfbundle", productName + ".plugin"); + else jassert (productName.isEmpty()); if (hasPList()) { @@ -604,12 +599,9 @@ private: s.add ("SDKROOT = macosx10.6"); } - if (sdkCompat == Project::BuildConfiguration::osxVersion10_4) - s.add ("MACOSX_DEPLOYMENT_TARGET = 10.4"); - else if (sdkCompat == Project::BuildConfiguration::osxVersion10_5) - s.add ("MACOSX_DEPLOYMENT_TARGET = 10.5"); - else if (sdkCompat == Project::BuildConfiguration::osxVersion10_6) - s.add ("MACOSX_DEPLOYMENT_TARGET = 10.6"); + if (sdkCompat == Project::BuildConfiguration::osxVersion10_4) s.add ("MACOSX_DEPLOYMENT_TARGET = 10.4"); + else if (sdkCompat == Project::BuildConfiguration::osxVersion10_5) s.add ("MACOSX_DEPLOYMENT_TARGET = 10.5"); + else if (sdkCompat == Project::BuildConfiguration::osxVersion10_6) s.add ("MACOSX_DEPLOYMENT_TARGET = 10.6"); s.add ("MACOSX_DEPLOYMENT_TARGET_ppc = 10.4"); } diff --git a/juce_amalgamated.cpp b/juce_amalgamated.cpp index 0793ed0074..35ede30d93 100644 --- a/juce_amalgamated.cpp +++ b/juce_amalgamated.cpp @@ -2180,10 +2180,6 @@ BEGIN_JUCE_NAMESPACE #endif -#if JUCE_WINDOWS - extern void juce_shutdownWin32Sockets(); // (defined in the sockets code) -#endif - #if JUCE_DEBUG extern void juce_CheckForDanglingStreams(); // (in juce_OutputStream.cpp) #endif @@ -2237,10 +2233,6 @@ JUCE_API void JUCE_CALLTYPE shutdownJuce_NonGUI() LocalisedStrings::setCurrentMappings (0); Thread::stopAllThreads (3000); - #if JUCE_WINDOWS - juce_shutdownWin32Sockets(); - #endif - #if JUCE_DEBUG juce_CheckForDanglingStreams(); #endif @@ -8964,72 +8956,70 @@ END_JUCE_NAMESPACE /*** Start of inlined file: juce_Socket.cpp ***/ #if JUCE_WINDOWS - #include - #include + #include + #include - #if JUCE_MSVC - #pragma warning (push) - #pragma warning (disable : 4127 4389 4018) - #endif + #if JUCE_MSVC + #pragma warning (push) + #pragma warning (disable : 4127 4389 4018) + #endif #else - #if JUCE_LINUX || JUCE_ANDROID - #include - #include - #include - #include - #include - #elif (MACOSX_DEPLOYMENT_TARGET <= MAC_OS_X_VERSION_10_4) && ! JUCE_IOS - #include - #endif + #if JUCE_LINUX || JUCE_ANDROID + #include + #include + #include + #include + #include + #endif - #include - #include - #include - #include + #include + #include + #include + #include + + #ifndef AI_NUMERICSERV // (missing in older Mac SDKs) + #define AI_NUMERICSERV 0x1000 + #endif #endif BEGIN_JUCE_NAMESPACE -#if JUCE_LINUX || JUCE_MAC || JUCE_IOS || JUCE_ANDROID - typedef socklen_t juce_socklen_t; -#else - typedef int juce_socklen_t; -#endif - #if JUCE_WINDOWS + typedef int juce_socklen_t; +#else + typedef socklen_t juce_socklen_t; +#endif namespace SocketHelpers { - typedef int (__stdcall juce_CloseWin32SocketLibCall) (void); - static juce_CloseWin32SocketLibCall* juce_CloseWin32SocketLib = 0; - - void initWin32Sockets() + #if JUCE_WINDOWS + class WinSocketStarter : public DeletedAtShutdown { - static CriticalSection lock; - const ScopedLock sl (lock); - - if (SocketHelpers::juce_CloseWin32SocketLib == 0) + public: + WinSocketStarter() { WSADATA wsaData; const WORD wVersionRequested = MAKEWORD (1, 1); WSAStartup (wVersionRequested, &wsaData); - - SocketHelpers::juce_CloseWin32SocketLib = &WSACleanup; } - } -} -void juce_shutdownWin32Sockets() -{ - if (SocketHelpers::juce_CloseWin32SocketLib != 0) - (*SocketHelpers::juce_CloseWin32SocketLib)(); -} + ~WinSocketStarter() + { + WSACleanup(); + clearSingletonInstance(); + } -#endif + juce_DeclareSingleton (WinSocketStarter, false); + }; + + juce_ImplementSingleton (WinSocketStarter); + + void initSockets() { WinSocketStarter::getInstance(); } + #else + void initSockets() {} + #endif -namespace SocketHelpers -{ bool resetSocketOptions (const int handle, const bool isDatagram, const bool allowBroadcast) throw() { const int sndBufSize = 65536; @@ -9068,15 +9058,15 @@ namespace SocketHelpers { int bytesThisTime; - #if JUCE_WINDOWS + #if JUCE_WINDOWS bytesThisTime = recv (handle, static_cast (destBuffer) + bytesRead, maxBytesToRead - bytesRead, 0); - #else + #else while ((bytesThisTime = (int) ::read (handle, addBytesToPointer (destBuffer, bytesRead), maxBytesToRead - bytesRead)) < 0 && errno == EINTR && connected) { } - #endif + #endif if (bytesThisTime <= 0 || ! connected) { @@ -9120,10 +9110,10 @@ namespace SocketHelpers fd_set* const prset = forReading ? &rset : 0; fd_set* const pwset = forReading ? 0 : &wset; - #if JUCE_WINDOWS + #if JUCE_WINDOWS if (select (handle + 1, prset, pwset, 0, timeoutp) < 0) return -1; - #else + #else { int result; while ((result = select (handle + 1, prset, pwset, 0, timeoutp)) < 0 @@ -9134,7 +9124,7 @@ namespace SocketHelpers if (result < 0) return -1; } - #endif + #endif { int opt; @@ -9145,21 +9135,15 @@ namespace SocketHelpers return -1; } - if ((forReading && FD_ISSET (handle, &rset)) - || ((! forReading) && FD_ISSET (handle, &wset))) - return 1; - - return 0; + return FD_ISSET (handle, forReading ? &rset : &wset) ? 1 : 0; } bool setSocketBlockingState (const int handle, const bool shouldBlock) throw() { - #if JUCE_WINDOWS + #if JUCE_WINDOWS u_long nonBlocking = shouldBlock ? 0 : 1; - - if (ioctlsocket (handle, FIONBIO, &nonBlocking) != 0) - return false; - #else + return ioctlsocket (handle, FIONBIO, &nonBlocking) == 0; + #else int socketFlags = fcntl (handle, F_GETFL, 0); if (socketFlags == -1) @@ -9170,11 +9154,8 @@ namespace SocketHelpers else socketFlags |= O_NONBLOCK; - if (fcntl (handle, F_SETFL, socketFlags) != 0) - return false; - #endif - - return true; + return fcntl (handle, F_SETFL, socketFlags) == 0; + #endif } bool connectSocket (int volatile& handle, @@ -9246,9 +9227,7 @@ StreamingSocket::StreamingSocket() connected (false), isListener (false) { -#if JUCE_WINDOWS - SocketHelpers::initWin32Sockets(); -#endif + SocketHelpers::initSockets(); } StreamingSocket::StreamingSocket (const String& hostName_, @@ -9260,10 +9239,7 @@ StreamingSocket::StreamingSocket (const String& hostName_, connected (true), isListener (false) { -#if JUCE_WINDOWS - SocketHelpers::initWin32Sockets(); -#endif - + SocketHelpers::initSockets(); SocketHelpers::resetSocketOptions (handle_, false, false); } @@ -9283,9 +9259,9 @@ int StreamingSocket::write (const void* sourceBuffer, const int numBytesToWrite) if (isListener || ! connected) return -1; -#if JUCE_WINDOWS + #if JUCE_WINDOWS return send (handle, (const char*) sourceBuffer, numBytesToWrite, 0); -#else + #else int result; while ((result = (int) ::write (handle, sourceBuffer, numBytesToWrite)) < 0 @@ -9294,7 +9270,7 @@ int StreamingSocket::write (const void* sourceBuffer, const int numBytesToWrite) } return result; -#endif + #endif } int StreamingSocket::waitUntilReady (const bool readyForReading, @@ -9340,12 +9316,12 @@ bool StreamingSocket::connect (const String& remoteHostName, void StreamingSocket::close() { -#if JUCE_WINDOWS + #if JUCE_WINDOWS if (handle != SOCKET_ERROR || connected) closesocket (handle); connected = false; -#else + #else if (connected) { connected = false; @@ -9360,7 +9336,7 @@ void StreamingSocket::close() if (handle != -1) ::close (handle); -#endif + #endif hostName = String::empty; portNumber = 0; @@ -9437,9 +9413,7 @@ DatagramSocket::DatagramSocket (const int localPortNumber, const bool allowBroad allowBroadcast (allowBroadcast_), serverAddress (0) { -#if JUCE_WINDOWS - SocketHelpers::initWin32Sockets(); -#endif + SocketHelpers::initSockets(); handle = (int) socket (AF_INET, SOCK_DGRAM, 0); bindToPort (localPortNumber); @@ -9454,9 +9428,7 @@ DatagramSocket::DatagramSocket (const String& hostName_, const int portNumber_, allowBroadcast (false), serverAddress (0) { -#if JUCE_WINDOWS - SocketHelpers::initWin32Sockets(); -#endif + SocketHelpers::initSockets(); SocketHelpers::resetSocketOptions (handle_, true, allowBroadcast); bindToPort (localPortNumber); @@ -9472,13 +9444,13 @@ DatagramSocket::~DatagramSocket() void DatagramSocket::close() { -#if JUCE_WINDOWS + #if JUCE_WINDOWS closesocket (handle); connected = false; -#else + #else connected = false; ::close (handle); -#endif + #endif hostName = String::empty; portNumber = 0; @@ -9564,7 +9536,7 @@ bool DatagramSocket::isLocal() const throw() } #if JUCE_MSVC - #pragma warning (pop) + #pragma warning (pop) #endif END_JUCE_NAMESPACE @@ -42538,17 +42510,14 @@ Desktop& JUCE_CALLTYPE Desktop::getInstance() Desktop* Desktop::instance = 0; -extern void juce_updateMultiMonitorInfo (Array >& monitorCoords, - const bool clipToWorkArea); - void Desktop::refreshMonitorSizes() { Array > oldClipped, oldUnclipped; oldClipped.swapWithArray (monitorCoordsClipped); oldUnclipped.swapWithArray (monitorCoordsUnclipped); - juce_updateMultiMonitorInfo (monitorCoordsClipped, true); - juce_updateMultiMonitorInfo (monitorCoordsUnclipped, false); + getCurrentMonitorPositions (monitorCoordsClipped, true); + getCurrentMonitorPositions (monitorCoordsUnclipped, false); jassert (monitorCoordsClipped.size() == monitorCoordsUnclipped.size()); if (oldClipped != monitorCoordsClipped @@ -189508,6 +189477,7 @@ long ov_read_filter(OggVorbis_File *vf,char *buffer,int length, long channels=ov_info(vf,-1)->channels; long bytespersample=word * channels; vorbis_fpu_control fpu; + (void) fpu; if(samples>length/bytespersample)samples=length/bytespersample; if(samples <= 0) @@ -248381,7 +248351,7 @@ static BOOL CALLBACK enumMonitorsProc (HMONITOR, HDC, LPRECT r, LPARAM userInfo) return TRUE; } -void juce_updateMultiMonitorInfo (Array >& monitorCoords, const bool clipToWorkArea) +void Desktop::getCurrentMonitorPositions (Array >& monitorCoords, const bool clipToWorkArea) { EnumDisplayMonitors (0, 0, &enumMonitorsProc, (LPARAM) &monitorCoords); @@ -263901,7 +263871,7 @@ void juce_windowMessageReceive (XEvent* event) } } -void juce_updateMultiMonitorInfo (Array >& monitorCoords, const bool /*clipToWorkArea*/) +void Desktop::getCurrentMonitorPositions (Array >& monitorCoords, const bool /*clipToWorkArea*/) { if (display == 0) return; @@ -269554,13 +269524,13 @@ void Desktop::setScreenSaverEnabled (const bool isEnabled) { if (screenSaverDisablerID == 0) { -#if defined (MAC_OS_X_VERSION_10_6) && MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_6 + #if defined (MAC_OS_X_VERSION_10_6) && MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_6 IOPMAssertionCreateWithName (kIOPMAssertionTypeNoIdleSleep, kIOPMAssertionLevelOn, CFSTR ("Juce"), &screenSaverDisablerID); -#else + #else IOPMAssertionCreate (kIOPMAssertionTypeNoIdleSleep, kIOPMAssertionLevelOn, &screenSaverDisablerID); -#endif + #endif } } } @@ -269572,9 +269542,39 @@ bool Desktop::isScreenSaverEnabled() #endif -void juce_updateMultiMonitorInfo (Array >& monitorCoords, const bool clipToWorkArea) +class DisplaySettingsChangeCallback : public DeletedAtShutdown +{ +public: + DisplaySettingsChangeCallback() + { + CGDisplayRegisterReconfigurationCallback (displayReconfigurationCallBack, 0); + } + + ~DisplaySettingsChangeCallback() + { + CGDisplayRemoveReconfigurationCallback (displayReconfigurationCallBack, 0); + clearSingletonInstance(); + } + + static void displayReconfigurationCallBack (CGDirectDisplayID, CGDisplayChangeSummaryFlags, void*) + { + Desktop::getInstance().refreshMonitorSizes(); + } + + juce_DeclareSingleton_SingleThreaded_Minimal (DisplaySettingsChangeCallback); + +private: + JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (DisplaySettingsChangeCallback); +}; + +juce_ImplementSingleton_SingleThreaded (DisplaySettingsChangeCallback); + +void Desktop::getCurrentMonitorPositions (Array >& monitorCoords, const bool clipToWorkArea) { const ScopedAutoReleasePool pool; + + DisplaySettingsChangeCallback::getInstance(); + monitorCoords.clear(); NSArray* screens = [NSScreen screens]; const CGFloat mainScreenBottom = [[[NSScreen screens] objectAtIndex: 0] frame].size.height; @@ -269595,7 +269595,6 @@ void juce_updateMultiMonitorInfo (Array >& monitorCoords, const } #endif - #endif /*** End of inlined file: juce_mac_MiscUtilities.mm ***/ @@ -271958,7 +271957,7 @@ Desktop::DisplayOrientation Desktop::getCurrentOrientation() const return convertToJuceOrientation ([[UIApplication sharedApplication] statusBarOrientation]); } -void juce_updateMultiMonitorInfo (Array >& monitorCoords, const bool clipToWorkArea) +void Desktop::getCurrentMonitorPositions (Array >& monitorCoords, const bool clipToWorkArea) { const ScopedAutoReleasePool pool; monitorCoords.clear(); @@ -287138,7 +287137,7 @@ void juce_setKioskComponent (Component* kioskModeComponent, bool enableOrDisable { } -void juce_updateMultiMonitorInfo (Array >& monitorCoords, const bool clipToWorkArea) +void Desktop::getCurrentMonitorPositions (Array >& monitorCoords, const bool clipToWorkArea) { monitorCoords.add (Rectangle (0, 0, android.screenWidth, android.screenHeight)); } diff --git a/juce_amalgamated.h b/juce_amalgamated.h index 8d4a3c7457..be41c93c8a 100644 --- a/juce_amalgamated.h +++ b/juce_amalgamated.h @@ -73,7 +73,7 @@ namespace JuceDummyNamespace {} */ #define JUCE_MAJOR_VERSION 1 #define JUCE_MINOR_VERSION 53 -#define JUCE_BUILDNUMBER 44 +#define JUCE_BUILDNUMBER 45 /** Current Juce version number. @@ -542,8 +542,8 @@ namespace JuceDummyNamespace {} /** This macro defines the C calling convention used as the standard for Juce calls. */ #if JUCE_MSVC - #define JUCE_CALLTYPE __stdcall - #define JUCE_CDECL __cdecl + #define JUCE_CALLTYPE __stdcall + #define JUCE_CDECL __cdecl #else #define JUCE_CALLTYPE #define JUCE_CDECL @@ -560,64 +560,42 @@ namespace JuceDummyNamespace {} #define juce_LogCurrentAssertion #endif -#if JUCE_DEBUG - - // If debugging is enabled.. - - /** Writes a string to the standard error stream. - - This is only compiled in a debug build. - - @see Logger::outputDebugString +#if JUCE_MAC || DOXYGEN + /** This will try to break into the debugger if the app is currently being debugged. + If called by an app that's not being debugged, the behaiour isn't defined - it may crash or not, depending + on the platform. + @see jassert() */ - #define DBG(dbgtext) { JUCE_NAMESPACE::String tempDbgBuf; tempDbgBuf << dbgtext; JUCE_NAMESPACE::Logger::outputDebugString (tempDbgBuf); } + #define juce_breakDebugger { Debugger(); } +#elif JUCE_IOS || JUCE_LINUX || JUCE_ANDROID + #define juce_breakDebugger { kill (0, SIGTRAP); } +#elif JUCE_USE_INTRINSICS + #pragma intrinsic (__debugbreak) + #define juce_breakDebugger { __debugbreak(); } +#elif JUCE_GCC + #define juce_breakDebugger { asm("int $3"); } +#else + #define juce_breakDebugger { __asm int 3 } +#endif - // Assertions.. - - #if JUCE_WINDOWS || DOXYGEN - - #if JUCE_USE_INTRINSICS - #pragma intrinsic (__debugbreak) - - /** This will try to break the debugger if one is currently hosting this app. - @see jassert() - */ - #define juce_breakDebugger __debugbreak(); - - #elif JUCE_GCC - /** This will try to break the debugger if one is currently hosting this app. - @see jassert() - */ - #define juce_breakDebugger asm("int $3"); - #else - /** This will try to break the debugger if one is currently hosting this app. - @see jassert() - */ - #define juce_breakDebugger { __asm int 3 } - #endif - #elif JUCE_MAC - #define juce_breakDebugger Debugger(); - #elif JUCE_IOS || JUCE_LINUX || JUCE_ANDROID - #define juce_breakDebugger kill (0, SIGTRAP); - #endif +#if JUCE_DEBUG || DOXYGEN + /** Writes a string to the standard error stream. + This is only compiled in a debug build. + @see Logger::outputDebugString + */ + #define DBG(dbgtext) { JUCE_NAMESPACE::String tempDbgBuf; tempDbgBuf << dbgtext; JUCE_NAMESPACE::Logger::outputDebugString (tempDbgBuf); } /** This will always cause an assertion failure. - - It is only compiled in a debug build, (unless JUCE_LOG_ASSERTIONS is enabled - in juce_Config.h). - - @see jassert() + It is only compiled in a debug build, (unless JUCE_LOG_ASSERTIONS is enabled for your build). + @see jassert */ #define jassertfalse { juce_LogCurrentAssertion; if (JUCE_NAMESPACE::juce_isRunningUnderDebugger()) juce_breakDebugger; } /** Platform-independent assertion macro. - This gets optimised out when not being built with debugging turned on. - - Be careful not to call any functions within its arguments that are vital to - the behaviour of the program, because these won't get called in the release - build. - + This macro gets turned into a no-op when you're building with debugging turned off, so be + careful that the expression you pass to it doesn't perform any actions that are vital for the + correct behaviour of your program! @see jassertfalse */ #define jassert(expression) { if (! (expression)) jassertfalse; } @@ -627,13 +605,12 @@ namespace JuceDummyNamespace {} // If debugging is disabled, these dummy debug and assertion macros are used.. #define DBG(dbgtext) - #define jassertfalse { juce_LogCurrentAssertion } #if JUCE_LOG_ASSERTIONS - #define jassert(expression) { if (! (expression)) jassertfalse; } + #define jassert(expression) { if (! (expression)) jassertfalse; } #else - #define jassert(a) { } + #define jassert(a) {} #endif #endif @@ -646,13 +623,13 @@ namespace JuceDummyNamespace {} #endif /** A compile-time assertion macro. - - If the expression parameter is false, the macro will cause a compile error. + If the expression parameter is false, the macro will cause a compile error. (The actual error + message that the compiler generates may be completely bizarre and seem to have no relation to + the place where you put the static_assert though!) */ #define static_jassert(expression) JUCE_NAMESPACE::JuceStaticAssert::dummy(); -/** This is a shorthand macro for declaring stubs for a class's copy constructor and - operator=. +/** This is a shorthand macro for declaring stubs for a class's copy constructor and operator=. For example, instead of @code @@ -691,7 +668,7 @@ namespace JuceDummyNamespace {} #define JUCE_JOIN_MACRO_HELPER(a, b) a ## b #endif -/** Good old C macro concatenation helper. +/** A good old-fashioned C macro concatenation helper. This combines two items (which may themselves be macros) into a single string, avoiding the pitfalls of the ## macro operator. */ @@ -730,42 +707,32 @@ namespace JuceDummyNamespace {} #endif -// Macros for inlining. - -#if JUCE_MSVC +#if JUCE_DEBUG || DOXYGEN /** A platform-independent way of forcing an inline function. - Use the syntax: @code forcedinline void myfunction (int x) @endcode */ - #ifndef JUCE_DEBUG - #define forcedinline __forceinline - #else - #define forcedinline inline - #endif - - #define JUCE_ALIGN(bytes) __declspec (align (bytes)) - + #define forcedinline inline #else - /** A platform-independent way of forcing an inline function. - - Use the syntax: @code - forcedinline void myfunction (int x) - @endcode - */ - #ifndef JUCE_DEBUG - #define forcedinline inline __attribute__((always_inline)) + #if JUCE_MSVC + #define forcedinline __forceinline #else - #define forcedinline inline + #define forcedinline inline __attribute__((always_inline)) #endif +#endif - #define JUCE_ALIGN(bytes) __attribute__ ((aligned (bytes))) - +#if JUCE_MSVC || DOXYGEN + /** This can be placed before a stack or member variable declaration to tell the compiler + to align it to the specified number of bytes. */ + #define JUCE_ALIGN(bytes) __declspec (align (bytes)) +#else + #define JUCE_ALIGN(bytes) __attribute__ ((aligned (bytes))) #endif // Cross-compiler deprecation macros.. -#if JUCE_MSVC && ! JUCE_NO_DEPRECATION_WARNINGS +#if DOXYGEN || (JUCE_MSVC && ! JUCE_NO_DEPRECATION_WARNINGS) + /** This can be used to wrap a function which has been deprecated. */ #define JUCE_DEPRECATED(functionDef) __declspec(deprecated) functionDef #elif JUCE_GCC && ! JUCE_NO_DEPRECATION_WARNINGS #define JUCE_DEPRECATED(functionDef) functionDef __attribute__ ((deprecated)) @@ -777,8 +744,7 @@ namespace JuceDummyNamespace {} #define JUCE_MODAL_LOOPS_PERMITTED 0 #else /** Some operating environments don't provide a modal loop mechanism, so this flag can be - used to disable any functions that try to run a modal loop. - */ + used to disable any functions that try to run a modal loop. */ #define JUCE_MODAL_LOOPS_PERMITTED 1 #endif @@ -33416,6 +33382,7 @@ private: int getNumDisplayMonitors() const throw(); const Rectangle getDisplayMonitorCoordinates (int index, bool clippedToWorkArea) const throw(); + static void getCurrentMonitorPositions (Array >& monitorCoords, const bool clipToWorkArea); void addDesktopComponent (Component* c); void removeDesktopComponent (Component* c); diff --git a/src/audio/audio_file_formats/oggvorbis/libvorbis-1.3.2/lib/vorbisfile.c b/src/audio/audio_file_formats/oggvorbis/libvorbis-1.3.2/lib/vorbisfile.c index bf0403b17f..5c54b736d7 100644 --- a/src/audio/audio_file_formats/oggvorbis/libvorbis-1.3.2/lib/vorbisfile.c +++ b/src/audio/audio_file_formats/oggvorbis/libvorbis-1.3.2/lib/vorbisfile.c @@ -1902,6 +1902,7 @@ long ov_read_filter(OggVorbis_File *vf,char *buffer,int length, long channels=ov_info(vf,-1)->channels; long bytespersample=word * channels; vorbis_fpu_control fpu; + (void) fpu; if(samples>length/bytespersample)samples=length/bytespersample; if(samples <= 0) diff --git a/src/core/juce_Initialisation.cpp b/src/core/juce_Initialisation.cpp index dd0949f736..7f46d19381 100644 --- a/src/core/juce_Initialisation.cpp +++ b/src/core/juce_Initialisation.cpp @@ -42,10 +42,6 @@ BEGIN_JUCE_NAMESPACE #include "../gui/components/lookandfeel/juce_LookAndFeel.h" #endif -#if JUCE_WINDOWS - extern void juce_shutdownWin32Sockets(); // (defined in the sockets code) -#endif - #if JUCE_DEBUG extern void juce_CheckForDanglingStreams(); // (in juce_OutputStream.cpp) #endif @@ -101,10 +97,6 @@ JUCE_API void JUCE_CALLTYPE shutdownJuce_NonGUI() LocalisedStrings::setCurrentMappings (0); Thread::stopAllThreads (3000); - #if JUCE_WINDOWS - juce_shutdownWin32Sockets(); - #endif - #if JUCE_DEBUG juce_CheckForDanglingStreams(); #endif diff --git a/src/core/juce_PlatformDefs.h b/src/core/juce_PlatformDefs.h index 4b3b815995..c53e3de0f9 100644 --- a/src/core/juce_PlatformDefs.h +++ b/src/core/juce_PlatformDefs.h @@ -41,8 +41,8 @@ /** This macro defines the C calling convention used as the standard for Juce calls. */ #if JUCE_MSVC - #define JUCE_CALLTYPE __stdcall - #define JUCE_CDECL __cdecl + #define JUCE_CALLTYPE __stdcall + #define JUCE_CDECL __cdecl #else #define JUCE_CALLTYPE #define JUCE_CDECL @@ -60,83 +60,62 @@ #define juce_LogCurrentAssertion #endif -#if JUCE_DEBUG - //============================================================================== - // If debugging is enabled.. - - /** Writes a string to the standard error stream. - - This is only compiled in a debug build. - - @see Logger::outputDebugString +//============================================================================== +#if JUCE_MAC || DOXYGEN + /** This will try to break into the debugger if the app is currently being debugged. + If called by an app that's not being debugged, the behaiour isn't defined - it may crash or not, depending + on the platform. + @see jassert() */ - #define DBG(dbgtext) { JUCE_NAMESPACE::String tempDbgBuf; tempDbgBuf << dbgtext; JUCE_NAMESPACE::Logger::outputDebugString (tempDbgBuf); } + #define juce_breakDebugger { Debugger(); } +#elif JUCE_IOS || JUCE_LINUX || JUCE_ANDROID + #define juce_breakDebugger { kill (0, SIGTRAP); } +#elif JUCE_USE_INTRINSICS + #pragma intrinsic (__debugbreak) + #define juce_breakDebugger { __debugbreak(); } +#elif JUCE_GCC + #define juce_breakDebugger { asm("int $3"); } +#else + #define juce_breakDebugger { __asm int 3 } +#endif - //============================================================================== - // Assertions.. - #if JUCE_WINDOWS || DOXYGEN - - #if JUCE_USE_INTRINSICS - #pragma intrinsic (__debugbreak) - - /** This will try to break the debugger if one is currently hosting this app. - @see jassert() - */ - #define juce_breakDebugger __debugbreak(); - - #elif JUCE_GCC - /** This will try to break the debugger if one is currently hosting this app. - @see jassert() - */ - #define juce_breakDebugger asm("int $3"); - #else - /** This will try to break the debugger if one is currently hosting this app. - @see jassert() - */ - #define juce_breakDebugger { __asm int 3 } - #endif - #elif JUCE_MAC - #define juce_breakDebugger Debugger(); - #elif JUCE_IOS || JUCE_LINUX || JUCE_ANDROID - #define juce_breakDebugger kill (0, SIGTRAP); - #endif +//============================================================================== +#if JUCE_DEBUG || DOXYGEN + /** Writes a string to the standard error stream. + This is only compiled in a debug build. + @see Logger::outputDebugString + */ + #define DBG(dbgtext) { JUCE_NAMESPACE::String tempDbgBuf; tempDbgBuf << dbgtext; JUCE_NAMESPACE::Logger::outputDebugString (tempDbgBuf); } //============================================================================== /** This will always cause an assertion failure. - - It is only compiled in a debug build, (unless JUCE_LOG_ASSERTIONS is enabled - in juce_Config.h). - - @see jassert() + It is only compiled in a debug build, (unless JUCE_LOG_ASSERTIONS is enabled for your build). + @see jassert */ - #define jassertfalse { juce_LogCurrentAssertion; if (JUCE_NAMESPACE::juce_isRunningUnderDebugger()) juce_breakDebugger; } + #define jassertfalse { juce_LogCurrentAssertion; if (JUCE_NAMESPACE::juce_isRunningUnderDebugger()) juce_breakDebugger; } //============================================================================== /** Platform-independent assertion macro. - This gets optimised out when not being built with debugging turned on. - - Be careful not to call any functions within its arguments that are vital to - the behaviour of the program, because these won't get called in the release - build. - + This macro gets turned into a no-op when you're building with debugging turned off, so be + careful that the expression you pass to it doesn't perform any actions that are vital for the + correct behaviour of your program! @see jassertfalse */ - #define jassert(expression) { if (! (expression)) jassertfalse; } + #define jassert(expression) { if (! (expression)) jassertfalse; } #else //============================================================================== // If debugging is disabled, these dummy debug and assertion macros are used.. #define DBG(dbgtext) - - #define jassertfalse { juce_LogCurrentAssertion } + #define jassertfalse { juce_LogCurrentAssertion } #if JUCE_LOG_ASSERTIONS - #define jassert(expression) { if (! (expression)) jassertfalse; } + #define jassert(expression) { if (! (expression)) jassertfalse; } #else - #define jassert(a) { } + #define jassert(a) {} #endif #endif @@ -150,13 +129,13 @@ #endif /** A compile-time assertion macro. - - If the expression parameter is false, the macro will cause a compile error. + If the expression parameter is false, the macro will cause a compile error. (The actual error + message that the compiler generates may be completely bizarre and seem to have no relation to + the place where you put the static_assert though!) */ #define static_jassert(expression) JUCE_NAMESPACE::JuceStaticAssert::dummy(); -/** This is a shorthand macro for declaring stubs for a class's copy constructor and - operator=. +/** This is a shorthand macro for declaring stubs for a class's copy constructor and operator=. For example, instead of @code @@ -197,7 +176,7 @@ #define JUCE_JOIN_MACRO_HELPER(a, b) a ## b #endif -/** Good old C macro concatenation helper. +/** A good old-fashioned C macro concatenation helper. This combines two items (which may themselves be macros) into a single string, avoiding the pitfalls of the ## macro operator. */ @@ -238,43 +217,33 @@ #endif //============================================================================== -// Macros for inlining. - -#if JUCE_MSVC +#if JUCE_DEBUG || DOXYGEN /** A platform-independent way of forcing an inline function. - Use the syntax: @code forcedinline void myfunction (int x) @endcode */ - #ifndef JUCE_DEBUG - #define forcedinline __forceinline - #else - #define forcedinline inline - #endif - - #define JUCE_ALIGN(bytes) __declspec (align (bytes)) - + #define forcedinline inline #else - /** A platform-independent way of forcing an inline function. - - Use the syntax: @code - forcedinline void myfunction (int x) - @endcode - */ - #ifndef JUCE_DEBUG - #define forcedinline inline __attribute__((always_inline)) + #if JUCE_MSVC + #define forcedinline __forceinline #else - #define forcedinline inline + #define forcedinline inline __attribute__((always_inline)) #endif +#endif - #define JUCE_ALIGN(bytes) __attribute__ ((aligned (bytes))) - +#if JUCE_MSVC || DOXYGEN + /** This can be placed before a stack or member variable declaration to tell the compiler + to align it to the specified number of bytes. */ + #define JUCE_ALIGN(bytes) __declspec (align (bytes)) +#else + #define JUCE_ALIGN(bytes) __attribute__ ((aligned (bytes))) #endif //============================================================================== // Cross-compiler deprecation macros.. -#if JUCE_MSVC && ! JUCE_NO_DEPRECATION_WARNINGS +#if DOXYGEN || (JUCE_MSVC && ! JUCE_NO_DEPRECATION_WARNINGS) + /** This can be used to wrap a function which has been deprecated. */ #define JUCE_DEPRECATED(functionDef) __declspec(deprecated) functionDef #elif JUCE_GCC && ! JUCE_NO_DEPRECATION_WARNINGS #define JUCE_DEPRECATED(functionDef) functionDef __attribute__ ((deprecated)) @@ -287,8 +256,7 @@ #define JUCE_MODAL_LOOPS_PERMITTED 0 #else /** Some operating environments don't provide a modal loop mechanism, so this flag can be - used to disable any functions that try to run a modal loop. - */ + used to disable any functions that try to run a modal loop. */ #define JUCE_MODAL_LOOPS_PERMITTED 1 #endif diff --git a/src/core/juce_StandardHeader.h b/src/core/juce_StandardHeader.h index b302e2c08c..19a36658d7 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 53 -#define JUCE_BUILDNUMBER 44 +#define JUCE_BUILDNUMBER 45 /** Current Juce version number. diff --git a/src/gui/components/juce_Desktop.cpp b/src/gui/components/juce_Desktop.cpp index b96e6c55ab..c2f185bc5e 100644 --- a/src/gui/components/juce_Desktop.cpp +++ b/src/gui/components/juce_Desktop.cpp @@ -65,17 +65,14 @@ Desktop& JUCE_CALLTYPE Desktop::getInstance() Desktop* Desktop::instance = 0; //============================================================================== -extern void juce_updateMultiMonitorInfo (Array >& monitorCoords, - const bool clipToWorkArea); - void Desktop::refreshMonitorSizes() { Array > oldClipped, oldUnclipped; oldClipped.swapWithArray (monitorCoordsClipped); oldUnclipped.swapWithArray (monitorCoordsUnclipped); - juce_updateMultiMonitorInfo (monitorCoordsClipped, true); - juce_updateMultiMonitorInfo (monitorCoordsUnclipped, false); + getCurrentMonitorPositions (monitorCoordsClipped, true); + getCurrentMonitorPositions (monitorCoordsUnclipped, false); jassert (monitorCoordsClipped.size() == monitorCoordsUnclipped.size()); if (oldClipped != monitorCoordsClipped diff --git a/src/gui/components/juce_Desktop.h b/src/gui/components/juce_Desktop.h index e067c5bd4e..49425767bd 100644 --- a/src/gui/components/juce_Desktop.h +++ b/src/gui/components/juce_Desktop.h @@ -377,6 +377,7 @@ private: int getNumDisplayMonitors() const throw(); const Rectangle getDisplayMonitorCoordinates (int index, bool clippedToWorkArea) const throw(); + static void getCurrentMonitorPositions (Array >& monitorCoords, const bool clipToWorkArea); void addDesktopComponent (Component* c); void removeDesktopComponent (Component* c); diff --git a/src/io/network/juce_Socket.cpp b/src/io/network/juce_Socket.cpp index 3bd0506a78..ac824ac39e 100644 --- a/src/io/network/juce_Socket.cpp +++ b/src/io/network/juce_Socket.cpp @@ -26,29 +26,31 @@ #include "../../core/juce_TargetPlatform.h" #if JUCE_WINDOWS - #include - #include + #include + #include - #if JUCE_MSVC - #pragma warning (push) - #pragma warning (disable : 4127 4389 4018) - #endif + #if JUCE_MSVC + #pragma warning (push) + #pragma warning (disable : 4127 4389 4018) + #endif #else - #if JUCE_LINUX || JUCE_ANDROID - #include - #include - #include - #include - #include - #elif (MACOSX_DEPLOYMENT_TARGET <= MAC_OS_X_VERSION_10_4) && ! JUCE_IOS - #include - #endif + #if JUCE_LINUX || JUCE_ANDROID + #include + #include + #include + #include + #include + #endif - #include - #include - #include - #include + #include + #include + #include + #include + + #ifndef AI_NUMERICSERV // (missing in older Mac SDKs) + #define AI_NUMERICSERV 0x1000 + #endif #endif #include "../../core/juce_StandardHeader.h" @@ -59,48 +61,42 @@ BEGIN_JUCE_NAMESPACE #include "../../threads/juce_ScopedLock.h" #include "../../threads/juce_Thread.h" -#if JUCE_LINUX || JUCE_MAC || JUCE_IOS || JUCE_ANDROID - typedef socklen_t juce_socklen_t; +#if JUCE_WINDOWS + typedef int juce_socklen_t; #else - typedef int juce_socklen_t; + typedef socklen_t juce_socklen_t; #endif - //============================================================================== -#if JUCE_WINDOWS - namespace SocketHelpers { - typedef int (__stdcall juce_CloseWin32SocketLibCall) (void); - static juce_CloseWin32SocketLibCall* juce_CloseWin32SocketLib = 0; - - void initWin32Sockets() + #if JUCE_WINDOWS + class WinSocketStarter : public DeletedAtShutdown { - static CriticalSection lock; - const ScopedLock sl (lock); - - if (SocketHelpers::juce_CloseWin32SocketLib == 0) + public: + WinSocketStarter() { WSADATA wsaData; const WORD wVersionRequested = MAKEWORD (1, 1); WSAStartup (wVersionRequested, &wsaData); - - SocketHelpers::juce_CloseWin32SocketLib = &WSACleanup; } - } -} -void juce_shutdownWin32Sockets() -{ - if (SocketHelpers::juce_CloseWin32SocketLib != 0) - (*SocketHelpers::juce_CloseWin32SocketLib)(); -} + ~WinSocketStarter() + { + WSACleanup(); + clearSingletonInstance(); + } -#endif + juce_DeclareSingleton (WinSocketStarter, false); + }; + + juce_ImplementSingleton (WinSocketStarter); + + void initSockets() { WinSocketStarter::getInstance(); } + #else + void initSockets() {} + #endif -//============================================================================== -namespace SocketHelpers -{ bool resetSocketOptions (const int handle, const bool isDatagram, const bool allowBroadcast) throw() { const int sndBufSize = 65536; @@ -139,15 +135,15 @@ namespace SocketHelpers { int bytesThisTime; - #if JUCE_WINDOWS + #if JUCE_WINDOWS bytesThisTime = recv (handle, static_cast (destBuffer) + bytesRead, maxBytesToRead - bytesRead, 0); - #else + #else while ((bytesThisTime = (int) ::read (handle, addBytesToPointer (destBuffer, bytesRead), maxBytesToRead - bytesRead)) < 0 && errno == EINTR && connected) { } - #endif + #endif if (bytesThisTime <= 0 || ! connected) { @@ -191,10 +187,10 @@ namespace SocketHelpers fd_set* const prset = forReading ? &rset : 0; fd_set* const pwset = forReading ? 0 : &wset; - #if JUCE_WINDOWS + #if JUCE_WINDOWS if (select (handle + 1, prset, pwset, 0, timeoutp) < 0) return -1; - #else + #else { int result; while ((result = select (handle + 1, prset, pwset, 0, timeoutp)) < 0 @@ -205,7 +201,7 @@ namespace SocketHelpers if (result < 0) return -1; } - #endif + #endif { int opt; @@ -216,21 +212,15 @@ namespace SocketHelpers return -1; } - if ((forReading && FD_ISSET (handle, &rset)) - || ((! forReading) && FD_ISSET (handle, &wset))) - return 1; - - return 0; + return FD_ISSET (handle, forReading ? &rset : &wset) ? 1 : 0; } bool setSocketBlockingState (const int handle, const bool shouldBlock) throw() { - #if JUCE_WINDOWS + #if JUCE_WINDOWS u_long nonBlocking = shouldBlock ? 0 : 1; - - if (ioctlsocket (handle, FIONBIO, &nonBlocking) != 0) - return false; - #else + return ioctlsocket (handle, FIONBIO, &nonBlocking) == 0; + #else int socketFlags = fcntl (handle, F_GETFL, 0); if (socketFlags == -1) @@ -241,11 +231,8 @@ namespace SocketHelpers else socketFlags |= O_NONBLOCK; - if (fcntl (handle, F_SETFL, socketFlags) != 0) - return false; - #endif - - return true; + return fcntl (handle, F_SETFL, socketFlags) == 0; + #endif } bool connectSocket (int volatile& handle, @@ -318,9 +305,7 @@ StreamingSocket::StreamingSocket() connected (false), isListener (false) { -#if JUCE_WINDOWS - SocketHelpers::initWin32Sockets(); -#endif + SocketHelpers::initSockets(); } StreamingSocket::StreamingSocket (const String& hostName_, @@ -332,10 +317,7 @@ StreamingSocket::StreamingSocket (const String& hostName_, connected (true), isListener (false) { -#if JUCE_WINDOWS - SocketHelpers::initWin32Sockets(); -#endif - + SocketHelpers::initSockets(); SocketHelpers::resetSocketOptions (handle_, false, false); } @@ -356,9 +338,9 @@ int StreamingSocket::write (const void* sourceBuffer, const int numBytesToWrite) if (isListener || ! connected) return -1; -#if JUCE_WINDOWS + #if JUCE_WINDOWS return send (handle, (const char*) sourceBuffer, numBytesToWrite, 0); -#else + #else int result; while ((result = (int) ::write (handle, sourceBuffer, numBytesToWrite)) < 0 @@ -367,7 +349,7 @@ int StreamingSocket::write (const void* sourceBuffer, const int numBytesToWrite) } return result; -#endif + #endif } //============================================================================== @@ -415,12 +397,12 @@ bool StreamingSocket::connect (const String& remoteHostName, void StreamingSocket::close() { -#if JUCE_WINDOWS + #if JUCE_WINDOWS if (handle != SOCKET_ERROR || connected) closesocket (handle); connected = false; -#else + #else if (connected) { connected = false; @@ -435,7 +417,7 @@ void StreamingSocket::close() if (handle != -1) ::close (handle); -#endif + #endif hostName = String::empty; portNumber = 0; @@ -516,9 +498,7 @@ DatagramSocket::DatagramSocket (const int localPortNumber, const bool allowBroad allowBroadcast (allowBroadcast_), serverAddress (0) { -#if JUCE_WINDOWS - SocketHelpers::initWin32Sockets(); -#endif + SocketHelpers::initSockets(); handle = (int) socket (AF_INET, SOCK_DGRAM, 0); bindToPort (localPortNumber); @@ -533,9 +513,7 @@ DatagramSocket::DatagramSocket (const String& hostName_, const int portNumber_, allowBroadcast (false), serverAddress (0) { -#if JUCE_WINDOWS - SocketHelpers::initWin32Sockets(); -#endif + SocketHelpers::initSockets(); SocketHelpers::resetSocketOptions (handle_, true, allowBroadcast); bindToPort (localPortNumber); @@ -551,13 +529,13 @@ DatagramSocket::~DatagramSocket() void DatagramSocket::close() { -#if JUCE_WINDOWS + #if JUCE_WINDOWS closesocket (handle); connected = false; -#else + #else connected = false; ::close (handle); -#endif + #endif hostName = String::empty; portNumber = 0; @@ -644,7 +622,7 @@ bool DatagramSocket::isLocal() const throw() } #if JUCE_MSVC - #pragma warning (pop) + #pragma warning (pop) #endif END_JUCE_NAMESPACE diff --git a/src/native/android/juce_android_Windowing.cpp b/src/native/android/juce_android_Windowing.cpp index 063818c611..6f4923f189 100644 --- a/src/native/android/juce_android_Windowing.cpp +++ b/src/native/android/juce_android_Windowing.cpp @@ -617,7 +617,7 @@ void juce_setKioskComponent (Component* kioskModeComponent, bool enableOrDisable } //============================================================================== -void juce_updateMultiMonitorInfo (Array >& monitorCoords, const bool clipToWorkArea) +void Desktop::getCurrentMonitorPositions (Array >& monitorCoords, const bool clipToWorkArea) { monitorCoords.add (Rectangle (0, 0, android.screenWidth, android.screenHeight)); } diff --git a/src/native/linux/juce_linux_Windowing.cpp b/src/native/linux/juce_linux_Windowing.cpp index 7c990cc086..589535cf69 100644 --- a/src/native/linux/juce_linux_Windowing.cpp +++ b/src/native/linux/juce_linux_Windowing.cpp @@ -2690,7 +2690,7 @@ void juce_windowMessageReceive (XEvent* event) } //============================================================================== -void juce_updateMultiMonitorInfo (Array >& monitorCoords, const bool /*clipToWorkArea*/) +void Desktop::getCurrentMonitorPositions (Array >& monitorCoords, const bool /*clipToWorkArea*/) { if (display == 0) return; diff --git a/src/native/mac/juce_ios_UIViewComponentPeer.mm b/src/native/mac/juce_ios_UIViewComponentPeer.mm index 2e2c16f09c..31a21ea255 100644 --- a/src/native/mac/juce_ios_UIViewComponentPeer.mm +++ b/src/native/mac/juce_ios_UIViewComponentPeer.mm @@ -992,7 +992,7 @@ Desktop::DisplayOrientation Desktop::getCurrentOrientation() const return convertToJuceOrientation ([[UIApplication sharedApplication] statusBarOrientation]); } -void juce_updateMultiMonitorInfo (Array >& monitorCoords, const bool clipToWorkArea) +void Desktop::getCurrentMonitorPositions (Array >& monitorCoords, const bool clipToWorkArea) { const ScopedAutoReleasePool pool; monitorCoords.clear(); diff --git a/src/native/mac/juce_mac_MiscUtilities.mm b/src/native/mac/juce_mac_MiscUtilities.mm index b2369770cc..6109b76c16 100644 --- a/src/native/mac/juce_mac_MiscUtilities.mm +++ b/src/native/mac/juce_mac_MiscUtilities.mm @@ -218,13 +218,13 @@ void Desktop::setScreenSaverEnabled (const bool isEnabled) { if (screenSaverDisablerID == 0) { -#if defined (MAC_OS_X_VERSION_10_6) && MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_6 + #if defined (MAC_OS_X_VERSION_10_6) && MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_6 IOPMAssertionCreateWithName (kIOPMAssertionTypeNoIdleSleep, kIOPMAssertionLevelOn, CFSTR ("Juce"), &screenSaverDisablerID); -#else + #else IOPMAssertionCreate (kIOPMAssertionTypeNoIdleSleep, kIOPMAssertionLevelOn, &screenSaverDisablerID); -#endif + #endif } } } @@ -237,9 +237,39 @@ bool Desktop::isScreenSaverEnabled() #endif //============================================================================== -void juce_updateMultiMonitorInfo (Array >& monitorCoords, const bool clipToWorkArea) +class DisplaySettingsChangeCallback : public DeletedAtShutdown +{ +public: + DisplaySettingsChangeCallback() + { + CGDisplayRegisterReconfigurationCallback (displayReconfigurationCallBack, 0); + } + + ~DisplaySettingsChangeCallback() + { + CGDisplayRemoveReconfigurationCallback (displayReconfigurationCallBack, 0); + clearSingletonInstance(); + } + + static void displayReconfigurationCallBack (CGDirectDisplayID, CGDisplayChangeSummaryFlags, void*) + { + Desktop::getInstance().refreshMonitorSizes(); + } + + juce_DeclareSingleton_SingleThreaded_Minimal (DisplaySettingsChangeCallback); + +private: + JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (DisplaySettingsChangeCallback); +}; + +juce_ImplementSingleton_SingleThreaded (DisplaySettingsChangeCallback); + +void Desktop::getCurrentMonitorPositions (Array >& monitorCoords, const bool clipToWorkArea) { const ScopedAutoReleasePool pool; + + DisplaySettingsChangeCallback::getInstance(); + monitorCoords.clear(); NSArray* screens = [NSScreen screens]; const CGFloat mainScreenBottom = [[[NSScreen screens] objectAtIndex: 0] frame].size.height; @@ -259,7 +289,5 @@ void juce_updateMultiMonitorInfo (Array >& monitorCoords, const jassert (monitorCoords.size() > 0); } - #endif - #endif diff --git a/src/native/windows/juce_win32_Windowing.cpp b/src/native/windows/juce_win32_Windowing.cpp index cc4b2b994a..43b3e9d955 100644 --- a/src/native/windows/juce_win32_Windowing.cpp +++ b/src/native/windows/juce_win32_Windowing.cpp @@ -2556,7 +2556,7 @@ static BOOL CALLBACK enumMonitorsProc (HMONITOR, HDC, LPRECT r, LPARAM userInfo) return TRUE; } -void juce_updateMultiMonitorInfo (Array >& monitorCoords, const bool clipToWorkArea) +void Desktop::getCurrentMonitorPositions (Array >& monitorCoords, const bool clipToWorkArea) { EnumDisplayMonitors (0, 0, &enumMonitorsProc, (LPARAM) &monitorCoords);