TIP #264: ADD FUNCTION TO RETRIEVE THE INTERPRETER OF A WINDOW ================================================================ Version: $Revision: 1.8 $ Author: George Petasis State: Final Type: Project Tcl-Version: 8.5 Vote: Done Created: Saturday, 01 April 2006 URL: https://tip.tcl-lang.org264.html Post-History: ------------------------------------------------------------------------- ABSTRACT ========== This TIP proposes the addition of a new function in the Tk public API, for retrieving a pointer to the Tcl interpreter that was used for creating a window. RATIONALE =========== During the development of a Tk extension that adds a ClientMessage handler under unix (tkdnd), I needed to get the pointer of the Tcl interpreter that is associated with a window. When the ClientMessage handler is called, only a Tk_Window pointer is passed, for the window the ClientMessage is for. But if you want to execute Tcl code, you don't have a Tcl interpreter... Of course, you can try use any (cached) interpreter, but this can lead to various problems, if it is not the interpreter that was used for creating the window. Since Tk already has this information, adding a function to return the associated interpreter for a Tk_Window pointer will be relatively easy. PROPOSED CHANGE ================= A new public function (with signature /Tcl_Interp */ *Tk_Interp*/(Tk_Window tkwin)/) is proposed to be added to the public C API of Tk. This function can be implemented as follows: Tcl_Interp * Tk_Interp(Tk_Window tkwin) { if (tkwin != NULL && ((TkWindow *) tkwin)->mainPtr != NULL) { return ((TkWindow *) tkwin)->mainPtr->interp; } return NULL; } COPYRIGHT =========== This document has been placed in the public domain. ------------------------------------------------------------------------- TIP AutoGenerator - written by Donal K. Fellows