Author: Pascal Scheffers <[email protected]> Author: Reinhard Max <[email protected]> Author: Neil Madden <[email protected]> State: Final Type: Project Vote: Done Created: 15-Apr-2005 Post-History: Keywords: Tk Tcl-Version: 8.5 Tk-Ticket: 1185731
This TIP proposes a new subcommand, inactive, to the tk command, as well as Tk_GetUserInactiveTime and Tk_ResetUserInactiveTime C functions to discover the number of milliseconds the user has been inactive and reset that timer to zero respectively. For most environments, this is the time since the user last used the keyboard or mouse.
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.
Applications that take some kind of user input from channels that bypass the system's mechanisms for detecting user activity might want to tell the system to reset the inactivity timer because they received input that has to be treated as user activity. An example for this would be barcode readers connected via serial lines that are read directly by the application.
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.
If the literal string reset is given as an additional argument, the timer is reset and an empty string is returned.
tk inactive ?-displayof window? ?reset?
Display *display (in): used to determine which display to query for user inactive time.
Tk_GetUserInactiveTime() 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.)
Display *display (in): used to determine on which display the user inactivity timer is to be reset.
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. Calling tk inactive reset in a safe interpreter will throw an error.
Windows 2000 and later have GetLastInputInfo 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. GetLastInputInfo() 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.)
For Win9x, Microsoft has published example code at http://www.microsoft.com/msj/0200/c/c0200.aspx .
A reference implementation is available as Patch #1185731 on SourceForgehttp://sf.net/support/tracker.php?aid=1185731 .
[ Insert here please ]
This document has been placed in the public domain.