client: use old Mac idle detection when running as a daemon

svn path=/branches/boinc_core_release_7_0/; revision=25039
This commit is contained in:
Charlie Fenton 2012-01-13 10:37:58 +00:00
parent f4cf96319b
commit 2326697643
2 changed files with 18 additions and 6 deletions

View File

@ -9080,3 +9080,13 @@ Charlie 11 Jan 2012
clientgui/
BOINCClientManager.cpp
Charlie 13 Jan 2012
- client: Due to my changes of 10 Jan 2012, idle detection did not work
when BOINC was run as a pre-login daemon. So use the old method
when running as a daemon. This means that idle detection for Apple
Remote Desktop and screen sharing (VNC) under Mac OS 10.7 works only
when not running BOINC as a daemon.
client/
hostinfo_unix.cpp

View File

@ -1587,9 +1587,12 @@ inline bool user_idle(time_t t, struct utmp* u) {
// In OS 10.7, IOHIDGetParameter() fails to recognize activity from remote
// logins via Apple Remote Desktop or Screen Sharing (VNC), but the
// CGEventSourceSecondsSinceLastEventType() API does work with ARD and VNC,
// and CGEventSourceSecondsSinceLastEventType() does work even when BOINC
// is a pre-login launchd daemon running as user boinc_master, provided that
// it is not called too soon after system restart.
// except when BOINC is a pre-login launchd daemon running as user boinc_master.
//
// So as a workaround in OS 10.7, we use CGEventSourceSecondsSinceLastEventType
// unless running as a daemon. Therefore BOINC still won't detect activity from
// remote via Apple Remote Desktop or Screen Sharing (VNC) when run as a daemon
// under OS 10.7.
//
// So we use weak-linking of NxIdleTime() to prevent a run-time crash from the
// dynamic linker and use it if it exists.
@ -1644,11 +1647,10 @@ bool HOST_INFO::users_idle(
}
}
} else { // NXIdleTime API does not exist in OS 10.6 and later
if (OSVersionInfo >= 0x1070) {
if (TickCount() > (120*60)) { // If system has been up for more than 2 minutes
if ((OSVersionInfo >= 0x1070) && (! gstate.executing_as_daemon)) {
idleTime = CGEventSourceSecondsSinceLastEventType
(kCGEventSourceStateCombinedSessionState, kCGAnyInputEventType);
}
} else { // OS Version < 10.7
if (gEventHandle) {
kernResult = IOHIDGetParameter( gEventHandle, CFSTR(EVSIOIDLE), sizeof(UInt64), &params, &rcnt );