Minor OSX RTAS fix


#1

Hi

I noticed, that RTAS wrapper on OSX is missing the part of the code that intercepts hide/show window events, so when you hide ProTools window (I mean “hide” not minimize), the juce plugin window will stay on desktop.
The missing parts seem to be (in juce_RTAS_MacUtilities.mm) :

attachSubWindow()

const EventTypeSpec eventsToCatch[] = {
      { kEventClassWindow, kEventWindowShown },
      { kEventClassWindow, kEventWindowHidden }
    };
EventHandlerRef ref;
  
InstallWindowEventHandler ((WindowRef) hostWindowRef,
                             NewEventHandlerUPP (windowVisibilityBodge),
                             GetEventTypeCount (eventsToCatch), eventsToCatch,
                             (void*) hostWindow, &ref);
comp->getProperties().set ("carbonEventRef", String::toHexString ((pointer_sized_int) (void*) ref));

removeSubWindow()

EventHandlerRef ref = (EventHandlerRef) (void*) (pointer_sized_int)
ref = (EventHandlerRef) (void*) (pointer_sized_int) comp->getProperties() ["carbonEventRef"].toString().getHexValue64();

RemoveEventHandler (ref);

and additional windowVisibilityBodge() function

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;
} 

cheers,
Bart :wink:


#2

Ok… so you’ve used the same bodge as the VST code uses… (I should probably think about moving that duplicated code into some kind of shared header). Thanks Bart, I’ll see what I can do.