Ticket #463: 463_xss.patch
File 463_xss.patch, 1.6 KB (added by , 13 years ago) |
---|
-
client/hostinfo_unix.cpp
149 149 #define _SC_PAGESIZE _SC_PAGE_SIZE 150 150 #endif 151 151 152 #include <X11/extensions/scrnsaver.h> // TODO encaps in ifdefs 153 152 154 // The following is intended to be true both on Linux 153 155 // and Debian GNU/kFreeBSD (see trac #521) 154 156 // … … 1628 1630 } 1629 1631 return last_irq < t; 1630 1632 } 1631 #endif1632 1633 1634 // Ask the X server for user idle time (using XScreenSaver API) 1635 // Returns true if the idle_treshold is smaller than the 1636 // idle time of the user (means: true = user is idle) 1637 bool xss_idle(long idle_treshold) { 1638 static XScreenSaverInfo* xssInfo = XScreenSaverAllocInfo(); 1639 static Display* disp = XOpenDisplay(NULL); 1640 long idle_time = 0; 1641 1642 if(disp != NULL) { 1643 XScreenSaverQueryInfo(disp, DefaultRootWindow(disp), xssInfo); 1644 idle_time = xssInfo->idle / 1000; // xssInfo->idle is in ms 1645 } else { 1646 msg_printf(NULL, MSG_INFO, "Cannot find default display. DISPLAY set?"); 1647 } 1648 //msg_printf(NULL, MSG_INFO, "tresh: %ld idle_time: %ld", idle_treshold, idle_time); 1649 return idle_treshold < idle_time; 1650 } 1651 #endif // LINUX_LIKE_SYSTEM 1652 1633 1653 bool HOST_INFO::users_idle(bool check_all_logins, double idle_time_to_run) { 1634 1654 time_t idle_time = time(0) - (long) (60 * idle_time_to_run); 1635 1655 … … 1650 1670 if (!interrupts_idle(idle_time)) { 1651 1671 return false; 1652 1672 } 1673 1674 if (!xss_idle((long)(idle_time_to_run * 60))) { 1675 return false; 1676 } 1653 1677 #else 1654 1678 // We should find out which of the following are actually relevant 1655 1679 // on which systems (if any)