| @@ -794,7 +794,7 @@ public: | |||||
| while (i.getNextEvent (midiEventData, midiEventSize, midiEventPosition)) | while (i.getNextEvent (midiEventData, midiEventSize, midiEventPosition)) | ||||
| { | { | ||||
| jassert (isPositiveAndBelow (midiEventPosition, numSamples)); | |||||
| jassert (isPositiveAndBelow (midiEventPosition, (int) numSamples)); | |||||
| @@ -99,7 +99,13 @@ public: | |||||
| /** Gives the thumbnail an AudioFormatReader to use directly. | /** Gives the thumbnail an AudioFormatReader to use directly. | ||||
| This will start parsing the audio in a background thread (unless the hash code | This will start parsing the audio in a background thread (unless the hash code | ||||
| can be looked-up successfully in the thumbnail cache). | |||||
| can be looked-up successfully in the thumbnail cache). Note that the reader | |||||
| object will be held by the thumbnail and deleted later when no longer needed. | |||||
| The thumbnail will actually keep hold of this reader until you clear the thumbnail | |||||
| or change the input source, so the file will be held open for all this time. If | |||||
| you don't want the thumbnail to keep a file handle open continuously, you | |||||
| should use the setSource() method instead, which will only open the file when | |||||
| it needs to. | |||||
| */ | */ | ||||
| void setReader (AudioFormatReader* newReader, int64 hashCode); | void setReader (AudioFormatReader* newReader, int64 hashCode); | ||||
| @@ -207,12 +207,17 @@ void Desktop::componentBroughtToFront (Component* const c) | |||||
| } | } | ||||
| //============================================================================== | //============================================================================== | ||||
| const Point<int> Desktop::getLastMouseDownPosition() throw() | |||||
| const Point<int> Desktop::getMousePosition() | |||||
| { | |||||
| return getInstance().getMainMouseSource().getScreenPosition(); | |||||
| } | |||||
| const Point<int> Desktop::getLastMouseDownPosition() | |||||
| { | { | ||||
| return getInstance().getMainMouseSource().getLastMouseDownPosition(); | return getInstance().getMainMouseSource().getLastMouseDownPosition(); | ||||
| } | } | ||||
| int Desktop::getMouseButtonClickCounter() throw() | |||||
| int Desktop::getMouseButtonClickCounter() | |||||
| { | { | ||||
| return getInstance().mouseClickCounter; | return getInstance().mouseClickCounter; | ||||
| } | } | ||||
| @@ -288,7 +293,7 @@ void Desktop::removeGlobalMouseListener (MouseListener* const listener) | |||||
| void Desktop::timerCallback() | void Desktop::timerCallback() | ||||
| { | { | ||||
| if (lastFakeMouseMove != getMousePosition()) | |||||
| if (lastFakeMouseMove != getRawMousePosition()) | |||||
| sendMouseMove(); | sendMouseMove(); | ||||
| } | } | ||||
| @@ -298,7 +303,7 @@ void Desktop::sendMouseMove() | |||||
| { | { | ||||
| startTimer (20); | startTimer (20); | ||||
| lastFakeMouseMove = getMousePosition(); | |||||
| lastFakeMouseMove = getRawMousePosition(); | |||||
| Component* const target = findComponentAt (lastFakeMouseMove); | Component* const target = findComponentAt (lastFakeMouseMove); | ||||
| @@ -326,7 +331,7 @@ void Desktop::resetTimer() | |||||
| else | else | ||||
| startTimer (100); | startTimer (100); | ||||
| lastFakeMouseMove = getMousePosition(); | |||||
| lastFakeMouseMove = getRawMousePosition(); | |||||
| } | } | ||||
| //============================================================================== | //============================================================================== | ||||
| @@ -104,6 +104,10 @@ public: | |||||
| /** Returns the mouse position. | /** Returns the mouse position. | ||||
| The co-ordinates are relative to the top-left of the main monitor. | The co-ordinates are relative to the top-left of the main monitor. | ||||
| Note that this is just a shortcut for calling getMainMouseSource().getScreenPosition(), and | |||||
| you should only resort to grabbing the global mouse position if there's really no | |||||
| way to get the coordinates via a mouse event callback instead. | |||||
| */ | */ | ||||
| static const Point<int> getMousePosition(); | static const Point<int> getMousePosition(); | ||||
| @@ -114,15 +118,20 @@ public: | |||||
| static void setMousePosition (const Point<int>& newPosition); | static void setMousePosition (const Point<int>& newPosition); | ||||
| /** Returns the last position at which a mouse button was pressed. | /** Returns the last position at which a mouse button was pressed. | ||||
| Note that this is just a shortcut for calling getMainMouseSource().getLastMouseDownPosition(), | |||||
| and in a multi-touch environment, it doesn't make much sense. ALWAYS prefer to | |||||
| get this information via other means, such as MouseEvent::getMouseDownScreenPosition() | |||||
| if possible, and only ever call this as a last resort. | |||||
| */ | */ | ||||
| static const Point<int> getLastMouseDownPosition() throw(); | |||||
| static const Point<int> getLastMouseDownPosition(); | |||||
| /** Returns the number of times the mouse button has been clicked since the | /** Returns the number of times the mouse button has been clicked since the | ||||
| app started. | app started. | ||||
| Each mouse-down event increments this number by 1. | Each mouse-down event increments this number by 1. | ||||
| */ | */ | ||||
| static int getMouseButtonClickCounter() throw(); | |||||
| static int getMouseButtonClickCounter(); | |||||
| //============================================================================== | //============================================================================== | ||||
| /** This lets you prevent the screensaver from becoming active. | /** This lets you prevent the screensaver from becoming active. | ||||
| @@ -345,6 +354,8 @@ private: | |||||
| ComponentAnimator animator; | ComponentAnimator animator; | ||||
| static const Point<int> getRawMousePosition(); | |||||
| void timerCallback(); | void timerCallback(); | ||||
| void resetTimer(); | void resetTimer(); | ||||
| @@ -1432,7 +1432,7 @@ public: | |||||
| void handleMotionNotifyEvent (const XPointerMovedEvent* const movedEvent) | void handleMotionNotifyEvent (const XPointerMovedEvent* const movedEvent) | ||||
| { | { | ||||
| updateKeyModifiers (movedEvent->state); | updateKeyModifiers (movedEvent->state); | ||||
| const Point<int> mousePos (Desktop::getMousePosition()); | |||||
| const Point<int> mousePos (movedEvent->x_root, movedEvent->y_root); | |||||
| if (lastMousePos != mousePos) | if (lastMousePos != mousePos) | ||||
| { | { | ||||
| @@ -2806,7 +2806,7 @@ bool Desktop::canUseSemiTransparentWindows() throw() | |||||
| && (matchedDepth == desiredDepth); | && (matchedDepth == desiredDepth); | ||||
| } | } | ||||
| const Point<int> Desktop::getMousePosition() | |||||
| const Point<int> Desktop::getRawMousePosition() | |||||
| { | { | ||||
| Window root, child; | Window root, child; | ||||
| int x, y, winx, winy; | int x, y, winx, winy; | ||||
| @@ -978,7 +978,7 @@ bool Desktop::canUseSemiTransparentWindows() throw() | |||||
| return true; | return true; | ||||
| } | } | ||||
| const Point<int> Desktop::getMousePosition() | |||||
| const Point<int> Desktop::getRawMousePosition() | |||||
| { | { | ||||
| return juce_lastMousePos; | return juce_lastMousePos; | ||||
| } | } | ||||
| @@ -143,7 +143,7 @@ bool Desktop::canUseSemiTransparentWindows() throw() | |||||
| return true; | return true; | ||||
| } | } | ||||
| const Point<int> Desktop::getMousePosition() | |||||
| const Point<int> Desktop::getRawMousePosition() | |||||
| { | { | ||||
| const ScopedAutoReleasePool pool; | const ScopedAutoReleasePool pool; | ||||
| const NSPoint p ([NSEvent mouseLocation]); | const NSPoint p ([NSEvent mouseLocation]); | ||||
| @@ -29,16 +29,23 @@ | |||||
| #include "juce_win32_DynamicLibraryLoader.h" | #include "juce_win32_DynamicLibraryLoader.h" | ||||
| //============================================================================== | //============================================================================== | ||||
| DynamicLibraryLoader::DynamicLibraryLoader (const String& name) | DynamicLibraryLoader::DynamicLibraryLoader (const String& name) | ||||
| : libHandle (0) | |||||
| { | { | ||||
| libHandle = LoadLibrary (name); | |||||
| load (name); | |||||
| } | } | ||||
| DynamicLibraryLoader::~DynamicLibraryLoader() | DynamicLibraryLoader::~DynamicLibraryLoader() | ||||
| { | |||||
| load (String::empty); | |||||
| } | |||||
| bool DynamicLibraryLoader::load (const String& name) | |||||
| { | { | ||||
| FreeLibrary ((HMODULE) libHandle); | FreeLibrary ((HMODULE) libHandle); | ||||
| libHandle = name.isNotEmpty() ? LoadLibrary (name) : 0; | |||||
| return libHandle != 0; | |||||
| } | } | ||||
| void* DynamicLibraryLoader::findProcAddress (const String& functionName) | void* DynamicLibraryLoader::findProcAddress (const String& functionName) | ||||
| @@ -46,5 +53,4 @@ void* DynamicLibraryLoader::findProcAddress (const String& functionName) | |||||
| return (void*) GetProcAddress ((HMODULE) libHandle, functionName.toCString()); // (void* cast is required for mingw) | return (void*) GetProcAddress ((HMODULE) libHandle, functionName.toCString()); // (void* cast is required for mingw) | ||||
| } | } | ||||
| #endif | #endif | ||||
| @@ -48,9 +48,11 @@ | |||||
| class JUCE_API DynamicLibraryLoader | class JUCE_API DynamicLibraryLoader | ||||
| { | { | ||||
| public: | public: | ||||
| DynamicLibraryLoader (const String& name); | |||||
| DynamicLibraryLoader (const String& name = String::empty); | |||||
| ~DynamicLibraryLoader(); | ~DynamicLibraryLoader(); | ||||
| bool load (const String& libraryName); | |||||
| void* findProcAddress (const String& functionName); | void* findProcAddress (const String& functionName); | ||||
| private: | private: | ||||
| @@ -2439,7 +2439,7 @@ void Desktop::createMouseInputSources() | |||||
| mouseSources.add (new MouseInputSource (0, true)); | mouseSources.add (new MouseInputSource (0, true)); | ||||
| } | } | ||||
| const Point<int> Desktop::getMousePosition() | |||||
| const Point<int> Desktop::getRawMousePosition() | |||||
| { | { | ||||
| POINT mousePos; | POINT mousePos; | ||||
| GetCursorPos (&mousePos); | GetCursorPos (&mousePos); | ||||
| @@ -122,13 +122,13 @@ void Thread::threadEntryPoint() | |||||
| JUCE_TRY | JUCE_TRY | ||||
| { | { | ||||
| jassert (getCurrentThreadId() == threadId_); | |||||
| if (threadName_.isNotEmpty()) | if (threadName_.isNotEmpty()) | ||||
| setCurrentThreadName (threadName_); | setCurrentThreadName (threadName_); | ||||
| if (startSuspensionEvent_.wait (10000)) | if (startSuspensionEvent_.wait (10000)) | ||||
| { | { | ||||
| jassert (getCurrentThreadId() == threadId_); | |||||
| if (affinityMask_ != 0) | if (affinityMask_ != 0) | ||||
| setCurrentThreadAffinityMask (affinityMask_); | setCurrentThreadAffinityMask (affinityMask_); | ||||