|
|
|
@@ -83,29 +83,7 @@ namespace juce |
|
|
|
|
|
|
|
JUCE_AUTORELEASEPOOL
|
|
|
|
{
|
|
|
|
#if JUCE_64BIT
|
|
|
|
NSView* parentView = (NSView*) windowRef;
|
|
|
|
|
|
|
|
#if JucePlugin_EditorRequiresKeyboardFocus
|
|
|
|
comp->addToDesktop (0, parentView);
|
|
|
|
#else
|
|
|
|
comp->addToDesktop (ComponentPeer::windowIgnoresKeyPresses, parentView);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
// (this workaround is because Wavelab provides a zero-size parent view..)
|
|
|
|
if ([parentView frame].size.height == 0)
|
|
|
|
[((NSView*) comp->getWindowHandle()) setFrameOrigin: NSZeroPoint];
|
|
|
|
|
|
|
|
comp->setVisible (true);
|
|
|
|
comp->toFront (false);
|
|
|
|
|
|
|
|
[[parentView window] setAcceptsMouseMovedEvents: YES];
|
|
|
|
return parentView;
|
|
|
|
|
|
|
|
#else
|
|
|
|
//treat NSView like 64bit
|
|
|
|
if (! isHIView)
|
|
|
|
{
|
|
|
|
#if JUCE_64BIT
|
|
|
|
NSView* parentView = (NSView*) windowRef;
|
|
|
|
|
|
|
|
#if JucePlugin_EditorRequiresKeyboardFocus
|
|
|
|
@@ -123,75 +101,96 @@ namespace juce |
|
|
|
|
|
|
|
[[parentView window] setAcceptsMouseMovedEvents: YES];
|
|
|
|
return parentView;
|
|
|
|
}
|
|
|
|
|
|
|
|
NSWindow* hostWindow = [[NSWindow alloc] initWithWindowRef: windowRef];
|
|
|
|
[hostWindow retain];
|
|
|
|
[hostWindow setCanHide: YES];
|
|
|
|
[hostWindow setReleasedWhenClosed: YES];
|
|
|
|
#else
|
|
|
|
//treat NSView like 64bit
|
|
|
|
if (! isHIView)
|
|
|
|
{
|
|
|
|
NSView* parentView = (NSView*) windowRef;
|
|
|
|
|
|
|
|
HIViewRef parentView = nullptr;
|
|
|
|
#if JucePlugin_EditorRequiresKeyboardFocus
|
|
|
|
comp->addToDesktop (0, parentView);
|
|
|
|
#else
|
|
|
|
comp->addToDesktop (ComponentPeer::windowIgnoresKeyPresses, parentView);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
WindowAttributes attributes;
|
|
|
|
GetWindowAttributes ((WindowRef) windowRef, &attributes);
|
|
|
|
// (this workaround is because Wavelab provides a zero-size parent view..)
|
|
|
|
if ([parentView frame].size.height == 0)
|
|
|
|
[((NSView*) comp->getWindowHandle()) setFrameOrigin: NSZeroPoint];
|
|
|
|
|
|
|
|
if ((attributes & kWindowCompositingAttribute) != 0)
|
|
|
|
{
|
|
|
|
HIViewRef root = HIViewGetRoot ((WindowRef) windowRef);
|
|
|
|
HIViewFindByID (root, kHIViewWindowContentID, &parentView);
|
|
|
|
comp->setVisible (true);
|
|
|
|
comp->toFront (false);
|
|
|
|
|
|
|
|
if (parentView == nullptr)
|
|
|
|
parentView = root;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
GetRootControl ((WindowRef) windowRef, (ControlRef*) &parentView);
|
|
|
|
[[parentView window] setAcceptsMouseMovedEvents: YES];
|
|
|
|
return parentView;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (parentView == nullptr)
|
|
|
|
CreateRootControl ((WindowRef) windowRef, (ControlRef*) &parentView);
|
|
|
|
}
|
|
|
|
NSWindow* hostWindow = [[NSWindow alloc] initWithWindowRef: windowRef];
|
|
|
|
[hostWindow retain];
|
|
|
|
[hostWindow setCanHide: YES];
|
|
|
|
[hostWindow setReleasedWhenClosed: YES];
|
|
|
|
|
|
|
|
// It seems that the only way to successfully position our overlaid window is by putting a dummy
|
|
|
|
// HIView into the host's carbon window, and then catching events to see when it gets repositioned
|
|
|
|
HIViewRef dummyView = 0;
|
|
|
|
HIImageViewCreate (0, &dummyView);
|
|
|
|
HIRect r = { {0, 0}, { (float) comp->getWidth(), (float) comp->getHeight()} };
|
|
|
|
HIViewSetFrame (dummyView, &r);
|
|
|
|
HIViewAddSubview (parentView, dummyView);
|
|
|
|
comp->getProperties().set ("dummyViewRef", String::toHexString ((pointer_sized_int) (void*) dummyView));
|
|
|
|
HIViewRef parentView = nullptr;
|
|
|
|
|
|
|
|
EventHandlerRef ref;
|
|
|
|
const EventTypeSpec kControlBoundsChangedEvent = { kEventClassControl, kEventControlBoundsChanged };
|
|
|
|
InstallEventHandler (GetControlEventTarget (dummyView), NewEventHandlerUPP (viewBoundsChangedEvent), 1, &kControlBoundsChangedEvent, (void*) comp, &ref);
|
|
|
|
comp->getProperties().set ("boundsEventRef", String::toHexString ((pointer_sized_int) (void*) ref));
|
|
|
|
WindowAttributes attributes;
|
|
|
|
GetWindowAttributes ((WindowRef) windowRef, &attributes);
|
|
|
|
|
|
|
|
updateComponentPos (comp);
|
|
|
|
if ((attributes & kWindowCompositingAttribute) != 0)
|
|
|
|
{
|
|
|
|
HIViewRef root = HIViewGetRoot ((WindowRef) windowRef);
|
|
|
|
HIViewFindByID (root, kHIViewWindowContentID, &parentView);
|
|
|
|
|
|
|
|
#if ! JucePlugin_EditorRequiresKeyboardFocus
|
|
|
|
comp->addToDesktop (ComponentPeer::windowIsTemporary | ComponentPeer::windowIgnoresKeyPresses);
|
|
|
|
#else
|
|
|
|
comp->addToDesktop (ComponentPeer::windowIsTemporary);
|
|
|
|
#endif
|
|
|
|
if (parentView == nullptr)
|
|
|
|
parentView = root;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
GetRootControl ((WindowRef) windowRef, (ControlRef*) &parentView);
|
|
|
|
|
|
|
|
comp->setVisible (true);
|
|
|
|
comp->toFront (false);
|
|
|
|
if (parentView == nullptr)
|
|
|
|
CreateRootControl ((WindowRef) windowRef, (ControlRef*) &parentView);
|
|
|
|
}
|
|
|
|
|
|
|
|
NSView* pluginView = (NSView*) comp->getWindowHandle();
|
|
|
|
NSWindow* pluginWindow = [pluginView window];
|
|
|
|
[pluginWindow setExcludedFromWindowsMenu: YES];
|
|
|
|
[pluginWindow setCanHide: YES];
|
|
|
|
// It seems that the only way to successfully position our overlaid window is by putting a dummy
|
|
|
|
// HIView into the host's carbon window, and then catching events to see when it gets repositioned
|
|
|
|
HIViewRef dummyView = 0;
|
|
|
|
HIImageViewCreate (0, &dummyView);
|
|
|
|
HIRect r = { {0, 0}, { (float) comp->getWidth(), (float) comp->getHeight()} };
|
|
|
|
HIViewSetFrame (dummyView, &r);
|
|
|
|
HIViewAddSubview (parentView, dummyView);
|
|
|
|
comp->getProperties().set ("dummyViewRef", String::toHexString ((pointer_sized_int) (void*) dummyView));
|
|
|
|
|
|
|
|
[hostWindow addChildWindow: pluginWindow
|
|
|
|
ordered: NSWindowAbove];
|
|
|
|
[hostWindow orderFront: nil];
|
|
|
|
[pluginWindow orderFront: nil];
|
|
|
|
EventHandlerRef ref;
|
|
|
|
const EventTypeSpec kControlBoundsChangedEvent = { kEventClassControl, kEventControlBoundsChanged };
|
|
|
|
InstallEventHandler (GetControlEventTarget (dummyView), NewEventHandlerUPP (viewBoundsChangedEvent), 1, &kControlBoundsChangedEvent, (void*) comp, &ref);
|
|
|
|
comp->getProperties().set ("boundsEventRef", String::toHexString ((pointer_sized_int) (void*) ref));
|
|
|
|
|
|
|
|
attachWindowHidingHooks (comp, (WindowRef) windowRef, hostWindow);
|
|
|
|
updateComponentPos (comp);
|
|
|
|
|
|
|
|
return hostWindow;
|
|
|
|
#endif
|
|
|
|
#if ! JucePlugin_EditorRequiresKeyboardFocus
|
|
|
|
comp->addToDesktop (ComponentPeer::windowIsTemporary | ComponentPeer::windowIgnoresKeyPresses);
|
|
|
|
#else
|
|
|
|
comp->addToDesktop (ComponentPeer::windowIsTemporary);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
}
|
|
|
|
comp->setVisible (true);
|
|
|
|
comp->toFront (false);
|
|
|
|
|
|
|
|
NSView* pluginView = (NSView*) comp->getWindowHandle();
|
|
|
|
NSWindow* pluginWindow = [pluginView window];
|
|
|
|
[pluginWindow setExcludedFromWindowsMenu: YES];
|
|
|
|
[pluginWindow setCanHide: YES];
|
|
|
|
|
|
|
|
[hostWindow addChildWindow: pluginWindow
|
|
|
|
ordered: NSWindowAbove];
|
|
|
|
[hostWindow orderFront: nil];
|
|
|
|
[pluginWindow orderFront: nil];
|
|
|
|
|
|
|
|
attachWindowHidingHooks (comp, (WindowRef) windowRef, hostWindow);
|
|
|
|
|
|
|
|
return hostWindow;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void detachComponentFromWindowRef (Component* comp, void* nsWindow, bool isHIView)
|
|
|
|
|