From e53d0a480ba8db4fff7f9d963de84b19f531cf1c Mon Sep 17 00:00:00 2001 From: Charlie Fenton Date: Tue, 26 Feb 2008 01:53:36 +0000 Subject: [PATCH] Mac SCR: Display "Starting screensaver graphics. Please wait ..." for 45 seconds each time we start graphics from a different application svn path=/trunk/boinc/; revision=14793 --- checkin_notes | 11 +++++++++++ clientscr/Mac_Saver_Module.h | 3 ++- clientscr/mac_saver_module.cpp | 30 +++++++++++++++++++++++------- clientscr/screensaver.cpp | 3 +++ 4 files changed, 39 insertions(+), 8 deletions(-) diff --git a/checkin_notes b/checkin_notes index 0184cfcce6..8177a9d1e9 100644 --- a/checkin_notes +++ b/checkin_notes @@ -1635,3 +1635,14 @@ Charlie Feb 25 2008 clientgui/ sg_DlgMessages.cpp ViewMessages.cpp + +Charlie Feb 25 2008 + - Mac SCR: Display "Starting screensaver graphics. Please wait ..." + for 45 seconds each time we start graphics from a different application. + The application graphics window will hode this when it opens, so we + stop showing it after 45 seconds to avoid wasting CPU cycles. + + clientscr/ + mac_saver_module.cpp + Mac_Saver_Module.h + screensaver.cpp diff --git a/clientscr/Mac_Saver_Module.h b/clientscr/Mac_Saver_Module.h index ef3cd69810..2f5db12549 100644 --- a/clientscr/Mac_Saver_Module.h +++ b/clientscr/Mac_Saver_Module.h @@ -79,7 +79,8 @@ protected: pid_t m_CoreClientPID; int m_dwBlankScreen; time_t m_dwBlankTime; - int m_statusUpdateCounter; + int m_iStatusUpdateCounter; + int m_iGraphicsStartingMsgCounter; int m_iLastResultShown; int m_tLastResultChangeCounter; bool m_StatusMessageUpdated; diff --git a/clientscr/mac_saver_module.cpp b/clientscr/mac_saver_module.cpp index 5aab39473d..f1e9e857c0 100644 --- a/clientscr/mac_saver_module.cpp +++ b/clientscr/mac_saver_module.cpp @@ -53,6 +53,7 @@ #define TEXTLOGOFREQUENCY 60 /* Number of times per second to update moving logo with text */ #define NOTEXTLOGOFREQUENCY 4 /* Times per second to call animateOneFrame if no moving logo with text */ #define STATUSUPDATEINTERVAL 5 /* seconds between status display updates */ +#define GFX_STARTING_MSG_DURATION 45 /* seconds to show ScreenSaverAppStartingMsg */ #define STATUSRESULTCHANGETIME 10 /* seconds to show status display for each task */ #define TASK_RUN_CHECK_PERIOD 5 /* Seconds between safety check that task is actually running */ @@ -88,6 +89,7 @@ const char * BOINCNoGraphicAppsExecutingMsg = "Project does not support graphic const char * BOINCUnrecoverableErrorMsg = "Sorry, an unrecoverable error occurred"; const char * BOINCTestmodeMsg = "BOINC screensaver test: success."; const char * BOINCV5GFXDaemonMsg = "BOINC can't display graphics from older applications when running as a daemon."; +const char * ScreenSaverAppStartingMsg = "Starting screensaver graphics. Please wait ..."; //const char * BOINCExitedSaverMode = "BOINC is no longer in screensaver mode."; @@ -124,7 +126,8 @@ CScreensaver::CScreensaver() { m_hrError = 0; m_StatusMessageUpdated = false; // Display first status update after 5 seconds - m_statusUpdateCounter = ((STATUSUPDATEINTERVAL-5) * TEXTLOGOFREQUENCY); + m_iStatusUpdateCounter = ((STATUSUPDATEINTERVAL-5) * TEXTLOGOFREQUENCY); + m_iGraphicsStartingMsgCounter = 0; m_iLastResultShown = 0; m_tLastResultChangeCounter = ((STATUSRESULTCHANGETIME-5) * TEXTLOGOFREQUENCY); saverState = SaverState_Idle; @@ -279,7 +282,7 @@ int CScreensaver::getSSMessage(char **theMessage) { pid_t myPid; OSStatus err; - m_statusUpdateCounter++; + m_iStatusUpdateCounter++; m_tLastResultChangeCounter++; switch (saverState) { @@ -334,10 +337,17 @@ int CScreensaver::getSSMessage(char **theMessage) { case SCRAPPERR_BOINCNOPROJECTSDETECTED: setSSMessageText(BOINCNoProjectsDetectedMsg); break; + case SCRAPPERR_BOINCAPPFOUNDGRAPHICSLOADING: case SCRAPPERR_SCREENSAVERRUNNING: #if ! ALWAYS_DISPLAY_PROGRESS_TEXT - setSSMessageText(0); // No text message - // Let the science app draw over our window + if (m_iGraphicsStartingMsgCounter > 0) { + // Show ScreenSaverAppStartingMsg for GFX_STARTING_MSG_DURATION seconds + setSSMessageText(ScreenSaverAppStartingMsg); + m_iGraphicsStartingMsgCounter--; + } else { + // Don't waste CPU cycles when the science app is drawing over our window + setSSMessageText(0); // No text message + } break; #endif case SCRAPPERR_BOINCNOGRAPHICSAPPSEXECUTING: @@ -476,6 +486,12 @@ bool CScreensaver::DestroyDataManagementThread() { bool CScreensaver::SetError(bool bErrorMode, unsigned int hrError) { m_bErrorMode = bErrorMode; m_hrError = hrError; + + if (hrError == SCRAPPERR_BOINCAPPFOUNDGRAPHICSLOADING) { + // Show ScreenSaverAppStartingMsg for GFX_STARTING_MSG_DURATION seconds + m_iGraphicsStartingMsgCounter = GFX_STARTING_MSG_DURATION * TEXTLOGOFREQUENCY; + } + if ((hrError == SCRAPPERR_BOINCNOGRAPHICSAPPSEXECUTING) || (hrError == SCRAPPERR_DAEMONALLOWSNOGRAPHICS) #if ALWAYS_DISPLAY_PROGRESS_TEXT @@ -497,9 +513,9 @@ void CScreensaver::UpdateProgressText(unsigned int hrError) { PROJECT* pProject; char statusBuf[2048]; - if ( (m_statusUpdateCounter >= (STATUSUPDATEINTERVAL * TEXTLOGOFREQUENCY) ) && !m_updating_results ) { + if ( (m_iStatusUpdateCounter >= (STATUSUPDATEINTERVAL * TEXTLOGOFREQUENCY) ) && !m_updating_results ) { if (! m_StatusMessageUpdated) { - m_statusUpdateCounter = 0; + m_iStatusUpdateCounter = 0; strcpy(m_MsgBuf, hrError == SCRAPPERR_DAEMONALLOWSNOGRAPHICS ? BOINCV5GFXDaemonMsg : BOINCNoGraphicAppsExecutingMsg ); @@ -541,7 +557,7 @@ void CScreensaver::UpdateProgressText(unsigned int hrError) { } // end for() loop m_StatusMessageUpdated = true; } // end if (! m_StatusMessageUpdated) - } // end if (m_statusUpdateCounter > time to update) + } // end if (m_iStatusUpdateCounter > time to update) } diff --git a/clientscr/screensaver.cpp b/clientscr/screensaver.cpp index a67cf333f1..ef60d5bf01 100644 --- a/clientscr/screensaver.cpp +++ b/clientscr/screensaver.cpp @@ -458,6 +458,9 @@ void *CScreensaver::DataManagementProc() { previous_result_ptr = NULL; graphics_app_result_ptr = NULL; } else { +#ifdef __APPLE__ + SetError(FALSE, SCRAPPERR_BOINCAPPFOUNDGRAPHICSLOADING); +#endif SetError(FALSE, SCRAPPERR_SCREENSAVERRUNNING); launch_time = dtime(); last_change_time = launch_time;