This is not necessarily the current version of this TIP.
| TIP: | 245 |
| Title: | Discover User Inactivity Time |
| Version: | $Revision: 1.5 $ |
| Authors: |
Pascal Scheffers <pascal at scheffers dot net> Reinhard Max <max at tclers dot tk> Neil Madden <nem at cs dot nott dot ac dot uk> |
| State: | Draft |
| Type: | Project |
| Tcl-Version: | 8.5 |
| Vote: | Pending |
| Created: | Friday, 15 April 2005 |
| Keywords: | Tk |
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.
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.
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?
long Tk_UserInactiveTime(display)
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.)
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.
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 [1].
Windows CE 3.0 and up has GetIdleTime() for this purpose.
A reference implementation is available as Patch #1185731 on SourceForge[2].
[ Insert here please ]
This document has been placed in the public domain.
This is not necessarily the current version of this TIP.