From 9e52a9db5c297283b25e4912b195fa823a117f06 Mon Sep 17 00:00:00 2001 From: Charlie Fenton Date: Fri, 13 Jan 2012 10:35:11 +0000 Subject: [PATCH] client: use old Mac idle detection when running as a daemon svn path=/trunk/boinc/; revision=25038 --- checkin_notes | 11 +++++++++++ client/hostinfo_unix.cpp | 14 ++++++++------ 2 files changed, 19 insertions(+), 6 deletions(-) diff --git a/checkin_notes b/checkin_notes index 9c0bed1368..82fc377cfb 100644 --- a/checkin_notes +++ b/checkin_notes @@ -439,3 +439,14 @@ Rom 12 Jan 2012 samples/vboxwrapper vboxwrapper.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 + diff --git a/client/hostinfo_unix.cpp b/client/hostinfo_unix.cpp index ec8730b06e..7ef6e72431 100644 --- a/client/hostinfo_unix.cpp +++ b/client/hostinfo_unix.cpp @@ -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), ¶ms, &rcnt );