summaryrefslogtreecommitdiffstats
path: root/unix
diff options
context:
space:
mode:
Diffstat (limited to 'unix')
-rw-r--r--unix/configure.in25
-rw-r--r--unix/tkUnix.c68
2 files changed, 91 insertions, 2 deletions
diff --git a/unix/configure.in b/unix/configure.in
index 7dbf335..732b301 100644
--- a/unix/configure.in
+++ b/unix/configure.in
@@ -3,7 +3,7 @@ dnl This file is an input file used by the GNU "autoconf" program to
dnl generate the file "configure", which is run during Tk installation
dnl to configure the system for the local environment.
#
-# RCS: @(#) $Id: configure.in,v 1.104 2005/05/26 11:19:04 das Exp $
+# RCS: @(#) $Id: configure.in,v 1.105 2005/05/27 23:14:29 dkf Exp $
AC_INIT([tk],[8.5])
AC_PREREQ(2.57)
@@ -323,6 +323,29 @@ if test -d /usr/include/mit ; then
fi
#--------------------------------------------------------------------
+# Check whether the header and library for the XScreenSaver
+# extension are available, and set HAVE_XSS if so.
+# XScreenSaver is needed for Tk_GetUserInactiveTime().
+#--------------------------------------------------------------------
+AC_MSG_CHECKING([for XScreenSaver support])
+tk_oldCFlags=$CFLAGS
+CFLAGS="$CFLAGS $XINCLUDES"
+tk_oldLibs=$LIBS
+LIBS="$LIBS $XLIBSW -lXss -lXext"
+AC_TRY_LINK([
+ #include <X11/Xlib.h>
+ #include <X11/extensions/scrnsaver.h>
+] , [
+ XScreenSaverAllocInfo();
+], [
+ AC_MSG_RESULT(yes)
+ XLIBSW="$XLIBSW -lXss -lXext"
+ AC_DEFINE([HAVE_XSS])
+], AC_MSG_RESULT(no))
+CFLAGS=$tk_oldCFlags
+LIBS=$tk_oldLibs
+
+#--------------------------------------------------------------------
# Check for freetype / fontconfig / Xft support.
#--------------------------------------------------------------------
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);
+}