1
0
mirror of https://github.com/cookiengineer/audacity synced 2025-11-08 22:23:59 +01:00

More pointer madness fixes

This round fixes Mac pointers when mouse transitions from
the main project window to an open effect window in GUI
mode and back.

Not all of the cases are fixed with VST overlay windows
being the final holdout.  Couldn't figure out the cause
so will just deal with it when we convert to wx3.

(I GET TO REDO ALL OF THIS FOR WX3...WOOHOO!!!)
This commit is contained in:
lllucius@gmail.com
2014-12-15 07:59:53 +00:00
parent 9ff563419c
commit a98a0ef654
4 changed files with 261 additions and 2 deletions

View File

@@ -822,6 +822,38 @@ printf("CONTROL class %d kind %d\n", GetEventClass(event), GetEventKind(event));
}
*/
// Event handler to track when the mouse enters/exits the various view
static const EventTypeSpec trackingEventList[] =
{
{kEventClassControl, kEventControlTrackingAreaEntered},
{kEventClassControl, kEventControlTrackingAreaExited},
};
pascal OSStatus
AudioUnitEffect::TrackingEventHandler(EventHandlerCallRef handler, EventRef event, void *data)
{
return ((AudioUnitEffect *)data)->OnTrackingEvent(event);
}
OSStatus AudioUnitEffect::OnTrackingEvent(EventRef event)
{
OSStatus result = eventNotHandledErr;
if (GetEventKind(event) == kEventControlTrackingAreaEntered)
{
// Should we save the existing cursor???
SetThemeCursor(kThemeArrowCursor);
}
if (GetEventKind(event) == kEventControlTrackingAreaExited)
{
// Possibly restore a saved cursor
}
return result;
}
// Event handler to capture the window close event
static const EventTypeSpec windowEventList[] =
{
@@ -908,6 +940,11 @@ AudioUnitEffect::AudioUnitEffect(const wxString & path,
mHandlerRef = NULL;
mHandlerUPP = NULL;
mRootTrackingHandlerRef = NULL;
mContentTrackingHandlerRef = NULL;
mAUTrackingHandlerRef = NULL;
mTrackingHandlerUPP = NULL;
mEventHelper = NULL;
mEventListenerRef = NULL;
}
@@ -1769,6 +1806,16 @@ bool AudioUnitEffect::SetAutomationParameters(EffectAutomationParameters & parms
void AudioUnitEffect::SetUIHost(EffectUIHostInterface *host)
{
mUIHost = host;
mHandlerRef = 0;
mHandlerUPP = 0;
mControlHandlerRef = 0;
mControlHandlerUPP = 0;
mTrackingHandlerUPP = 0;
mRootTrackingHandlerRef = 0;
mContentTrackingHandlerRef = 0;
mAUTrackingHandlerRef = 0;
}
bool AudioUnitEffect::PopulateUI(wxWindow *parent)
@@ -1784,7 +1831,7 @@ bool AudioUnitEffect::PopulateUI(wxWindow *parent)
// Find the content view within our window
HIViewRef contentView;
HIViewFindByID(HIViewGetRoot(windowRef), kHIViewWindowContentID, &contentView);
HIViewFindByID(rootControl, kHIViewWindowContentID, &contentView);
mIsCocoa = false;
mIsCarbon = false;
@@ -1898,6 +1945,28 @@ bool AudioUnitEffect::PopulateUI(wxWindow *parent)
this,
&mControlHandlerRef);
*/
mTrackingHandlerUPP = NewEventHandlerUPP(AudioUnitEffect::TrackingEventHandler);
InstallControlEventHandler(rootControl,
mTrackingHandlerUPP,
GetEventTypeCount(trackingEventList),
trackingEventList,
this,
&mRootTrackingHandlerRef);
InstallControlEventHandler(contentView,
mTrackingHandlerUPP,
GetEventTypeCount(trackingEventList),
trackingEventList,
this,
&mContentTrackingHandlerRef);
InstallControlEventHandler(auView,
mTrackingHandlerUPP,
GetEventTypeCount(trackingEventList),
trackingEventList,
this,
&mAUTrackingHandlerRef);
HIViewNewTrackingArea(rootControl, NULL, 0, NULL);
HIViewNewTrackingArea(contentView, NULL, 0, NULL);
HIViewNewTrackingArea(auView, NULL, 0, NULL);
return true;
}
@@ -1931,6 +2000,8 @@ bool AudioUnitEffect::HideUI()
bool AudioUnitEffect::CloseUI()
{
RemoveHandler();
if (mEventHelper)
{
mParent->RemoveEventHandler(mEventHelper);
@@ -2075,6 +2146,57 @@ void AudioUnitEffect::ShowOptions()
// AudioUnitEffect Implementation
// ============================================================================
void AudioUnitEffect::RemoveHandler()
{
if (mAUTrackingHandlerRef)
{
::RemoveEventHandler(mAUTrackingHandlerRef);
mAUTrackingHandlerRef = 0;
}
if (mContentTrackingHandlerRef)
{
::RemoveEventHandler(mContentTrackingHandlerRef);
mContentTrackingHandlerRef = 0;
}
if (mRootTrackingHandlerRef)
{
::RemoveEventHandler(mRootTrackingHandlerRef);
mRootTrackingHandlerRef = 0;
}
if (mTrackingHandlerUPP)
{
DisposeEventHandlerUPP(mTrackingHandlerUPP);
mTrackingHandlerUPP = 0;
}
if (mControlHandlerRef)
{
::RemoveEventHandler(mControlHandlerRef);
mControlHandlerRef = 0;
}
if (mControlHandlerUPP)
{
DisposeEventHandlerUPP(mControlHandlerUPP);
mControlHandlerUPP = 0;
}
if (mHandlerRef)
{
::RemoveEventHandler(mHandlerRef);
mHandlerRef = 0;
}
if (mHandlerUPP)
{
DisposeEventHandlerUPP(mHandlerUPP);
mHandlerUPP = 0;
}
}
void AudioUnitEffect::LoadParameters(const wxString & group)
{
OSStatus result;

View File

@@ -165,6 +165,13 @@ private:
void *data);
OSStatus ControlEventHandler(EventRef event);
static pascal OSStatus TrackingEventHandler(EventHandlerCallRef handler,
EventRef event,
void *data);
OSStatus OnTrackingEvent(EventRef event);
void RemoveHandler();
void GetChannelCounts();
void LoadParameters(const wxString & group);
@@ -224,6 +231,11 @@ private:
EventHandlerRef mControlHandlerRef;
EventHandlerUPP mControlHandlerUPP;
EventHandlerUPP mTrackingHandlerUPP;
EventHandlerRef mRootTrackingHandlerRef;
EventHandlerRef mContentTrackingHandlerRef;
EventHandlerRef mAUTrackingHandlerRef;
AudioUnitEffectEventHelper *mEventHelper;
friend class AudioUnitEffectEventHelper;