From e60057fd856618fe4c96fbe7dfea637553574b71 Mon Sep 17 00:00:00 2001 From: Paul Licameli Date: Wed, 27 May 2015 20:14:32 -0400 Subject: [PATCH] Bug924, addendum: pause scrubbing when Audacity loses focus... ... And it resumes if Audacity regains focus. Actually this fix causes pausing and resuming depending on whether Track Panel has focus, so clicks in other parts of the Audacity window may also pause the scrubbing. I hope that is acceptable. --- src/TrackPanel.cpp | 18 ++++++++++++++++-- src/TrackPanel.h | 1 + 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/src/TrackPanel.cpp b/src/TrackPanel.cpp index 3dffb7510..aedfeeeca 100755 --- a/src/TrackPanel.cpp +++ b/src/TrackPanel.cpp @@ -607,6 +607,7 @@ TrackPanel::TrackPanel(wxWindow * parent, wxWindowID id, mScrubStartPosition = -1; mMaxScrubSpeed = 1.0; mScrubSpeedDisplayCountdown = 0; + mScrubHasFocus = false; #endif #ifdef EXPERIMENTAL_SCRUBBING_SMOOTH_SCROLL @@ -2406,6 +2407,7 @@ bool TrackPanel::MaybeStartScrubbing(wxMouseEvent &event) mScrubStartClockTimeMillis = ::wxGetLocalTimeMillis(); if (IsScrubbing()) { + mScrubHasFocus = true; //mMouseCapture = IsMiddleButtonScrubbing; //CaptureMouse(); } @@ -2417,8 +2419,11 @@ bool TrackPanel::MaybeStartScrubbing(wxMouseEvent &event) bool TrackPanel::ContinueScrubbing(wxCoord position, bool maySkip) { - wxCoord leadPosition = position; - double newEnd = PositionToTime(leadPosition, GetLeftOffset()); + // When we don't have focus, enqueue silent scrubs until we regain focus. + if (!mScrubHasFocus) + return gAudioIO->EnqueueScrubBySignedSpeed(0, mMaxScrubSpeed, maySkip); + + const double newEnd = PositionToTime(position, GetLeftOffset()); if (maySkip) // Cause OnTimer() to suppress the speed display @@ -7371,6 +7376,9 @@ void TrackPanel::DrawEverythingElse(wxDC * dc, #ifdef EXPERIMENTAL_SCRUBBING_BASIC void TrackPanel::DrawScrubSpeed(wxDC &dc) { + if (!mScrubHasFocus) + return; + // Don't draw it during stutter play with shift down if (!::wxGetMouseState().ShiftDown() && ( @@ -9777,12 +9785,18 @@ void TrackPanel::SetFocusedTrack( Track *t ) void TrackPanel::OnSetFocus(wxFocusEvent & WXUNUSED(event)) { +#ifdef EXPERIMENTAL_SCRUBBING_BASIC + mScrubHasFocus = IsScrubbing(); +#endif SetFocusedTrack( GetFocusedTrack() ); Refresh( false ); } void TrackPanel::OnKillFocus(wxFocusEvent & WXUNUSED(event)) { +#ifdef EXPERIMENTAL_SCRUBBING_BASIC + mScrubHasFocus = false; +#endif Refresh( false); } diff --git a/src/TrackPanel.h b/src/TrackPanel.h index 2d8093214..12c69946f 100755 --- a/src/TrackPanel.h +++ b/src/TrackPanel.h @@ -783,6 +783,7 @@ protected: wxCoord mScrubStartPosition; double mMaxScrubSpeed; int mScrubSpeedDisplayCountdown; + bool mScrubHasFocus; #endif #ifdef EXPERIMENTAL_SCRUBBING_SMOOTH_SCROLL