TIP #245 Version 1.1: Discover User Inactivity Time

This is not necessarily the current version of this TIP.


TIP:245
Title:Discover User Inactivity Time
Version:$Revision: 1.1 $
Authors: Pascal Scheffers <pascal at scheffers dot net>
Reinhard Max <max at tclers dot tk>
State:Draft
Type:Project
Tcl-Version:8.5
Vote:Pending
Created:Friday, 15 April 2005
Keywords:Tk

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[1].

Comments

[ Insert here please ]

Copyright

This document has been placed in the public domain.


Powered by TclThis is not necessarily the current version of this TIP.

TIP AutoGenerator - written by Donal K. Fellows