Skip to content

Commit

Permalink
- WINSCR: Fix the BOINC text displayed is the screensaver control
Browse files Browse the repository at this point in the history
        panel applet
    - WINSCR: Get rid of the 'Up to 5 second wait' for the data thread
        to terminate.  Force terminate the thread and clean up the
        graphics app in a clean-up routine.  Forcing the user to wait
        when they return to the system isn't a good idea.
    - WINSCR: Fix screensaver issue where the screensaver locks up
        when the graphics application deadlocks for one reason or
        another.
        
        Create two new threads:
          1. Monitor system for keyboard and mouse events.
          2. Shuffle window z-order positions if needed.
          
        The keyboard/mouse event monitor is isolated from either
          the core client getting stuck in a loop and not returning
          the results of an RPC or the window shuffling code which
          can get stuck if the graphics application dead locks.
          
        The window shuffle code is isolated due to the
          BroadcastSystemMessage() API using something akin to
          SendMessage() which waits for a return value from the
          target windows winproc.  If a graphics application
          deadlocks for one reason or another it'll cause
          the thread to stall.  This isn't terminal and so we
          just wait for the next time the data thread chooses
          a new application and terminates the old one which
          will cause the thread to resume.
          
        This should resolve all outstanding issues with the
          screensaver not exiting when the mouse or keyboard
          is used.
          
    clientscr/
        boinc_ss.rc
        screensaver.cpp
        screensaver_win.cpp, .h

svn path=/trunk/boinc/; revision=17336
  • Loading branch information
romw committed Feb 23, 2009
1 parent 2574afb commit b402864
Show file tree
Hide file tree
Showing 5 changed files with 417 additions and 319 deletions.
40 changes: 40 additions & 0 deletions checkin_notes
Original file line number Diff line number Diff line change
Expand Up @@ -1899,3 +1899,43 @@ David 22 Feb 2009
scheduler_op.cpp
app.cpp
app_control.cpp

Rom 22 Feb 2009
- WINSCR: Fix the BOINC text displayed is the screensaver control
panel applet
- WINSCR: Get rid of the 'Up to 5 second wait' for the data thread
to terminate. Force terminate the thread and clean up the
graphics app in a clean-up routine. Forcing the user to wait
when they return to the system isn't a good idea.
- WINSCR: Fix screensaver issue where the screensaver locks up
when the graphics application deadlocks for one reason or
another.

Create two new threads:
1. Monitor system for keyboard and mouse events.
2. Shuffle window z-order positions if needed.

The keyboard/mouse event monitor is isolated from either
the core client getting stuck in a loop and not returning
the results of an RPC or the window shuffling code which
can get stuck if the graphics application dead locks.

The window shuffle code is isolated due to the
BroadcastSystemMessage() API using something akin to
SendMessage() which waits for a return value from the
target windows winproc. If a graphics application
deadlocks for one reason or another it'll cause
the thread to stall. This isn't terminal and so we
just wait for the next time the data thread chooses
a new application and terminates the old one which
will cause the thread to resume.

This should resolve all outstanding issues with the
screensaver not exiting when the mouse or keyboard
is used.

clientscr/
boinc_ss.rc
screensaver.cpp
screensaver_win.cpp, .h

5 changes: 5 additions & 0 deletions clientscr/boinc_ss.rc
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,7 @@ IDB_BOINCSPLAT BITMAP "res\\boinc.bmp"

STRINGTABLE
BEGIN
IDS_DESCRIPTION "GridRepublic"
IDS_ERR_GENERIC "There was an unspecified problem\nwith the GridRepublic screensaver."
IDS_ERR_BOINCNOTDETECTED
"GridRepublic is not running.\n\nPlease launch GridRepublic to display graphics."
Expand All @@ -275,6 +276,7 @@ END

STRINGTABLE
BEGIN
IDS_DESCRIPTION "World Community Grid"
IDS_ERR_GENERIC "There was an unspecified problem\nwith the World Community Grid screensaver."
IDS_ERR_BOINCNOTDETECTED
"World Community Grid is not running.\n\nPlease launch World Community Grid\nto display graphics."
Expand All @@ -299,6 +301,7 @@ END

STRINGTABLE
BEGIN
IDS_DESCRIPTION "BOINC"
IDS_ERR_GENERIC "There was an unspecified problem\nwith the BOINC screensaver."
IDS_ERR_BOINCNOTDETECTED
"BOINC is not running.\n\nPlease launch BOINC to display graphics."
Expand Down Expand Up @@ -327,6 +330,8 @@ BEGIN
IDS_ERR_NOPREVIEW "No preview available"
END



