- client: Account for the display management power system when

calculating idle time from the XSS system on Linux.
This commit is contained in:
Rom Walton 2013-01-01 14:05:58 -05:00 committed by Oliver Bock
parent 9209a887cc
commit 4ee64625c1
3 changed files with 59 additions and 1 deletions

View File

@ -7989,3 +7989,10 @@ David 29 Dec 2012
client/ client/
gui_rpc_server_ops.cpp 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

View File

@ -150,6 +150,10 @@ mach_port_t gEventHandle = NULL;
#define _SC_PAGESIZE _SC_PAGE_SIZE #define _SC_PAGESIZE _SC_PAGE_SIZE
#endif #endif
#if HAVE_DPMS
#include <X11/extensions/dpms.h>
#endif
#if HAVE_XSS #if HAVE_XSS
#include <X11/extensions/scrnsaver.h> #include <X11/extensions/scrnsaver.h>
#endif #endif
@ -1806,7 +1810,51 @@ bool xss_idle(long idle_treshold) {
if(disp != NULL) { if(disp != NULL) {
XScreenSaverQueryInfo(disp, DefaultRootWindow(disp), xssInfo); 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 { } else {
disp = XOpenDisplay(NULL); disp = XOpenDisplay(NULL);
// XOpenDisplay may return NULL if there is no running X // XOpenDisplay may return NULL if there is no running X

View File

@ -847,6 +847,9 @@ fi
LIBS=$svlibs LIBS=$svlibs
if (test "$enable_xss" == yes) && (test "$have_Xss" == yes); then 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],[ SAH_CHECK_LIB([Xss],[XScreenSaverAllocInfo],[
AC_DEFINE([HAVE_XSS],[1],[Define to 1 if you have xss library]) AC_DEFINE([HAVE_XSS],[1],[Define to 1 if you have xss library])
CLIENTLIBS="${sah_lib_last} ${CLIENTLIBS}"]) CLIENTLIBS="${sah_lib_last} ${CLIENTLIBS}"])