diff options
author | dkf <donal.k.fellows@manchester.ac.uk> | 2005-05-27 23:14:26 (GMT) |
---|---|---|
committer | dkf <donal.k.fellows@manchester.ac.uk> | 2005-05-27 23:14:26 (GMT) |
commit | 99166f48dd544d3fef849683b0b40175d7238547 (patch) | |
tree | 628e1802dd6cb304781edf0f4c92998bc0d943cf /unix/tkUnix.c | |
parent | 1c838522c0b377c7567543d50640f9290e506db4 (diff) | |
download | tk-99166f48dd544d3fef849683b0b40175d7238547.zip tk-99166f48dd544d3fef849683b0b40175d7238547.tar.gz tk-99166f48dd544d3fef849683b0b40175d7238547.tar.bz2 |
Partial implementation of TIP#245; thanks Reinhard!
Diffstat (limited to 'unix/tkUnix.c')
-rw-r--r-- | unix/tkUnix.c | 68 |
1 files changed, 67 insertions, 1 deletions
diff --git a/unix/tkUnix.c b/unix/tkUnix.c index 65f1a90..c0e454d 100644 --- a/unix/tkUnix.c +++ b/unix/tkUnix.c @@ -10,10 +10,13 @@ * See the file "license.terms" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tkUnix.c,v 1.6 2004/10/26 13:15:09 dkf Exp $ + * RCS: @(#) $Id: tkUnix.c,v 1.7 2005/05/27 23:14:29 dkf Exp $ */ #include <tkInt.h> +#ifdef HAVE_XSS +#include <X11/extensions/scrnsaver.h> +#endif /* *---------------------------------------------------------------------- @@ -165,3 +168,66 @@ TkpBuildRegionFromAlphaData(region, x, y, width, height, dataPtr, dataPtr += lineStride; } } + +/* + *---------------------------------------------------------------------- + * + * Tk_GetUserInactiveTime -- + * + * Return the number of milliseconds the user was inactive. + * + * Results: + * The number of milliseconds since the user's latest interaction + * with the system on the given display, or -1 if the + * XScreenSaver extension is not supported by the client + * libraries or the X server implementation. + * + * Side effects: + * None. + *---------------------------------------------------------------------- + */ + +long +Tk_GetUserInactiveTime(dpy) + Display *dpy; /* The display for which to query the + * inactive time. */ +{ + long inactiveTime = -1; +#ifdef HAVE_XSS + int eventBase; + int errorBase; + + if (XScreenSaverQueryExtension(dpy, &eventBase, &errorBase)) { + XScreenSaverInfo *info = XScreenSaverAllocInfo(); + + XScreenSaverQueryInfo(dpy, DefaultRootWindow(dpy), info); + inactiveTime = info->idle; + XFree(info); + } +#endif /* HAVE_XSS */ + return inactiveTime; +} + +/* + *---------------------------------------------------------------------- + * + * Tk_ResetUserInactiveTime -- + * + * Reset the user inactivity timer + * + * Results: + * none + * + * Side effects: + * The user inactivity timer of the underlaying windowing system + * is reset to zero. + * + *---------------------------------------------------------------------- + */ + +void +Tk_ResetUserInactiveTime(dpy) + Display *dpy; +{ + XResetScreenSaver(dpy); +} |