Thomas Langston 检查 pidgin (libpurple) 是如何工作的想法非常有帮助。我下载了源代码,发现了这个——
在 pidgin-2.10.0/pidgin/gtkidle.c 从第 46 行开始:
/*
* Get the number of seconds the user has been idle. In Unix-world
* this is based on the X Windows usage. In MS Windows this is
* based on keyboard/mouse usage information obtained from the OS.
* In MacOS X, this is based on keyboard/mouse usage information
* obtained from the OS, if configure detected IOKit. Otherwise,
* MacOS X is handled as a case of X Windows.
*
* In Debian bug #271639, jwz says:
*
* Purple should simply ask xscreensaver how long the user has been idle:
* % xscreensaver-command -time
* XScreenSaver 4.18: screen blanked since Tue Sep 14 14:10:45 2004
*
* Or you can monitor the _SCREENSAVER_STATUS property on root window #0.
* Element 0 is the status (0, BLANK, LOCK), element 1 is the time_t since
* the last state change, and subsequent elements are which hack is running
* on the various screens:
* % xprop -f _SCREENSAVER_STATUS 32ac -root _SCREENSAVER_STATUS
* _SCREENSAVER_STATUS(INTEGER) = BLANK, 1095196626, 10, 237
*
* See watch() in xscreensaver/driver/xscreensaver-command.c.
*
* @return The number of seconds the user has been idle.
*/
该文件包含为不同平台处理此问题的代码。