diff options
-rw-r--r-- | ChangeLog | 6 | ||||
-rw-r--r-- | doc/Inactive.3 | 38 | ||||
-rw-r--r-- | tests/tk.test | 46 |
3 files changed, 83 insertions, 7 deletions
@@ -1,3 +1,9 @@ +2005-05-31 Reinhard Max <max@suse.de> + + * doc/Inactive.3 (new file): C level API documentationn for + TIP#245 (Tk_GetUserInactiveTime, Tk_ResetUserInactiveTime). + * tests/tk.test: Added tests for the TIP#245 implementation. + 2005-05-30 Jeff Hobbs <jeffh@ActiveState.com> * generic/tkPanedWindow.c, tests/panedwindow.test: batch of fixes diff --git a/doc/Inactive.3 b/doc/Inactive.3 new file mode 100644 index 0000000..37cd93f --- /dev/null +++ b/doc/Inactive.3 @@ -0,0 +1,38 @@ +'\" +'\" Copyright (c) 1998-2000 by Scriptics Corporation. +'\" All rights reserved. +'\" +'\" RCS: @(#) $Id: Inactive.3,v 1.1 2005/05/31 15:24:53 rmax Exp $ +'\" +.so man.macros +.TH Tk_GetUserInactiveTime 3 8.5 Tk "Tk Library Procedures" +.BS +.SH NAME +Tk_GetUserInactiveTime, Tk_ResetUserInactiveTime \- discover user inactivity time +.SH SYNOPSIS +.nf +\fB#include <tk.h>\fR +.sp +long +\fBTk_GetUserInactiveTime(\fIdisplay\fB)\fR +.sp +\fBTk_GetUserInactiveTime(\fIdisplay\fB)\fR +.SH ARGUMENTS +.AS Display *display +.AP Display *display in +The display on which the user inactivity timer is to be queried or +reset. +.BE + +.SH DESCRIPTION +.PP +\fBTk_GetUserInactiveTime\fR returns the number of milliseconds that +have passed since the last user interaction (usually via keyboard or +mouse) with the respective display. On systems and displays that don't +support querying the user inactiviy time, \fB-1\fR is returned. +\fBTk_GetUserInactiveTime\fR resets the user inactivity timer of the +given display to zero. On windowing systems that don't support +multiple displays \fIdisplay\fR can be passed as \fBNULL\fR. + +.SH KEYWORDS +idle, inactive diff --git a/tests/tk.test b/tests/tk.test index c2a781b..d4fd43e 100644 --- a/tests/tk.test +++ b/tests/tk.test @@ -5,18 +5,18 @@ # Copyright (c) 1998-1999 by Scriptics Corporation. # Copyright (c) 2002 ActiveState Corporation. # -# RCS: @(#) $Id: tk.test,v 1.12 2004/06/24 12:45:44 dkf Exp $ +# RCS: @(#) $Id: tk.test,v 1.13 2005/05/31 15:24:53 rmax Exp $ package require tcltest 2.1 eval tcltest::configure $argv tcltest::loadTestedCommands -test tk-1.1 {tk command: general} { - list [catch {tk} msg] $msg -} {1 {wrong # args: should be "tk option ?arg?"}} -test tk-1.2 {tk command: general} { - list [catch {tk xyz} msg] $msg -} {1 {bad option "xyz": must be appname, caret, scaling, useinputmethods, or windowingsystem}} +test tk-1.1 {tk command: general} \ + -body {tk} -returnCodes 1 \ + -result {wrong # args: should be "tk option ?arg?"} +test tk-1.2 {tk command: general} \ + -body {tk xyz} -returnCodes 1 \ + -result {bad option "xyz": must be appname, caret, scaling, useinputmethods, windowingsystem, or inactive} set appname [tk appname] test tk-2.1 {tk command: appname} { @@ -129,6 +129,38 @@ test tk-5.6 {tk caret} { list [catch {tk caret . -x 20 -y 25 -h 30; tk caret . -hei} msg] $msg } {0 30} +# tk inactive +test tk-5.1 {tk inactive} -body { + string is integer [tk inactive] +} -result 1 +test tk-5.2 {tk inactive reset} -body { + catch {tk inactive reset} +} -result 0 +test tk-5.3 {tk inactive wrong argument} -body { + tk inactive foo +} -returnCodes 1 -result {bad option "foo": must be reset} +test tk-5.4 {tk inactive too many arguments} -body { + tk inactive reset foo +} -returnCodes 1 -result {wrong # args: should be "tk inactive ?-displayof window? ?reset?"} +test tk-5.3 {tk inactive} -body { + tk inactive reset + update + after 100 + set i [tk inactive] + expr {$i == -1 || ( $i > 90 && $i < 200 )} +} -result 1 + +# tk inactive in safe interpreters +safe::interpCreate foo +safe::loadTk foo +test tk-6.1 {tk inactive in a safe interpreter} -body { + foo eval {tk inactive} +} -result -1 +test tk-6.2 {tk inactive reset in a safe interpreter} -body { + foo eval {tk inactive reset} +} -returnCodes 1 -result {resetting the user inactivity timer is not allowed in a safe interpreter} +::safe::interpDelete foo + # cleanup cleanupTests return |