diff --git a/src/Project.cpp b/src/Project.cpp index a225729ef..2263f5c83 100644 --- a/src/Project.cpp +++ b/src/Project.cpp @@ -2174,6 +2174,22 @@ void AudacityProject::OnUpdateUI(wxUpdateUIEvent & WXUNUSED(event)) UpdateMenus(); } +void AudacityProject::MacShowUndockedToolbars(bool show) +{ +#ifdef __WXMAC__ + // Find all the floating toolbars, and show or hide them + const auto &children = GetChildren(); + for(const auto &child : children) { + if (auto frame = dynamic_cast(child)) { + if (!show) + frame->Hide(); + else if (frame->GetToolBar()->IsVisible()) + frame->Show(); + } + } +#endif +} + void AudacityProject::OnActivate(wxActivateEvent & event) { // Activate events can fire during window teardown, so just @@ -2207,6 +2223,10 @@ void AudacityProject::OnActivate(wxActivateEvent & event) if (wxGetTopLevelParent(w) ==this) { mLastFocusedWindow = w; } +#ifdef __WXMAC__ + if (IsIconized()) + MacShowUndockedToolbars(false); +#endif } else { SetActiveProject(this); @@ -2220,6 +2240,10 @@ void AudacityProject::OnActivate(wxActivateEvent & event) } // No longer need to remember the last focused window mLastFocusedWindow = NULL; + +#ifdef __WXMAC__ + MacShowUndockedToolbars(true); +#endif } event.Skip(); } diff --git a/src/Project.h b/src/Project.h index 0e33dfb0e..b847f0000 100644 --- a/src/Project.h +++ b/src/Project.h @@ -312,7 +312,9 @@ class AUDACITY_DLL_API AudacityProject final : public wxFrame, void OnMenu(wxCommandEvent & event); void OnUpdateUI(wxUpdateUIEvent & event); + void MacShowUndockedToolbars(bool show); void OnActivate(wxActivateEvent & event); + void OnMouseEvent(wxMouseEvent & event); void OnIconize(wxIconizeEvent &event); void OnSize(wxSizeEvent & event); diff --git a/src/TrackPanel.cpp b/src/TrackPanel.cpp index d26279c27..058a86c13 100644 --- a/src/TrackPanel.cpp +++ b/src/TrackPanel.cpp @@ -925,6 +925,18 @@ AudacityProject * TrackPanel::GetProject() const /// AS: This gets called on our wx timer events. void TrackPanel::OnTimer(wxTimerEvent& ) { +#ifdef __WXMAC__ + // Unfortunate part of fix for bug 1431 + // Without this, the toolbars hide only every other time that you press + // the yellow title bar button. For some reason, not every press sends + // us a deactivate event for the application. + { + auto project = GetProject(); + if (project->IsIconized()) + project->MacShowUndockedToolbars(false); + } +#endif + mTimeCount++; // AS: If the user is dragging the mouse and there is a track that // has captured the mouse, then scroll the screen, as necessary. diff --git a/src/toolbars/ToolManager.h b/src/toolbars/ToolManager.h index 6a5982041..d06af8f40 100644 --- a/src/toolbars/ToolManager.h +++ b/src/toolbars/ToolManager.h @@ -138,6 +138,8 @@ public: ~ToolFrame(); + ToolBar *GetToolBar() { return mBar; } + // // Transition a toolbar from float to dragging //