Mac: Refine big fix for menubar icon menu not working after changing skin

svn path=/trunk/boinc/; revision=23819
This commit is contained in:
Charlie Fenton 2011-07-08 08:26:11 +00:00
parent f60700cff4
commit 3e0055cbe0
4 changed files with 30 additions and 12 deletions

View File

@ -3960,3 +3960,11 @@ David 7 July 2011
client/
client_types.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

View File

@ -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
}

View File

@ -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;
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()) {
// 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));
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;

View File

@ -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;
};