mirror of https://github.com/BOINC/boinc.git
- client, linux: use X server for idle detection if available
svn path=/trunk/boinc/; revision=23035
This commit is contained in:
parent
c62a55b47f
commit
3b6325916f
|
@ -743,3 +743,10 @@ David 14 Feb 2011
|
||||||
html/user/
|
html/user/
|
||||||
sample_index.php
|
sample_index.php
|
||||||
main.css
|
main.css
|
||||||
|
|
||||||
|
David 14 Feb 2011
|
||||||
|
- client, linux: use X server for idle detection if available
|
||||||
|
|
||||||
|
configure.ac
|
||||||
|
client/
|
||||||
|
hostinfo_unix.cpp
|
||||||
|
|
|
@ -149,6 +149,10 @@ mach_port_t gEventHandle = NULL;
|
||||||
#define _SC_PAGESIZE _SC_PAGE_SIZE
|
#define _SC_PAGESIZE _SC_PAGE_SIZE
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if HAVE_XSS
|
||||||
|
#include <X11/extensions/scrnsaver.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
// The following is intended to be true both on Linux
|
// The following is intended to be true both on Linux
|
||||||
// and Debian GNU/kFreeBSD (see trac #521)
|
// and Debian GNU/kFreeBSD (see trac #521)
|
||||||
//
|
//
|
||||||
|
@ -1679,7 +1683,33 @@ bool interrupts_idle(time_t t) {
|
||||||
}
|
}
|
||||||
return last_irq < t;
|
return last_irq < t;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
#if HAVE_XSS
|
||||||
|
// Ask the X server for user idle time (using XScreenSaver API)
|
||||||
|
// Returns true if the idle_treshold is smaller than the
|
||||||
|
// idle time of the user (means: true = user is idle)
|
||||||
|
bool xss_idle(long idle_treshold) {
|
||||||
|
static XScreenSaverInfo* xssInfo = NULL;
|
||||||
|
static Display* disp = NULL;
|
||||||
|
|
||||||
|
long idle_time = 0;
|
||||||
|
|
||||||
|
if(disp != NULL) {
|
||||||
|
XScreenSaverQueryInfo(disp, DefaultRootWindow(disp), xssInfo);
|
||||||
|
idle_time = xssInfo->idle / 1000; // xssInfo->idle is in ms
|
||||||
|
} else {
|
||||||
|
disp = XOpenDisplay(NULL);
|
||||||
|
// XOpenDisplay may return NULL if there is no running X
|
||||||
|
// or DISPLAY points to wrong/invalid display
|
||||||
|
if(disp != NULL) {
|
||||||
|
xssInfo = XScreenSaverAllocInfo();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return idle_treshold < idle_time;
|
||||||
|
}
|
||||||
|
#endif // HAVE_XSS
|
||||||
|
#endif // LINUX_LIKE_SYSTEM
|
||||||
|
|
||||||
bool HOST_INFO::users_idle(bool check_all_logins, double idle_time_to_run) {
|
bool HOST_INFO::users_idle(bool check_all_logins, double idle_time_to_run) {
|
||||||
time_t idle_time = time(0) - (long) (60 * idle_time_to_run);
|
time_t idle_time = time(0) - (long) (60 * idle_time_to_run);
|
||||||
|
@ -1701,6 +1731,13 @@ bool HOST_INFO::users_idle(bool check_all_logins, double idle_time_to_run) {
|
||||||
if (!interrupts_idle(idle_time)) {
|
if (!interrupts_idle(idle_time)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if HAVE_XSS
|
||||||
|
if (!xss_idle((long)(idle_time_to_run * 60))) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
#else
|
#else
|
||||||
// We should find out which of the following are actually relevant
|
// We should find out which of the following are actually relevant
|
||||||
// on which systems (if any)
|
// on which systems (if any)
|
||||||
|
|
14
configure.ac
14
configure.ac
|
@ -549,6 +549,13 @@ fi
|
||||||
|
|
||||||
AM_CONDITIONAL(BUILD_GRAPHICS_API, [ test "$have_glut" = yes ])
|
AM_CONDITIONAL(BUILD_GRAPHICS_API, [ test "$have_glut" = yes ])
|
||||||
|
|
||||||
|
dnl check for X screen saver lib
|
||||||
|
AC_CHECK_LIB([Xss], [XScreenSaverAllocInfo], [have_Xss="yes"], [have_Xss="no"])
|
||||||
|
AC_CHECK_HEADER([X11/extensions/scrnsaver.h], [have_Xss="yes"], [have_Xss="no"])
|
||||||
|
if test "$have_Xss" == no; then
|
||||||
|
AC_MSG_WARN([libxss missing, disabling X ScreenSaver user idle detection])
|
||||||
|
fi
|
||||||
|
|
||||||
dnl --------------------------------------------------------------------------------
|
dnl --------------------------------------------------------------------------------
|
||||||
dnl put double-inclusion protection into config.h
|
dnl put double-inclusion protection into config.h
|
||||||
AH_TOP([
|
AH_TOP([
|
||||||
|
@ -791,6 +798,13 @@ if test "${ac_cv_func_res_init}" != "yes" ; then
|
||||||
fi
|
fi
|
||||||
LIBS=$svlibs
|
LIBS=$svlibs
|
||||||
|
|
||||||
|
if test "$have_Xss" == yes; then
|
||||||
|
SAH_CHECK_LIB([Xss],[XScreenSaverAllocInfo],[
|
||||||
|
AC_DEFINE([HAVE_XSS],[1],[Define to 1 if you have xss library])
|
||||||
|
CLIENTLIBS="${sah_lib_last} ${CLIENTLIBS}"])
|
||||||
|
echo DEBUG: CLIENTLIBS=${CLIENTLIBS} >&5
|
||||||
|
fi
|
||||||
|
|
||||||
SAH_CHECK_LIB([resolv],[res_query],[
|
SAH_CHECK_LIB([resolv],[res_query],[
|
||||||
AC_DEFINE([HAVE_RESOLV],[1],[Define to 1 if you have the resolv library])
|
AC_DEFINE([HAVE_RESOLV],[1],[Define to 1 if you have the resolv library])
|
||||||
CLIENTLIBS="${sah_lib_last} ${CLIENTLIBS}"])
|
CLIENTLIBS="${sah_lib_last} ${CLIENTLIBS}"])
|
||||||
|
|
Loading…
Reference in New Issue