diff --git a/checkin_notes b/checkin_notes index fcab8ec83d..c396ad3814 100644 --- a/checkin_notes +++ b/checkin_notes @@ -7989,3 +7989,10 @@ David 29 Dec 2012 client/ gui_rpc_server_ops.cpp + +Rom 1 Jan 2013 + - client: Account for the display management power system when + calculating idle time from the XSS system on Linux. + + client/ + hostinfo_unix.cpp \ No newline at end of file diff --git a/client/hostinfo_unix.cpp b/client/hostinfo_unix.cpp index fcfe9f515f..59e6dfc0e6 100644 --- a/client/hostinfo_unix.cpp +++ b/client/hostinfo_unix.cpp @@ -150,6 +150,10 @@ mach_port_t gEventHandle = NULL; #define _SC_PAGESIZE _SC_PAGE_SIZE #endif +#if HAVE_DPMS +#include +#endif + #if HAVE_XSS #include #endif @@ -1806,7 +1810,51 @@ bool xss_idle(long idle_treshold) { if(disp != NULL) { XScreenSaverQueryInfo(disp, DefaultRootWindow(disp), xssInfo); - idle_time = xssInfo->idle / 1000; // xssInfo->idle is in ms + + idle_time = xssInfo->idle; + +#if HAVE_DPMS + int dummy; + CARD16 standby, suspend, off; + CARD16 state; + BOOL onoff; + + if (DPMSQueryExtension(disp, &dummy, &dummy)) { + if (DPMSCapable(disp)) { + DPMSGetTimeouts(disp, &standby, &suspend, &off); + DPMSInfo(disp, &state, &onoff); + + if (onoff) { + switch (state) { + case DPMSModeStandby: + /* this check is a littlebit paranoid, but be sure */ + if (idle_time < (unsigned) (standby * 1000)) { + idle_time += (standby * 1000); + } + break; + case DPMSModeSuspend: + if (idle_time < (unsigned) ((suspend + standby) * 1000)) { + idle_time += ((suspend + standby) * 1000); + } + break; + case DPMSModeOff: + if (idle_time < (unsigned) ((off + suspend + standby) * 1000)) { + idle_time += ((off + suspend + standby) * 1000); + } + break; + case DPMSModeOn: + default: + break; + } + } + + } + } +#endif + + // convert from milliseconds to seconds + idle_time = idle_time / 1000; + } else { disp = XOpenDisplay(NULL); // XOpenDisplay may return NULL if there is no running X diff --git a/configure.ac b/configure.ac index beaf68cde2..53f4db62dc 100644 --- a/configure.ac +++ b/configure.ac @@ -847,6 +847,9 @@ fi LIBS=$svlibs if (test "$enable_xss" == yes) && (test "$have_Xss" == yes); then + SAH_CHECK_LIB([xcb-dpms],[DPMSQueryExtension],[ + AC_DEFINE([HAVE_DPMS],[1],[Define to 1 if you have xcb-dpms library]) + CLIENTLIBS="${sah_lib_last} ${CLIENTLIBS}"]) SAH_CHECK_LIB([Xss],[XScreenSaverAllocInfo],[ AC_DEFINE([HAVE_XSS],[1],[Define to 1 if you have xss library]) CLIENTLIBS="${sah_lib_last} ${CLIENTLIBS}"])