From d1d5a1e3a9dd1de7bb1978d10620c8ff83bf3ca6 Mon Sep 17 00:00:00 2001 From: lllucius Date: Tue, 8 Mar 2011 14:09:26 +0000 Subject: [PATCH] Refer to bug #294 for details. --- src/Project.cpp | 31 +++++++++++++++++++++++++++++++ src/Project.h | 5 +++++ 2 files changed, 36 insertions(+) diff --git a/src/Project.cpp b/src/Project.cpp index 522cf0b6c..bc03360c8 100644 --- a/src/Project.cpp +++ b/src/Project.cpp @@ -1728,6 +1728,31 @@ void AudacityProject::OnUpdateUI(wxUpdateUIEvent & event) UpdateMenus(); } +#if defined(__WXGTK__) +// Under wxGTK, we seem to experience focus issues related to improper "buffering" of active focus. This causes +// the normal SetFocus() to be ignored if it thinks the target window already has focus, even though it may not +// really have it. +// +// Thus the reason for this hackage. It basically, forces focus to another, known to exist, window before +// forcing focus to the TrackPanel. This is not at all a perfect solution, but until wxGTK is fixed, this +// may provide some relief from focus not returning to the TrackPanel after modal dialogs are closed. +// +// This also means that it may not work the same way on different versions of wxGTK other than 2.8.11, which +// is the version this was tested on. +void AudacityProject::SetFocus() +{ + if (mTrackPanel) { + wxWindow *w = GetSelectionBar(); + if (w) + { + w->SetFocus(); + OnInternalIdle(); + } + mTrackPanel->SetFocus(); + } +} +#endif + void AudacityProject::OnActivate(wxActivateEvent & event) { // Activate events can fire during window teardown, so just @@ -1738,6 +1763,12 @@ void AudacityProject::OnActivate(wxActivateEvent & event) mActive = event.GetActive(); +#if defined(__WXGTK__) + // See AudacityProject::SetFocus() above for further wxGTK handling + event.Skip(); + return; +#endif + // Under Windows, focus can be "lost" when returning to // Audacity from a different application. // diff --git a/src/Project.h b/src/Project.h index 6326e5013..d28b434db 100644 --- a/src/Project.h +++ b/src/Project.h @@ -127,6 +127,11 @@ class AUDACITY_DLL_API AudacityProject: public wxFrame, const wxPoint & pos, const wxSize & size); virtual ~AudacityProject(); +#if defined(__WXGTK__) + // See comments in Project.cpp/AudacityProject::SetFocus() + virtual void SetFocus(); +#endif + TrackList *GetTracks() { return mTracks; }; UndoManager *GetUndoManager() { return &mUndoManager; }