MGR: Mac updates for wxWidgets 2.9.5 (wxCocoa)

- Avoid bouncing Dock icon when hiding Manager
- Avoid "ghost" image when closing or hiding windows
This commit is contained in:
Charlie Fenton 2013-08-26 18:28:04 -07:00
parent 2870f35abb
commit a9474c0440
6 changed files with 83 additions and 23 deletions

View File

@ -723,9 +723,6 @@ bool CAdvancedFrame::CreateMenu() {
}
#ifdef __WXMAC__
// Enable Mac OS X's standard Preferences menu item (handled in MacSysMenu.cpp)
EnableMenuCommand(NULL, kHICommandPreferences);
// Set HELP key as keyboard shortcut
m_Shortcuts[0].Set(wxACCEL_NORMAL, WXK_HELP, ID_HELPBOINCMANAGER);
m_pAccelTable = new wxAcceleratorTable(1, m_Shortcuts);
@ -1013,9 +1010,21 @@ void CAdvancedFrame::SaveWindowDimensions() {
wxString strBaseConfigLocation = wxString(wxT("/"));
wxConfigBase* pConfig = wxConfigBase::Get(FALSE);
wxPoint pos = GetPosition();
wxASSERT(pConfig);
#ifdef __WXMAC__
// We don't call Hide() or Show(false) for the main frame
// under wxCocoa 2.9.5 because it bounces the Dock icon
// (as in notification.) We work around this by moving
// the main window/frame off screen when displaying the
// CDlgAbout modal dialog while the main window is hidden
// by CTaskBarIcon::OnAbout().
if (pos.x >= 20000) pos.x -= 20000;
if (pos.y >= 20000) pos.y -= 20000;
#endif
pConfig->SetPath(strBaseConfigLocation);
bool iconized = IsIconized();
@ -1024,8 +1033,8 @@ void CAdvancedFrame::SaveWindowDimensions() {
if (!iconized) {
pConfig->Write(wxT("Width"), GetSize().GetWidth());
pConfig->Write(wxT("Height"), GetSize().GetHeight());
pConfig->Write(wxT("XPos"), GetPosition().x);
pConfig->Write(wxT("YPos"), GetPosition().y);
pConfig->Write(wxT("XPos"), pos.x);
pConfig->Write(wxT("YPos"), pos.y);
}
wxLogTrace(wxT("Function Start/End"), wxT("CAdvancedFrame::SaveWindowDimensions - Function End"));

View File

@ -314,6 +314,10 @@ void CBOINCBaseFrame::OnClose(wxCloseEvent& event) {
// Apparently aborting a close event just causes the main window to be displayed
// again. Just minimize the window instead.
Iconize();
#elif defined(__WXMAC__)
// Don't call Hide() or Show(false) under wxCocoa 2.9.5
// because it bounces the Dock icon (as in notification)
wxGetApp().ShowApplication(false);
#else
Hide();
#endif
@ -882,7 +886,11 @@ bool CBOINCBaseFrame::Show(bool bShow) {
}
retval = wxFrame::Show(bShow);
#ifndef __WXMAC__
// Calling wxFrame::Raise() under wxCocoa 2.9.5 causes a
// "ghost" image of the frame to appear briefly
wxFrame::Raise();
#endif
wxLogTrace(wxT("Function Start/End"), wxT("CBOINCBaseFrame::Show - Function End"));
return retval;

View File

@ -792,6 +792,27 @@ int CBOINCGUIApp::IdleTrackerDetach() {
void CBOINCGUIApp::OnActivateApp(wxActivateEvent& event) {
#ifdef __WXMAC__
static wxPoint pos;
// We don't call Hide() or Show(false) for the main frame
// under wxCocoa 2.9.5 because it bounces the Dock icon
// (as in notification.) We work around this by moving
// the main window/frame off screen when displaying the
// CDlgAbout modal dialog while the main window is hidden
// by CTaskBarIcon::OnAbout().
if (m_pFrame) {
if (event.GetActive()) {
if (!IsModalDialogDisplayed()) {
m_pFrame->SetPosition(pos);
}
} else {
wxPoint newPos = m_pFrame->GetPosition();
if ((newPos.x < 20000) && (newPos.y < 20000)) {
pos = newPos;
}
}
}
// Make sure any modal dialog (such as Attach Wizard) ends up in front.
if (IsModalDialogDisplayed()) {
event.Skip();
@ -803,7 +824,9 @@ void CBOINCGUIApp::OnActivateApp(wxActivateEvent& event) {
if (m_pEventLog && !m_pEventLog->IsIconized()) {
m_pEventLog->Raise();
}
m_pFrame->Raise();
if (m_pFrame) {
m_pFrame->Raise();
}
#ifdef __WXMAC__
ShowInterface();
#endif
@ -921,7 +944,7 @@ bool CBOINCGUIApp::SetActiveGUI(int iGUISelection, bool bShowWindow) {
// Create the new window
if ((iGUISelection != m_iGUISelected) || !m_pFrame) {
// Reterieve the desired window state before creating the
// Retrieve the desired window state before creating the
// desired frames
if (BOINC_ADVANCEDGUI == iGUISelection) {
m_pConfig->SetPath(wxT("/"));
@ -1217,6 +1240,7 @@ void CBOINCGUIApp::ShowApplication(bool) {
bool CBOINCGUIApp::ShowInterface() {
ShowApplication(true);
return SetActiveGUI(m_iGUISelected, true);
}

View File

@ -73,12 +73,6 @@ BEGIN_EVENT_TABLE(CTaskBarIcon, wxTaskBarIconEx)
EVT_TASKBAR_APPRESTORE(CTaskBarIcon::OnAppRestore)
#endif
#ifdef __WXMAC__
// wxMac-2.6.3 "helpfully" converts wxID_ABOUT to kHICommandAbout, wxID_EXIT to kHICommandQuit,
// wxID_PREFERENCES to kHICommandPreferences
EVT_MENU(kHICommandAbout, CTaskBarIcon::OnAbout)
#endif
END_EVENT_TABLE()
@ -262,6 +256,23 @@ void CTaskBarIcon::OnAbout(wxCommandEvent& WXUNUSED(event)) {
bEventLogWasShown = eventLog->IsShown();
if (bEventLogWasShown && !bWasVisible) eventLog->Show(false);
}
// We don't call Hide() or Show(false) for the main frame
// under wxCocoa 2.9.5 because it bounces the Dock icon
// (as in notification.) We work around this by moving
// the main window/frame off screen when displaying the
// CDlgAbout modal dialog while the main window is hidden.
// The position will be restored in one of these methods:
// CBOINCGUIApp::OnActivateApp(), CSimpleFrame::SaveState()
// or CAdvancedFrame::SaveWindowDimensions().
wxPoint pos;
CBOINCBaseFrame* pFrame = wxGetApp().GetFrame();
if (pFrame) {
pos = pFrame->GetPosition();
if ((!bWasVisible) && (pos.x < 20000) && (pos.y < 20000)) {
pFrame->SetPosition(wxPoint(pos.x + 20000, pos.y));
}
}
#endif
wxGetApp().ShowApplication(true);
@ -274,10 +285,6 @@ void CTaskBarIcon::OnAbout(wxCommandEvent& WXUNUSED(event)) {
if (!bWasVisible) {
wxGetApp().ShowApplication(false);
}
#ifdef __WXMAC__
if (bEventLogWasShown) eventLog->Show(true);
#endif
}

View File

@ -1016,7 +1016,10 @@ void CMainDocument::RunPeriodicRPCs(int frameRefreshRate) {
// Don't do periodic RPC calls when hidden / minimized
if (!pFrame->IsShown()) return;
#ifdef __WXMAC__
if (!wxGetApp().IsApplicationVisible()) return;
#endif
m_dtLastFrameViewRefreshRPCTime = dtNow;
// *********** RPC_GET_PROJECT_STATUS1 **************

View File

@ -274,9 +274,6 @@ CSimpleFrame::CSimpleFrame(wxString title, wxIcon* icon, wxIcon* icon32, wxPoint
#ifdef __WXMAC__
m_pMenubar->MacInstallMenuBar();
MacLocalizeBOINCMenu();
// Enable Mac OS X's standard Preferences menu item (handled in MacSysMenu.cpp)
EnableMenuCommand(NULL, kHICommandPreferences);
#endif
m_Shortcuts[0].Set(wxACCEL_NORMAL, WXK_HELP, ID_HELPBOINCMANAGER);
@ -307,6 +304,7 @@ bool CSimpleFrame::SaveState() {
CBOINCBaseFrame::SaveState();
wxConfigBase* pConfig = wxConfigBase::Get(FALSE);
wxString strBaseConfigLocation = wxString(wxT("/Simple"));
wxPoint pos = GetPosition();
wxASSERT(pConfig);
@ -316,13 +314,24 @@ bool CSimpleFrame::SaveState() {
// pointer, return false.
if (!pConfig) return false;
#ifdef __WXMAC__
// We don't call Hide() or Show(false) for the main frame
// under wxCocoa 2.9.5 because it bounces the Dock icon
// (as in notification.) We work around this by moving
// the main window/frame off screen when displaying the
// CDlgAbout modal dialog while the main window is hidden
// by CTaskBarIcon::OnAbout().
if (pos.x >= 20000) pos.x -= 20000;
if (pos.y >= 20000) pos.y -= 20000;
#endif
//
// Save Frame State
//
pConfig->SetPath(strBaseConfigLocation);
pConfig->Write(wxT("XPos"), GetPosition().x);
pConfig->Write(wxT("YPos"), GetPosition().y);
pConfig->Write(wxT("XPos"), pos.x);
pConfig->Write(wxT("YPos"), pos.y);
return true;
}