Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

TIP #245: Discover User Inactivity Time

2 views
Skip to first unread message

Pascal Scheffers

unread,
Apr 22, 2005, 7:05:47 PM4/22/05
to

TIP #245: DISCOVER USER INACTIVITY TIME
=========================================
Version: $Revision: 1.1 $
Author: Pascal Scheffers <pascal_at_scheffers.net>
Reinhard Max <max_at_tclers.tk>
State: Draft
Type: Project
Tcl-Version: 8.5
Vote: Pending
Created: Friday, 15 April 2005
URL: http://purl.org/tcl/tip/245.html
WebEdit: http://purl.org/tcl/tip/edit/245
Post-History:

-------------------------------------------------------------------------

ABSTRACT
==========

This TIP proposes a new subcommand, *inactive*, to the *tk* command, as
well as a /Tk_UserInactiveTime/ C function to discover the number of
milliseconds the user has been inactive. For most environments, this is
the time since the user last used the keyboard or mouse.

RATIONALE
===========

User inactivity is used by screen-savers, chat applications and for
security conscious applications to quit or lock themselves after some
inactive time has elapsed. It would make it easier for authors of these
kinds of applications to use Tk if there was a simple way to get the
length of time which the user has been inactive, which is information
available on all supported platforms.

SPECIFICATION
===============

TCL API
---------

A single new subcommand will be added to *tk*, *inactive*. This command
takes an optional argument ?*-displayof* /window/?. It returns a
positive integer, the number of milliseconds since the last time the
user interacted with the system. If the -displayof option is given then
the return value refers to the display of /window/; otherwise it refers
to the display of the application's main window.

If querying the user inactive time is not supported by the system, *tk
inactive* will return -1.

*tk* *inactive* ?*-displayof* /window/?

C API
-------

long *Tk_UserInactiveTime*(/display/)

Display *display (in):
used to determine which display to query for user inactive time.

*Tk_UserInactiveTime()* returns a positive integer, the number of
milliseconds since the last time the user interacted with the system
(note that this is not necessarily the time since the user interacted
with the application.)

SAFE INTERPRETERS
===================

User inactive time can be used for timing attacks and will not be made
available in safe interpreters, *tk inactive* will return -1 in safe
interpreters.

IMPLEMENTATION NOTES
======================

Windows 2000 and later have /GetLastUserInfo/ to obtain the
information, earlier platforms do not have this symbol in user32.dll.
This symbol will be dynamically obtained upon the first call of
/Tk_UserInactiveTime()/ on windows. If the symbol is not available,
/Tk_UserInactiveTime()/ will return -1. /GetLastUserInfo()/ has no
notion of displays, and as a result the display argument is ignored.
The behaviour of the command is unknown for terminal services, remote
desktop, VNC, Citrix and other remote screen systems.

For X, this patch introduces two additional library dependencies -
libXext and libXss. The authors do not know if a similar situation to
Windows could exist on the X Window System, where the build host has
libXss, and yet not all installations for that platform have libXss. A
proper solution for that scenario would require an additional TIP to
export TclLoadFile, Tcl_FSLoadFile is not sufficient, to resolve the
symbols at runtime. (The other library, libXext, is virtually
universally available.)

REFERENCE IMPLEMENTATION
==========================

A reference implementation is available as Patch #1185731 on
SourceForge[<URL:http://sf.net/support/tracker.php?aid=1185731>].

COMMENTS
==========

[ Insert here please ]

COPYRIGHT
===========

This document has been placed in the public domain.

-------------------------------------------------------------------------

TIP AutoGenerator - written by Donal K. Fellows

[[Send Tcl/Tk announcements to tcl-an...@mitchell.org
Announcements archived at http://groups.yahoo.com/group/tcl_announce/
Send administrivia to tcl-announ...@mitchell.org
Tcl/Tk at http://tcl.tk/ ]]

0 new messages