#endif // English (U.S.) resources
/////////////////////////////////////////////////////////////////////////////

Expand Down
59 changes: 23 additions & 36 deletions clientscr/screensaver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -420,12 +420,10 @@ void *CScreensaver::DataManagementProc()
default_data_dir_path = "/Library/Application Support/BOINC Data";
default_ss_dir_path = default_data_dir_path;
#else
UtilGetRegDirectoryStr(_T("INSTALLDIR"), &default_ss_dir_path);
BOINCTRACE(_T("CScreensaver::DataManagementProc - default_ss_dir_path = '%s'\n"), default_ss_dir_path);
retval = UtilGetRegDirectoryStr(_T("DATADIR"), &default_data_dir_path);
BOINCTRACE(_T("CScreensaver::DataManagementProc - default_data_dir_path = '%s'\n"), default_data_dir_path);
retval = 0;
default_data_dir_path = (char*)m_strBOINCDataDirectory.c_str();
default_ss_dir_path = (char*)m_strBOINCInstallDirectory.c_str();
#endif

strlcpy(full_path, default_ss_dir_path, sizeof(full_path));
strlcat(full_path, PATH_SEPARATOR, sizeof(full_path));
strlcat(full_path, THE_DEFAULT_SS_EXECUTABLE, sizeof(full_path));
Expand All @@ -445,6 +443,8 @@ retval = 0;
GetDisplayPeriods(default_data_dir_path);

while (true) {

#ifndef _WIN32
for (int i = 0; i < 4; i++) {
// ***
// *** Things that should be run frequently.
Expand All @@ -459,32 +459,11 @@ retval = 0;
previous_result_ptr = NULL;
m_hGraphicsApplication = 0;
}
#ifdef _WIN32
if (default_ss_dir_path) free(default_ss_dir_path);
default_ss_dir_path = NULL;
if (default_data_dir_path) free(default_data_dir_path);
default_data_dir_path = NULL;
#endif
return 0; // Exit the thread
}

#ifdef _WIN32

// Check for keyboard and mouse activity just in case the
// user wants to blow out of the screensaver.
//
CheckKeyboardMouseActivity();

// Check to see if there are any notification windows from
// personal firewalls, virus scanners, or anything else that
// demands the users attention. If there is blow out of the
// screensaver
CheckForNotificationWindow();

#endif

boinc_sleep(0.25);
}
#endif

// ***
// *** Things that should be run frequently.
Expand All @@ -495,12 +474,22 @@ retval = 0;
if ((m_dwBlankScreen) && (time(0) > m_dwBlankTime)) {
BOINCTRACE(_T("CScreensaver::DataManagementProc - Time to blank\n"));
SetError(FALSE, SCRAPPERR_SCREENSAVERBLANKED);
#ifndef _WIN32
m_QuitDataManagementProc = true;
#else
if (m_hGraphicsApplication || graphics_app_result_ptr) {
terminate_screensaver(m_hGraphicsApplication, graphics_app_result_ptr);
graphics_app_result_ptr = NULL;
previous_result_ptr = NULL;
m_hGraphicsApplication = 0;
}
return 0; // Exit the thread
#endif
}

BOINCTRACE(_T("CScreensaver::DataManagementProc - ErrorMode = '%d', ErrorCode = '%x'\n"), m_bErrorMode, m_hrError);

if (! m_bConnected) {
if (!m_bConnected) {
HandleRPCError();
}

Expand Down Expand Up @@ -697,10 +686,10 @@ retval = 0;
graphics_app_result_ptr = NULL;
m_bScience_gfx_running = false;
} else {
#ifdef __APPLE__
#ifdef __APPLE__
// Show ScreenSaverAppStartingMsg for GFX_STARTING_MSG_DURATION seconds
SetError(FALSE, SCRAPPERR_BOINCAPPFOUNDGRAPHICSLOADING);
#endif
#endif
SetError(FALSE, SCRAPPERR_SCREENSAVERRUNNING);
last_change_time = dtime();
m_bScience_gfx_running = true;
Expand Down Expand Up @@ -781,14 +770,12 @@ retval = 0;
m_bDefault_gfx_running = false;
m_bScience_gfx_running = false;
continue;
} else {
#ifdef _WIN32
CheckForegroundWindow();
#endif
}
}

} // end while(true)
#ifdef _WIN32
boinc_sleep(1.0);
#endif
} // end while(true)
}


Expand Down
Loading

0 comments on commit b402864

Please sign in to comment.