Ticket #463: 463_xss_1.patch
File 463_xss_1.patch, 2.8 KB (added by , 13 years ago) |
---|
-
configure.ac
549 549 550 550 AM_CONDITIONAL(BUILD_GRAPHICS_API, [ test "$have_glut" = yes ]) 551 551 552 dnl check for X screen saver lib 553 AC_CHECK_LIB([Xss], [XScreenSaverAllocInfo], [have_Xss="yes"], [have_Xss="no"]) 554 AC_CHECK_HEADER([X11/extensions/scrnsaver.h], [have_Xss="yes"], [have_Xss="no"]) 555 if test "$have_Xss" == no; then 556 AC_MSG_WARN([libxss missing, disabling X ScreenSaver user idle detection]) 557 fi 558 552 559 dnl -------------------------------------------------------------------------------- 553 560 dnl put double-inclusion protection into config.h 554 561 AH_TOP([ … … 791 798 fi 792 799 LIBS=$svlibs 793 800 801 if test "$have_Xss" == yes; then 802 SAH_CHECK_LIB([Xss],[XScreenSaverAllocInfo],[ 803 AC_DEFINE([HAVE_XSS],[1],[Define to 1 if you have xss library]) 804 CLIENTLIBS="${sah_lib_last} ${CLIENTLIBS}"]) 805 echo DEBUG: CLIENTLIBS=${CLIENTLIBS} >&5 806 fi 807 794 808 SAH_CHECK_LIB([resolv],[res_query],[ 795 809 AC_DEFINE([HAVE_RESOLV],[1],[Define to 1 if you have the resolv library]) 796 810 CLIENTLIBS="${sah_lib_last} ${CLIENTLIBS}"]) -
client/hostinfo_unix.cpp
149 149 #define _SC_PAGESIZE _SC_PAGE_SIZE 150 150 #endif 151 151 152 #if HAVE_XSS 153 #include <X11/extensions/scrnsaver.h> 154 #endif 155 152 156 // The following is intended to be true both on Linux 153 157 // and Debian GNU/kFreeBSD (see trac #521) 154 158 // … … 1679 1683 } 1680 1684 return last_irq < t; 1681 1685 } 1682 #endif1683 1686 1687 #if HAVE_XSS 1688 // Ask the X server for user idle time (using XScreenSaver API) 1689 // Returns true if the idle_treshold is smaller than the 1690 // idle time of the user (means: true = user is idle) 1691 bool xss_idle(long idle_treshold) { 1692 static XScreenSaverInfo* xssInfo = NULL; 1693 static Display* disp = NULL; 1694 1695 long idle_time = 0; 1696 1697 if(disp != NULL) { 1698 XScreenSaverQueryInfo(disp, DefaultRootWindow(disp), xssInfo); 1699 idle_time = xssInfo->idle / 1000; // xssInfo->idle is in ms 1700 } else { 1701 disp = XOpenDisplay(NULL); 1702 // XOpenDisplay may return NULL if there is no running X 1703 // or DISPLAY points to wrong/invalid display 1704 if(disp != NULL) { 1705 xssInfo = XScreenSaverAllocInfo(); 1706 } 1707 } 1708 1709 return idle_treshold < idle_time; 1710 } 1711 #endif // HAVE_XSS 1712 #endif // LINUX_LIKE_SYSTEM 1713 1684 1714 bool HOST_INFO::users_idle(bool check_all_logins, double idle_time_to_run) { 1685 1715 time_t idle_time = time(0) - (long) (60 * idle_time_to_run); 1686 1716 … … 1701 1731 if (!interrupts_idle(idle_time)) { 1702 1732 return false; 1703 1733 } 1734 1735 #if HAVE_XSS 1736 if (!xss_idle((long)(idle_time_to_run * 60))) { 1737 return false; 1738 } 1739 #endif 1740 1704 1741 #else 1705 1742 // We should find out which of the following are actually relevant 1706 1743 // on which systems (if any)