| 1187 | } |
| 1188 | |
| 1189 | void ProjectWindow::OnActivate(wxActivateEvent & event) |
| 1190 | { |
| 1191 | // Activate events can fire during window teardown, so just |
| 1192 | // ignore them. |
| 1193 | if (IsBeingDeleted()) { |
| 1194 | return; |
| 1195 | } |
| 1196 | |
| 1197 | auto pProject = FindProject(); |
| 1198 | if (!pProject) |
| 1199 | return; |
| 1200 | auto &project = *pProject; |
| 1201 | |
| 1202 | mActive = event.GetActive(); |
| 1203 | |
| 1204 | // Under Windows, focus can be "lost" when returning to |
| 1205 | // Audacity from a different application. |
| 1206 | // |
| 1207 | // This was observed by minimizing all windows using WINDOWS+M and |
| 1208 | // then ALT+TAB to return to Audacity. Focus will be given to the |
| 1209 | // project window frame which is not at all useful. |
| 1210 | // |
| 1211 | // So, we use ToolManager's observation of focus changes in a wxEventFilter. |
| 1212 | // Then, when we receive the |
| 1213 | // activate event, we restore that focus to the child or the track |
| 1214 | // panel if no child had the focus (which probably should never happen). |
| 1215 | if (mActive) { |
| 1216 | auto &toolManager = ToolManager::Get( project ); |
| 1217 | SetActiveProject( &project ); |
| 1218 | if ( ! toolManager.RestoreFocus() ) |
| 1219 | GetProjectPanel( project ).SetFocus(); |
| 1220 | } |
| 1221 | event.Skip(); |
| 1222 | } |
| 1223 | |
| 1224 | bool ProjectWindow::IsActive() |
| 1225 | { |
nothing calls this directly
no test coverage detected