I also have this code, running in 8.5a1:
proc newexit {} {
outline "DIE" [clock seconds]
_exit
}
rename exit _exit
rename newexit exit
wm protocol . WM_DELETE_WINDOW exit
and that doesn't seem to invoke outline when the process exits, unless I
exit by explicitly clicking the close box. Logging out while it's
running, or cleanly rebooting, doesn't seem to invoke the exit proc.
What I really want is a program running that records when the user
logged out. This doesn't seem to be working.
--
Darren New / San Diego, CA, USA (PST)
Just because you find out you are
telepathic, don't let it go to your head.
If you are using at least 8.4.13, add also:
wm protocol . WM_SAVE_YOURSELF exit
--
Jeff Hobbs, The Tcl Guy, http://www.activestate.com/
8.5a1, and nope. BTW, this is Windows.
> Jeff Hobbs wrote:
> > If you are using at least 8.4.13, add also:
> > wm protocol . WM_SAVE_YOURSELF exit
>
> 8.5a1, and nope. BTW, this is Windows.
Uh.. that's a few years old... :) If you use alpha, best take the
latest (8.5a4)
I don't get why you're renaming. Why don't you just
wm protocol . WM_DELETE_WINDOW newexit
Also, is newexit in a namespace. I assume the WM_DELETE_WINDOW handler
would be looking in the global namespace.
--
Glenn Jackman
Ulterior Designer
I was under the impression (from earlier conversations here a while
back) that [exit] is called whenever the interpreter exits, even if it's
not from closing the window via a WM_DELETE_WINDOW. E.g., by logging out.
> Also, is newexit in a namespace. I assume the WM_DELETE_WINDOW handler
> would be looking in the global namespace.
Nope. It's a 15-line program overall. Too simple to worry about such. It
works OK if I actually click the close box. I'm looking to catch exits
caused by closing the window without clicking the close box.
I know, thanks. I use Tcl idly-like now, rather than as a production
language, so being old isn't a problem. I'm not pushing the cutting
edge. The only reason I upgraded before was to try to fix the problem of
the windows not refreshing when the resolution/depth changed.
**** DANGER DANGER DANGER ****
Do *not* do this if the program will ever be run under X11.
WM_SAVE_YOURSELF is part of the older session manager protocol;
SMs can send WM_SAVE_YOURSELF at any time, not just when
the session is about to end.
Also, if you register a WM_SAVE_YOURSELF handler make sure
that it calls [wm command $win ...]; this tells the SM that
the app has finished processing the message. If you don't
do this, it can prevent users from logging out while your
application is active.
--Joe English