mirror of https://github.com/BOINC/boinc.git
SS: Fixes for dual-GPU Macbook Pros (continued).
- If user preferences allow "Run while on battery" then run boincscr or project screensavers even when dual-GPU Macbook Pro is on battery power - Replace a deprecated API (applies to all Macs)
This commit is contained in:
parent
ec0fd879a9
commit
65294bc6de
|
@ -274,7 +274,7 @@ int signof(float x) {
|
||||||
NSImage *myImage = [[ NSImage alloc ] initWithContentsOfFile:fileName ];
|
NSImage *myImage = [[ NSImage alloc ] initWithContentsOfFile:fileName ];
|
||||||
[ myImage setScalesWhenResized:YES ];
|
[ myImage setScalesWhenResized:YES ];
|
||||||
[ myImage setSize:theFrame.size ];
|
[ myImage setSize:theFrame.size ];
|
||||||
[ myImage compositeToPoint:NSZeroPoint operation:NSCompositeSourceOver ];
|
[ myImage drawAtPoint:NSZeroPoint fromRect:NSZeroRect operation:NSCompositeSourceOver fraction:1.0 ];
|
||||||
[ myImage release ];
|
[ myImage release ];
|
||||||
}
|
}
|
||||||
[ self setAnimationTimeInterval:1/1.0 ];
|
[ self setAnimationTimeInterval:1/1.0 ];
|
||||||
|
@ -449,7 +449,7 @@ int signof(float x) {
|
||||||
imagePosition.x = (float) ((int)gCurrentPosition.x + gImageXIndent);
|
imagePosition.x = (float) ((int)gCurrentPosition.x + gImageXIndent);
|
||||||
imagePosition.y = (float) (int)gCurrentPosition.y;
|
imagePosition.y = (float) (int)gCurrentPosition.y;
|
||||||
|
|
||||||
[ gBOINC_Logo compositeToPoint:imagePosition operation:NSCompositeCopy ];
|
[ gBOINC_Logo drawAtPoint:imagePosition fromRect:NSZeroRect operation:NSCompositeCopy fraction:1.0 ];
|
||||||
|
|
||||||
if ( (msg != NULL) && (msg[0] != '\0') ) {
|
if ( (msg != NULL) && (msg[0] != '\0') ) {
|
||||||
cf_msg = CFStringCreateWithCString(NULL, msg, kCFStringEncodingMacRoman);
|
cf_msg = CFStringCreateWithCString(NULL, msg, kCFStringEncodingMacRoman);
|
||||||
|
|
|
@ -86,6 +86,7 @@ static SaverState saverState = SaverState_Idle;
|
||||||
|
|
||||||
static bool IsDualGPUMacbook = false;
|
static bool IsDualGPUMacbook = false;
|
||||||
static io_connect_t GPUSelectConnect = IO_OBJECT_NULL;
|
static io_connect_t GPUSelectConnect = IO_OBJECT_NULL;
|
||||||
|
static bool OKToRunOnBatteries = false;
|
||||||
static bool RunningOnBattery = true;
|
static bool RunningOnBattery = true;
|
||||||
static time_t ScreenSaverStartTime = 0;
|
static time_t ScreenSaverStartTime = 0;
|
||||||
static bool ScreenIsBlanked = false;
|
static bool ScreenIsBlanked = false;
|
||||||
|
@ -100,11 +101,10 @@ const char * ScreenSaverAppStartingMsg = "Starting screensaver graphics.\nPleas
|
||||||
const char * CantLaunchDefaultGFXAppMsg = "Can't launch default screensaver module. Please reinstall BOINC";
|
const char * CantLaunchDefaultGFXAppMsg = "Can't launch default screensaver module. Please reinstall BOINC";
|
||||||
const char * DefaultGFXAppCantRPCMsg = "Default screensaver module couldn't connect to BOINC application";
|
const char * DefaultGFXAppCantRPCMsg = "Default screensaver module couldn't connect to BOINC application";
|
||||||
const char * DefaultGFXAppCrashedMsg = "Default screensaver module had an unrecoverable error";
|
const char * DefaultGFXAppCrashedMsg = "Default screensaver module had an unrecoverable error";
|
||||||
const char * RunningOnBatteryMsg = "Displaying minimum screensaver to save battery power";
|
const char * RunningOnBatteryMsg = "Computing and screensaver disabled while running on battery power.";
|
||||||
|
|
||||||
//const char * BOINCExitedSaverMode = "BOINC is no longer in screensaver mode.";
|
//const char * BOINCExitedSaverMode = "BOINC is no longer in screensaver mode.";
|
||||||
|
|
||||||
void force_discrete_gpu() {}; // To satisfy the linker
|
|
||||||
|
|
||||||
// If there are multiple displays, this may get called
|
// If there are multiple displays, this may get called
|
||||||
// multiple times (once for each display), so we need to guard
|
// multiple times (once for each display), so we need to guard
|
||||||
|
@ -441,6 +441,7 @@ int CScreensaver::getSSMessage(char **theMessage, int* coveredFreq) {
|
||||||
int newFrequency = TEXTLOGOFREQUENCY;
|
int newFrequency = TEXTLOGOFREQUENCY;
|
||||||
*coveredFreq = 0;
|
*coveredFreq = 0;
|
||||||
pid_t myPid;
|
pid_t myPid;
|
||||||
|
CC_STATE state;
|
||||||
OSStatus err;
|
OSStatus err;
|
||||||
|
|
||||||
if (ScreenIsBlanked) {
|
if (ScreenIsBlanked) {
|
||||||
|
@ -457,11 +458,6 @@ int CScreensaver::getSSMessage(char **theMessage, int* coveredFreq) {
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case SaverState_LaunchingCoreClient:
|
case SaverState_LaunchingCoreClient:
|
||||||
if (IsDualGPUMacbook && RunningOnBattery) {
|
|
||||||
setSSMessageText(RunningOnBatteryMsg);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (m_wasAlreadyRunning) {
|
if (m_wasAlreadyRunning) {
|
||||||
setSSMessageText(ConnectingCCMsg);
|
setSSMessageText(ConnectingCCMsg);
|
||||||
} else {
|
} else {
|
||||||
|
@ -473,9 +469,23 @@ int CScreensaver::getSSMessage(char **theMessage, int* coveredFreq) {
|
||||||
saverState = SaverState_CoreClientRunning;
|
saverState = SaverState_CoreClientRunning;
|
||||||
if (!rpc->init(NULL)) { // Initialize communications with Core Client
|
if (!rpc->init(NULL)) { // Initialize communications with Core Client
|
||||||
m_bConnected = true;
|
m_bConnected = true;
|
||||||
|
if (IsDualGPUMacbook) {
|
||||||
|
state.clear();
|
||||||
|
state.global_prefs.clear_bools();
|
||||||
|
int result = rpc->get_state(state);
|
||||||
|
if (!result) {
|
||||||
|
OKToRunOnBatteries = state.global_prefs.run_on_batteries;
|
||||||
|
} else {
|
||||||
|
OKToRunOnBatteries = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (OKToRunOnBatteries) {
|
||||||
|
SetDiscreteGPU(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set up a separate thread for communicating with Core Client
|
// Set up a separate thread for communicating with Core Client
|
||||||
// and running screensaver graphics
|
// and running screensaver graphics
|
||||||
CreateDataManagementThread();
|
CreateDataManagementThread();
|
||||||
// ToDo: Add a timeout after which we display error message
|
// ToDo: Add a timeout after which we display error message
|
||||||
|
@ -489,20 +499,21 @@ int CScreensaver::getSSMessage(char **theMessage, int* coveredFreq) {
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case SaverState_CoreClientRunning:
|
case SaverState_CoreClientRunning:
|
||||||
if (IsDualGPUMacbook && RunningOnBattery) {
|
if (IsDualGPUMacbook && RunningOnBattery && !OKToRunOnBatteries) {
|
||||||
setSSMessageText(RunningOnBatteryMsg);
|
setSSMessageText(RunningOnBatteryMsg);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
// RPC called in DataManagementProc()
|
// RPC called in DataManagementProc()
|
||||||
setSSMessageText(ConnectingCCMsg);
|
setSSMessageText(ConnectingCCMsg);
|
||||||
|
|
||||||
if (! m_bResetCoreState) {
|
if (! m_bResetCoreState) {
|
||||||
saverState = SaverState_ConnectedToCoreClient;
|
saverState = SaverState_ConnectedToCoreClient;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case SaverState_ConnectedToCoreClient:
|
case SaverState_ConnectedToCoreClient:
|
||||||
if (IsDualGPUMacbook && RunningOnBattery) {
|
if (IsDualGPUMacbook && RunningOnBattery && !OKToRunOnBatteries) {
|
||||||
setSSMessageText(RunningOnBatteryMsg);
|
setSSMessageText(RunningOnBatteryMsg);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -583,7 +594,11 @@ int CScreensaver::getSSMessage(char **theMessage, int* coveredFreq) {
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case SaverState_CantLaunchCoreClient:
|
case SaverState_CantLaunchCoreClient:
|
||||||
setSSMessageText(CantLaunchCCMsg);
|
if (IsDualGPUMacbook && RunningOnBattery && !OKToRunOnBatteries) {
|
||||||
|
setSSMessageText(RunningOnBatteryMsg);
|
||||||
|
} else {
|
||||||
|
setSSMessageText(CantLaunchCCMsg);
|
||||||
|
}
|
||||||
// Set up a separate thread for running screensaver graphics
|
// Set up a separate thread for running screensaver graphics
|
||||||
// even if we can't communicate with core client
|
// even if we can't communicate with core client
|
||||||
CreateDataManagementThread();
|
CreateDataManagementThread();
|
||||||
|
@ -593,7 +608,7 @@ int CScreensaver::getSSMessage(char **theMessage, int* coveredFreq) {
|
||||||
break; // Should never get here; fixes compiler warning
|
break; // Should never get here; fixes compiler warning
|
||||||
} // end switch (saverState)
|
} // end switch (saverState)
|
||||||
|
|
||||||
if (IsDualGPUMacbook && RunningOnBattery) {
|
if (IsDualGPUMacbook && RunningOnBattery && !OKToRunOnBatteries) {
|
||||||
if ((m_dwBlankScreen) && (time(0) > m_dwBlankTime) && (m_dwBlankTime > 0)) {
|
if ((m_dwBlankScreen) && (time(0) > m_dwBlankTime) && (m_dwBlankTime > 0)) {
|
||||||
setSSMessageText(0); // No text message
|
setSSMessageText(0); // No text message
|
||||||
ScreenIsBlanked = true;
|
ScreenIsBlanked = true;
|
||||||
|
@ -704,7 +719,7 @@ bool CScreensaver::CreateDataManagementThread() {
|
||||||
// applications trigger a switch to the power-hungry
|
// applications trigger a switch to the power-hungry
|
||||||
// discrete GPU. To extend battery life, don't run
|
// discrete GPU. To extend battery life, don't run
|
||||||
// them when on battery power.
|
// them when on battery power.
|
||||||
if (IsDualGPUMacbook && RunningOnBattery) return true;
|
if (IsDualGPUMacbook && RunningOnBattery && !OKToRunOnBatteries) return true;
|
||||||
|
|
||||||
if (m_hDataManagementThread == NULL) {
|
if (m_hDataManagementThread == NULL) {
|
||||||
retval = pthread_create(&m_hDataManagementThread, NULL, DataManagementProcStub, 0);
|
retval = pthread_create(&m_hDataManagementThread, NULL, DataManagementProcStub, 0);
|
||||||
|
@ -971,6 +986,7 @@ void CScreensaver::CheckDualGPUStatus() {
|
||||||
bool nowOnBattery;
|
bool nowOnBattery;
|
||||||
|
|
||||||
if (!IsDualGPUMacbook) return;
|
if (!IsDualGPUMacbook) return;
|
||||||
|
if (OKToRunOnBatteries) return;
|
||||||
|
|
||||||
currentTime = dtime();
|
currentTime = dtime();
|
||||||
if (currentTime < lastBatteryCheckTime + BATTERY_CHECK_INTERVAL) return;
|
if (currentTime < lastBatteryCheckTime + BATTERY_CHECK_INTERVAL) return;
|
||||||
|
|
Loading…
Reference in New Issue