From 7540acb7de13fb04ad947a1ab455bf6781850a45 Mon Sep 17 00:00:00 2001 From: Charlie Fenton Date: Fri, 8 Jul 2011 08:32:10 +0000 Subject: [PATCH] Mac: Refine big fix for menubar icon menu not working after changing skin svn path=/branches/boinc_core_release_6_12/; revision=23820 --- checkin_notes | 8 ++++++++ clientgui/BOINCTaskBar.cpp | 3 ++- clientgui/mac/MacSysMenu.cpp | 19 +++++++++++++------ clientgui/mac/MacSysMenu.h | 8 +++++--- 4 files changed, 28 insertions(+), 10 deletions(-) diff --git a/checkin_notes b/checkin_notes index fff189dccc..ede6cdee17 100644 --- a/checkin_notes +++ b/checkin_notes @@ -10005,3 +10005,11 @@ Charlie 7 July 2011 clientgui/ mac/ MacSysMenu.cpp + +Charlie 8 July 2011 + - Mac: Refine big fix for menubar icon menu not working after changing skin. + + clientgui/ + BOINCTaskBar.cpp + mac/ + MacSysMenu.cpp, .h diff --git a/clientgui/BOINCTaskBar.cpp b/clientgui/BOINCTaskBar.cpp index 208bdb9c8c..b904d39ee8 100644 --- a/clientgui/BOINCTaskBar.cpp +++ b/clientgui/BOINCTaskBar.cpp @@ -325,7 +325,8 @@ void CTaskBarIcon::OnReloadSkin(CTaskbarEvent& WXUNUSED(event)) { m_iconTaskBarSnooze = *pSkinAdvanced->GetApplicationSnoozeIcon(); #ifdef __WXMAC__ - wxGetApp().GetMacSystemMenu()->BuildMenu(); + // For unknown reasons, menus won't work if we call BuildMenu() here + wxGetApp().GetMacSystemMenu()->SetNeedToRebuildMenu(); #endif } diff --git a/clientgui/mac/MacSysMenu.cpp b/clientgui/mac/MacSysMenu.cpp index 003dde8862..9f62e7a7f1 100644 --- a/clientgui/mac/MacSysMenu.cpp +++ b/clientgui/mac/MacSysMenu.cpp @@ -121,7 +121,8 @@ CMacSystemMenu::CMacSystemMenu(wxString title, wxIcon* icon, wxIcon* iconDisconn : CTaskBarIcon(title, icon, iconDisconnected, iconSnooze) { CFBundleRef SysMenuBundle = NULL; - m_OpeningAboutDlg = false; + m_bOpeningAboutDlg = false; + m_bNeedRebuildMenu = false; LoadPrivateFrameworkBundle( CFSTR("SystemMenu.bundle"), &SysMenuBundle ); if ( SysMenuBundle != NULL ) @@ -163,17 +164,23 @@ CMacSystemMenu::~CMacSystemMenu() { // Set the System Menu Icon from XPM data bool CMacSystemMenu::SetIcon(const wxIcon& icon) { wxBitmap theBits; + + // For unknown reasons, menus won't work if we call BuildMenu() directly + // from CTaskBarIcon::OnReloadSkin(), so it sets a flag to call it here + if (m_bNeedRebuildMenu) { CMainDocument* pDoc = wxGetApp().GetDocument(); wxASSERT(pDoc); wxASSERT(wxDynamicCast(pDoc, CMainDocument)); - - theBits.CopyFromIcon(icon); - CGImageRef imageRef = (CGImageRef)theBits.CGImageCreate(); - if ( (SetSystemMenuIcon != NULL ) && (imageRef != NULL) ) { - if (pDoc->IsConnected()) { + if (pDoc->IsConnected() && m_bNeedRebuildMenu) { // For unknown reasons, Menubar Icon menu doesn't work without this BuildMenu(); } + } + m_bNeedRebuildMenu = false; + + theBits.CopyFromIcon(icon); + CGImageRef imageRef = (CGImageRef)theBits.CGImageCreate(); + if ( (SetSystemMenuIcon != NULL) && (imageRef != NULL) ) { SetSystemMenuIcon(imageRef); CGImageRelease( imageRef ); return true; diff --git a/clientgui/mac/MacSysMenu.h b/clientgui/mac/MacSysMenu.h index 5f40e41c87..67b8ea1e34 100644 --- a/clientgui/mac/MacSysMenu.h +++ b/clientgui/mac/MacSysMenu.h @@ -42,8 +42,9 @@ public: SetUpSystemMenuProc SetUpSystemMenu; SetSystemMenuIconProc SetSystemMenuIcon; - bool IsOpeningAboutDlg() { return m_OpeningAboutDlg; } - void SetOpeningAboutDlg(bool b) { m_OpeningAboutDlg = b; } + bool IsOpeningAboutDlg() { return m_bOpeningAboutDlg; } + void SetOpeningAboutDlg(bool b) { m_bOpeningAboutDlg = b; } + void SetNeedToRebuildMenu() { m_bNeedRebuildMenu = true; } void BuildMenu(void); #if wxCHECK_VERSION(2,8,0) wxMenu *GetCurrentMenu(); @@ -51,7 +52,8 @@ public: private: - bool m_OpeningAboutDlg; + bool m_bOpeningAboutDlg; + bool m_bNeedRebuildMenu; };