| @@ -51,6 +51,8 @@ | |||
| class JuceAUView; | |||
| #endif | |||
| #define JUCE_MAC_WINDOW_VISIBITY_BODGE 1 | |||
| #include "../juce_PluginHeaders.h" | |||
| #include "../juce_PluginHostType.h" | |||
| @@ -1251,23 +1253,15 @@ private: | |||
| NSWindow* pluginWindow = [((NSView*) getWindowHandle()) window]; | |||
| [pluginWindow setNextResponder: hostWindow]; | |||
| // Adds a callback bodge to work around some problems with wrapped | |||
| // carbon windows.. | |||
| const EventTypeSpec eventsToCatch[] = { | |||
| { kEventClassWindow, kEventWindowShown }, | |||
| { kEventClassWindow, kEventWindowHidden } | |||
| }; | |||
| InstallWindowEventHandler ((WindowRef) windowRef, | |||
| NewEventHandlerUPP (windowVisibilityBodge), | |||
| GetEventTypeCount (eventsToCatch), eventsToCatch, | |||
| (void*) hostWindow, 0); | |||
| attachWindowHidingHooks (this, (WindowRef) windowRef, hostWindow); | |||
| } | |||
| ~ComponentInHIView() | |||
| { | |||
| JUCE_AUTORELEASEPOOL | |||
| removeWindowHidingHooks (this); | |||
| NSWindow* pluginWindow = [((NSView*) getWindowHandle()) window]; | |||
| [hostWindow removeChildWindow: pluginWindow]; | |||
| removeFromDesktop(); | |||
| @@ -1353,27 +1347,6 @@ private: | |||
| NSWindow* hostWindow; | |||
| EditorCompHolder editor; | |||
| bool recursive; | |||
| /* When you wrap a WindowRef as an NSWindow, it seems to bugger up the HideWindow | |||
| function, so when the host tries (and fails) to hide the window, this catches | |||
| the event and does the job properly. | |||
| */ | |||
| static pascal OSStatus windowVisibilityBodge (EventHandlerCallRef, EventRef e, void* user) | |||
| { | |||
| NSWindow* hostWindow = (NSWindow*) user; | |||
| switch (GetEventKind (e)) | |||
| { | |||
| case kEventWindowShown: | |||
| [hostWindow orderFront: nil]; | |||
| break; | |||
| case kEventWindowHidden: | |||
| [hostWindow orderOut: nil]; | |||
| break; | |||
| } | |||
| return eventNotHandledErr; | |||
| } | |||
| }; | |||
| }; | |||
| @@ -31,9 +31,10 @@ | |||
| // Horrible carbon-based fix for a cocoa bug, where an NSWindow that wraps a carbon | |||
| // window fails to keep its position updated when the user drags the window around.. | |||
| #define WINDOWPOSITON_BODGE 1 | |||
| #define WINDOWPOSITION_BODGE 1 | |||
| #define JUCE_MAC_WINDOW_VISIBITY_BODGE 1 | |||
| #if WINDOWPOSITON_BODGE | |||
| #if WINDOWPOSITION_BODGE | |||
| #include <Carbon/Carbon.h> | |||
| #endif | |||
| @@ -68,7 +69,7 @@ void* attachSubWindow (void* hostWindowRef, Component* comp) | |||
| NSRect hostWindowScreenFrame = [[hostWindow screen] frame]; | |||
| #if WINDOWPOSITON_BODGE | |||
| #if WINDOWPOSITION_BODGE | |||
| { | |||
| Rect winBounds; | |||
| GetWindowBounds ((WindowRef) hostWindowRef, kWindowContentRgn, &winBounds); | |||
| @@ -77,7 +78,7 @@ void* attachSubWindow (void* hostWindowRef, Component* comp) | |||
| w.origin.y = hostWindowScreenFrame.size.height + hostWindowScreenFrame.origin.y - winBounds.bottom; | |||
| [hostWindow setFrame: w display: NO animate: NO]; | |||
| } | |||
| #endif | |||
| #endif | |||
| NSPoint windowPos = [hostWindow convertBaseToScreen: f.origin]; | |||
| windowPos.x = windowPos.x + jmax (0.0f, (oldWindowFrame.size.width - f.size.width) / 2.0f); | |||
| @@ -85,11 +86,11 @@ void* attachSubWindow (void* hostWindowRef, Component* comp) | |||
| comp->setTopLeftPosition ((int) windowPos.x, (int) windowPos.y); | |||
| #if ! JucePlugin_EditorRequiresKeyboardFocus | |||
| #if ! JucePlugin_EditorRequiresKeyboardFocus | |||
| comp->addToDesktop (ComponentPeer::windowIsTemporary | ComponentPeer::windowIgnoresKeyPresses); | |||
| #else | |||
| #else | |||
| comp->addToDesktop (ComponentPeer::windowIsTemporary); | |||
| #endif | |||
| #endif | |||
| comp->setVisible (true); | |||
| @@ -100,6 +101,9 @@ void* attachSubWindow (void* hostWindowRef, Component* comp) | |||
| ordered: NSWindowAbove]; | |||
| [hostWindow orderFront: nil]; | |||
| [pluginWindow orderFront: nil]; | |||
| attachWindowHidingHooks (comp, (WindowRef) hostWindowRef, hostWindow); | |||
| return hostWindow; | |||
| } | |||
| @@ -111,6 +115,7 @@ void removeSubWindow (void* nsWindow, Component* comp) | |||
| NSWindow* hostWindow = (NSWindow*) nsWindow; | |||
| NSWindow* pluginWindow = [pluginView window]; | |||
| removeWindowHidingHooks (comp); | |||
| [hostWindow removeChildWindow: pluginWindow]; | |||
| comp->removeFromDesktop(); | |||
| [hostWindow release]; | |||
| @@ -31,6 +31,8 @@ | |||
| #include <Cocoa/Cocoa.h> | |||
| #include <Carbon/Carbon.h> | |||
| #define JUCE_MAC_WINDOW_VISIBITY_BODGE 1 | |||
| #include "../juce_PluginHeaders.h" | |||
| #include "../juce_PluginHostType.h" | |||
| @@ -41,33 +43,6 @@ | |||
| //============================================================================== | |||
| BEGIN_JUCE_NAMESPACE | |||
| #if ADD_CARBON_BODGE | |||
| /* When you wrap a WindowRef as an NSWindow, it seems to bugger up the HideWindow | |||
| function, so when the host tries (and fails) to hide the window, this catches | |||
| the event and does the job properly. | |||
| */ | |||
| static pascal OSStatus windowVisibilityBodge (EventHandlerCallRef, EventRef e, void* user) | |||
| { | |||
| NSWindow* hostWindow = (NSWindow*) user; | |||
| switch (GetEventKind (e)) | |||
| { | |||
| case kEventWindowInit: | |||
| [hostWindow display]; | |||
| break; | |||
| case kEventWindowShown: | |||
| [hostWindow orderFront: nil]; | |||
| break; | |||
| case kEventWindowHidden: | |||
| [hostWindow orderOut: nil]; | |||
| break; | |||
| } | |||
| return eventNotHandledErr; | |||
| } | |||
| #endif | |||
| static void updateComponentPos (Component* const comp) | |||
| { | |||
| HIViewRef dummyView = (HIViewRef) (void*) (pointer_sized_int) | |||
| @@ -176,23 +151,7 @@ void* attachComponentToWindowRef (Component* comp, void* windowRef) | |||
| [hostWindow orderFront: nil]; | |||
| [pluginWindow orderFront: nil]; | |||
| #if ADD_CARBON_BODGE | |||
| { | |||
| // Adds a callback bodge to work around some problems with wrapped | |||
| // carbon windows.. | |||
| const EventTypeSpec eventsToCatch[] = { | |||
| { kEventClassWindow, kEventWindowInit }, | |||
| { kEventClassWindow, kEventWindowShown }, | |||
| { kEventClassWindow, kEventWindowHidden } | |||
| }; | |||
| InstallWindowEventHandler ((WindowRef) windowRef, | |||
| NewEventHandlerUPP (windowVisibilityBodge), | |||
| GetEventTypeCount (eventsToCatch), eventsToCatch, | |||
| (void*) hostWindow, &ref); | |||
| comp->getProperties().set ("carbonEventRef", String::toHexString ((pointer_sized_int) (void*) ref)); | |||
| } | |||
| #endif | |||
| attachWindowHidingHooks (comp, (WindowRef) windowRef, hostWindow); | |||
| return hostWindow; | |||
| #endif | |||
| @@ -210,11 +169,7 @@ void detachComponentFromWindowRef (Component* comp, void* nsWindow) | |||
| comp->getProperties() ["boundsEventRef"].toString().getHexValue64(); | |||
| RemoveEventHandler (ref); | |||
| #if ADD_CARBON_BODGE | |||
| ref = (EventHandlerRef) (void*) (pointer_sized_int) | |||
| comp->getProperties() ["carbonEventRef"].toString().getHexValue64(); | |||
| RemoveEventHandler (ref); | |||
| #endif | |||
| removeWindowHidingHooks (comp); | |||
| HIViewRef dummyView = (HIViewRef) (void*) (pointer_sized_int) | |||
| comp->getProperties() ["dummyViewRef"].toString().getHexValue64(); | |||
| @@ -31,6 +31,7 @@ | |||
| #if JUCE_MAC && JUCE_SUPPORT_CARBON | |||
| //============================================================================== | |||
| // Helper class to workaround carbon windows not getting mouse-moves.. | |||
| class FakeMouseMoveGenerator : public Timer | |||
| { | |||
| @@ -73,4 +74,57 @@ private: | |||
| struct FakeMouseMoveGenerator {}; | |||
| #endif | |||
| //============================================================================== | |||
| #if JUCE_SUPPORT_CARBON && JUCE_MAC_WINDOW_VISIBITY_BODGE | |||
| /* When you wrap a WindowRef as an NSWindow, it seems to bugger up the HideWindow | |||
| function, so when the host tries (and fails) to hide the window, this stuff catches | |||
| the event and forces it to update. | |||
| */ | |||
| static pascal OSStatus windowVisibilityBodge (EventHandlerCallRef, EventRef e, void* user) | |||
| { | |||
| NSWindow* hostWindow = (NSWindow*) user; | |||
| switch (GetEventKind (e)) | |||
| { | |||
| case kEventWindowInit: [hostWindow display]; break; | |||
| case kEventWindowShown: [hostWindow orderFront: nil]; break; | |||
| case kEventWindowHidden: [hostWindow orderOut: nil]; break; | |||
| } | |||
| return eventNotHandledErr; | |||
| } | |||
| static void attachWindowHidingHooks (Component* comp, void* hostWindowRef, NSWindow* nsWindow) | |||
| { | |||
| const EventTypeSpec eventsToCatch[] = | |||
| { | |||
| { kEventClassWindow, kEventWindowInit }, | |||
| { kEventClassWindow, kEventWindowShown }, | |||
| { kEventClassWindow, kEventWindowHidden } | |||
| }; | |||
| EventHandlerRef ref; | |||
| InstallWindowEventHandler ((WindowRef) hostWindowRef, | |||
| NewEventHandlerUPP (windowVisibilityBodge), | |||
| GetEventTypeCount (eventsToCatch), eventsToCatch, | |||
| (void*) nsWindow, &ref); | |||
| comp->getProperties().set ("carbonEventRef", String::toHexString ((pointer_sized_int) (void*) ref)); | |||
| } | |||
| static void removeWindowHidingHooks (Component* comp) | |||
| { | |||
| if (comp != nullptr) | |||
| RemoveEventHandler ((EventHandlerRef) (void*) (pointer_sized_int) | |||
| comp->getProperties() ["carbonEventRef"].toString().getHexValue64()); | |||
| } | |||
| #else | |||
| static void attachWindowHidingHooks (void*, void*, void*) {} | |||
| static void removeWindowHidingHooks (void*) {} | |||
| #endif | |||
| #endif | |||
| @@ -73,7 +73,7 @@ namespace JuceDummyNamespace {} | |||
| */ | |||
| #define JUCE_MAJOR_VERSION 1 | |||
| #define JUCE_MINOR_VERSION 53 | |||
| #define JUCE_BUILDNUMBER 70 | |||
| #define JUCE_BUILDNUMBER 71 | |||
| /** Current Juce version number. | |||
| @@ -33,7 +33,7 @@ | |||
| */ | |||
| #define JUCE_MAJOR_VERSION 1 | |||
| #define JUCE_MINOR_VERSION 53 | |||
| #define JUCE_BUILDNUMBER 70 | |||
| #define JUCE_BUILDNUMBER 71 | |||
| /** Current Juce version number. | |||