From 8daba3cd798826bf426a4db3cbaad50846b5c25d Mon Sep 17 00:00:00 2001 From: Charlie Fenton Date: Wed, 6 Jul 2005 05:16:53 +0000 Subject: [PATCH] *** empty log message *** svn path=/trunk/boinc/; revision=6531 --- checkin_notes | 20 +++++++++++ clientgui/BOINCGUIApp.cpp | 5 ++- clientgui/BOINCTaskBar.cpp | 30 +++++++++++++++++ clientgui/MainFrame.cpp | 24 ++++++++----- clientgui/MainFrame.h | 4 +++ clientgui/mac/MacSysMenu.cpp | 41 +++++++++++++++++++++-- clientgui/mac/MacSysMenu.h | 4 ++- clientgui/mac/SystemMenu.m | 6 ++++ mac_build/English.lproj/InfoPlist.strings | 4 +-- mac_build/Info.plist | 2 +- mac_build/Installer-info.plist | 2 +- mac_build/ScreenSaver-Info.plist | 2 +- mac_build/SystemMenu-Info.plist | 2 +- 13 files changed, 127 insertions(+), 19 deletions(-) diff --git a/checkin_notes b/checkin_notes index 8fbe23727a..1a7d189bea 100755 --- a/checkin_notes +++ b/checkin_notes @@ -8902,3 +8902,23 @@ David 5 July 2005 sched/ sched_send.C + +Charlie 5 July 2005 + Mac: Integrated Hide of BOINCManager with close of main Manager window. + Closing window hides Manager application, opening window (from menubar + icon menu or from Dock menu) Shows application. Hiding or showing + application closes or opens window. This eliminates having just the + manager's menu bar pop up when a foreground application quits. + Disable all application-specific menu items in Dock menu and menubar + icon menu when a modal dialog is active. This matches the disabling + of items in the Manager's regular menus. + Fixed bug where all items in menubar icon menu were disabled, which + required clicking on the icon repeatedly. + + clientgui/ + BOINCGUIApp.cpp + BOINCTaskBar.cpp + MainFrame.cpp, .h + mac/ + MacSysMenu.cpp, .h + SystemMenu.m diff --git a/clientgui/BOINCGUIApp.cpp b/clientgui/BOINCGUIApp.cpp index 9267d9b593..01846d2347 100644 --- a/clientgui/BOINCGUIApp.cpp +++ b/clientgui/BOINCGUIApp.cpp @@ -216,7 +216,10 @@ bool CBOINCGUIApp::OnInit() { if (m_bFrameVisible) { m_pFrame->Show(); } else { -#ifndef __WXMAC__ +#ifdef __WXMAC__ + GetCurrentProcess(&psn); + ShowHideProcess(&psn, false); +#else m_pFrame->Show(); m_pFrame->Show(false); #endif diff --git a/clientgui/BOINCTaskBar.cpp b/clientgui/BOINCTaskBar.cpp index 0359575730..c99ae08696 100644 --- a/clientgui/BOINCTaskBar.cpp +++ b/clientgui/BOINCTaskBar.cpp @@ -183,6 +183,14 @@ void CTaskBarIcon::OnNetworkSelection(wxCommandEvent& event) { void CTaskBarIcon::OnAbout(wxCommandEvent& WXUNUSED(event)) { +#ifdef __WXMAC__ + ProcessSerialNumber psn; + + GetCurrentProcess(&psn); + bool wasVisible = IsProcessVisible(&psn); + SetFrontProcess(&psn); // Shows process if hidden +#endif + ResetTaskBar(); CDlgAbout* pDlg = new CDlgAbout(NULL); @@ -192,6 +200,11 @@ void CTaskBarIcon::OnAbout(wxCommandEvent& WXUNUSED(event)) { if (pDlg) { pDlg->Destroy(); + +#ifdef __WXMAC__ + if (! wasVisible) + ShowHideProcess(&psn, false); +#endif } } @@ -420,6 +433,23 @@ void CTaskBarIcon::AdjustMenuItems(wxMenu* menu) { } else { menu->Check(ID_TB_NETWORKSUSPEND, false); } + +#ifdef __WXMAC__ + WindowRef win = ActiveNonFloatingWindow(); + WindowModality modality = kWindowModalityNone; + wxMenuItem *item; + unsigned int i; + + if (win) + GetWindowModality(win, &modality, NULL); + for (i = 0; i GetMenuItemCount() ; i++) { + item = menu->FindItemByPosition(i); + if (modality == kWindowModalityAppModal) + item->Enable(false); + else + item->Enable(!(item->IsSeparator())); + } +#endif // __WXMAC__ } const char *BOINC_RCSID_531575eeaa = "$Id$"; diff --git a/clientgui/MainFrame.cpp b/clientgui/MainFrame.cpp index 01c7ec1a48..849e07b01a 100644 --- a/clientgui/MainFrame.cpp +++ b/clientgui/MainFrame.cpp @@ -319,19 +319,11 @@ bool CMainFrame::CreateMenu() { // File menu wxMenu *menuFile = new wxMenu; -#ifdef __WXMAC__ - menuFile->Append( - ID_HIDE, - _("Close"), - _("Closes the main BOINC Manager window") - ); -#else menuFile->Append( ID_HIDE, _("&Hide"), _("Hides the main BOINC Manager window") ); -#endif menuFile->AppendSeparator(); menuFile->AppendRadioItem( @@ -1786,5 +1778,21 @@ void CMainFrame::ExecuteBrowserLink(const wxString &strLink) { wxHyperLink::ExecuteLink(strLink); } +#ifdef __WXMAC__ + +bool CMainFrame::Show(bool show) { + ProcessSerialNumber psn; + + GetCurrentProcess(&psn); + if (show) { + SetFrontProcess(&psn); // Shows process if hidden + } else + if (IsProcessVisible(&psn)) + ShowHideProcess(&psn, false); + + return wxFrame::Show(show); +} + +#endif // __WXMAC__ const char *BOINC_RCSID_d881a56dc5 = "$Id$"; diff --git a/clientgui/MainFrame.h b/clientgui/MainFrame.h index b03a7d03a4..dc48ea379a 100644 --- a/clientgui/MainFrame.h +++ b/clientgui/MainFrame.h @@ -97,6 +97,10 @@ public: void ShowAlert( const wxString title, const wxString message, const int style, const bool notification_only = false ); void ExecuteBrowserLink( const wxString& strLink ); +#ifdef __WXMAC__ + bool Show( bool show = true ); +#endif + private: wxMenuBar* m_pMenubar; diff --git a/clientgui/mac/MacSysMenu.cpp b/clientgui/mac/MacSysMenu.cpp index 6abe4d7c1d..d4263c56c9 100644 --- a/clientgui/mac/MacSysMenu.cpp +++ b/clientgui/mac/MacSysMenu.cpp @@ -38,6 +38,8 @@ pascal OSStatus SysMenuEventHandler( EventHandlerCallRef inHandlerCallRef, EventRef inEvent, void* pData); EventTypeSpec myEvents[] = { {kEventClassCommand, kEventCommandProcess}, + { kEventClassApplication, kEventAppHidden}, + { kEventClassApplication, kEventAppShown}, {kEventClassMenu, kEventMenuOpening} }; EventTypeSpec removeEventList[] = { { kEventClassApplication, kEventAppGetDockTileMenu } }; @@ -54,6 +56,8 @@ CMacSystemMenu::CMacSystemMenu() : CTaskBarIcon() theBitsRefData = theBits.GetBitmapData(); thePICT = theBitsRefData->GetPictHandle(); + m_OpeningAboutDlg = false; + LoadPrivateFrameworkBundle( CFSTR("SystemMenu.bundle"), &SysMenuBundle ); if ( SysMenuBundle != NULL ) { @@ -176,7 +180,12 @@ pascal OSStatus SysMenuEventHandler( EventHandlerCallRef inHandlerCallRef, if ((command.attributes == kHICommandFromMenu) && (command.commandID == 0)) return eventNotHandledErr; - + + pMSM = wxGetApp().GetMacSystemMenu(); + + if (command.commandID == wxID_ABOUT) + pMSM->SetOpeningAboutDlg(true); + // If not our system menu, pass event on to next event handler // sysMenuRef = command.menu.menuRef; if (PLstrcmp("\pBOINC!", (GetMenuTitle((sysMenuRef), theMenuTitle) ))) @@ -184,7 +193,6 @@ pascal OSStatus SysMenuEventHandler( EventHandlerCallRef inHandlerCallRef, // Change the command to point to the same item in our base (prototype) // menu and pass the event on to the Dock's menu event handler. - pMSM = (CMacSystemMenu*&) pData; baseMenu = (pMSM->GetCurrentMenu()); baseMenuRef = (MenuRef)(baseMenu->GetHMenu()); command.menu.menuRef = baseMenuRef; @@ -208,7 +216,7 @@ pascal OSStatus SysMenuEventHandler( EventHandlerCallRef inHandlerCallRef, if (PLstrcmp("\pBOINC!", (GetMenuTitle((sysMenuRef), theMenuTitle) ))) return eventNotHandledErr; - pMSM = (CMacSystemMenu*&) pData; + pMSM = wxGetApp().GetMacSystemMenu(); baseMenu = (pMSM->GetCurrentMenu()); pMSM->AdjustMenuItems(baseMenu); @@ -231,6 +239,33 @@ pascal OSStatus SysMenuEventHandler( EventHandlerCallRef inHandlerCallRef, } return noErr; + + case kEventClassApplication: + CMainFrame* pFrame = wxGetApp().GetFrame(); + pMSM = wxGetApp().GetMacSystemMenu(); + switch (eventKind) { + case kEventAppHidden: + if (pFrame) + pFrame->Hide(); + pMSM->SetOpeningAboutDlg(false); + break; + + case kEventAppShown: + // Don't open main window if "About" Dialog from task bar menu. + if (pMSM->IsOpeningAboutDlg()) { + pMSM->SetOpeningAboutDlg(false); + break; + } + if (ActiveNonFloatingWindow()) // Prevent infinite loop + break; + if (pFrame) { + pFrame->Show(); + pFrame->SendSizeEvent(); + } + break; + } + + return eventNotHandledErr; } // End switch (eventClass) diff --git a/clientgui/mac/MacSysMenu.h b/clientgui/mac/MacSysMenu.h index 7b388ca830..6c15dd1cc6 100644 --- a/clientgui/mac/MacSysMenu.h +++ b/clientgui/mac/MacSysMenu.h @@ -46,10 +46,12 @@ public: SetUpSystemMenuProc SetUpSystemMenu; SetSystemMenuIconProc SetSystemMenuIcon; + bool IsOpeningAboutDlg() { return m_OpeningAboutDlg; } + void SetOpeningAboutDlg(bool b) { m_OpeningAboutDlg = b; } private: EventHandlerRef m_pSysMenuEventHandlerRef; - + bool m_OpeningAboutDlg; }; diff --git a/clientgui/mac/SystemMenu.m b/clientgui/mac/SystemMenu.m index c0d3c96576..be8b7b33d9 100644 --- a/clientgui/mac/SystemMenu.m +++ b/clientgui/mac/SystemMenu.m @@ -148,11 +148,17 @@ void SetUpSystemMenu(MenuRef menuToCopy, PicHandle theIcon) newItem = [[NSMenuItem allocWithZone:[NSMenu menuZone]] initWithTitle:(NSString*)CFText action:NULL keyEquivalent:@""]; [newItem setTarget:self]; [sysMenu addItem:newItem]; + if( IsMenuItemEnabled(menuToCopy, i) ) + [newItem setEnabled:YES]; + else + [newItem setEnabled:NO]; + [newItem release]; CFRelease(CFText); } } + [sysMenu setAutoenablesItems:NO]; return; } diff --git a/mac_build/English.lproj/InfoPlist.strings b/mac_build/English.lproj/InfoPlist.strings index cba4c62b2a..03506e6f17 100755 --- a/mac_build/English.lproj/InfoPlist.strings +++ b/mac_build/English.lproj/InfoPlist.strings @@ -1,5 +1,5 @@ /* Localized versions of Info.plist keys */ CFBundleName = "BOINC"; -CFBundleShortVersionString = "BOINC version 5.50"; -CFBundleGetInfoString = "BOINC version 5.50, Copyright 2005 University of California."; +CFBundleShortVersionString = "BOINC version 4.70"; +CFBundleGetInfoString = "BOINC version 4.70, Copyright 2005 University of California."; diff --git a/mac_build/Info.plist b/mac_build/Info.plist index 9b1af1a711..7fd4596800 100644 --- a/mac_build/Info.plist +++ b/mac_build/Info.plist @@ -17,6 +17,6 @@ CFBundleSignature BNC! CFBundleVersion - 5.50 + 4.70 diff --git a/mac_build/Installer-info.plist b/mac_build/Installer-info.plist index 535d317864..4b4ac5016e 100644 --- a/mac_build/Installer-info.plist +++ b/mac_build/Installer-info.plist @@ -15,6 +15,6 @@ CFBundleSignature ???? CFBundleVersion - 5.50 + 4.70 diff --git a/mac_build/ScreenSaver-Info.plist b/mac_build/ScreenSaver-Info.plist index 3ff46167c1..45dd836c38 100644 --- a/mac_build/ScreenSaver-Info.plist +++ b/mac_build/ScreenSaver-Info.plist @@ -17,7 +17,7 @@ CFBundleSignature ???? CFBundleVersion - 5.50 + 4.70 NSPrincipalClass BOINC_Saver_ModuleView diff --git a/mac_build/SystemMenu-Info.plist b/mac_build/SystemMenu-Info.plist index 3d19c69d08..b5348a5a60 100644 --- a/mac_build/SystemMenu-Info.plist +++ b/mac_build/SystemMenu-Info.plist @@ -15,6 +15,6 @@ CFBundleSignature ???? CFBundleVersion - 5.50 + 4.70