diff options
author | stanton <stanton@noemail.net> | 1999-04-16 01:51:06 (GMT) |
---|---|---|
committer | stanton <stanton@noemail.net> | 1999-04-16 01:51:06 (GMT) |
commit | 58364783d6f176ecb8520dade8d1cb1a346c0950 (patch) | |
tree | 31378e81bd58f8c726fc552d6b30cbf3ca07497b /win/tkWinWindow.c | |
parent | 878ed3a2c9af6e583516ac48fd69ce3b349ac5f8 (diff) | |
download | tk-58364783d6f176ecb8520dade8d1cb1a346c0950.zip tk-58364783d6f176ecb8520dade8d1cb1a346c0950.tar.gz tk-58364783d6f176ecb8520dade8d1cb1a346c0950.tar.bz2 |
* Merged 8.1 branch into the main trunk
FossilOrigin-Name: 1120dc4257448ed1955333e682de48e2940cc741
Diffstat (limited to 'win/tkWinWindow.c')
-rw-r--r-- | win/tkWinWindow.c | 50 |
1 files changed, 26 insertions, 24 deletions
diff --git a/win/tkWinWindow.c b/win/tkWinWindow.c index 7d321d9..1b0e7a4 100644 --- a/win/tkWinWindow.c +++ b/win/tkWinWindow.c @@ -4,27 +4,22 @@ * Xlib emulation routines for Windows related to creating, * displaying and destroying windows. * - * Copyright (c) 1995 Sun Microsystems, Inc. + * Copyright (c) 1995-1997 Sun Microsystems, Inc. * * See the file "license.terms" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tkWinWindow.c,v 1.4 1998/09/14 18:24:01 stanton Exp $ + * RCS: @(#) $Id: tkWinWindow.c,v 1.5 1999/04/16 01:51:54 stanton Exp $ */ #include "tkWinInt.h" -/* - * The windowTable maps from HWND to Tk_Window handles. - */ - -static Tcl_HashTable windowTable; - -/* - * Have statics in this module been initialized? - */ - -static int initialized = 0; +typedef struct ThreadSpecificData { + int initialized; /* 0 means table below needs initializing. */ + Tcl_HashTable windowTable; /* The windowTable maps from HWND to + * Tk_Window handles. */ +} ThreadSpecificData; +static Tcl_ThreadDataKey dataKey; /* * Forward declarations for procedures defined in this file: @@ -61,10 +56,12 @@ Tk_AttachHWND(tkwin, hwnd) int new; Tcl_HashEntry *entryPtr; TkWinDrawable *twdPtr = (TkWinDrawable *) Tk_WindowId(tkwin); + ThreadSpecificData *tsdPtr = (ThreadSpecificData *) + Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData)); - if (!initialized) { - Tcl_InitHashTable(&windowTable, TCL_ONE_WORD_KEYS); - initialized = 1; + if (!tsdPtr->initialized) { + Tcl_InitHashTable(&tsdPtr->windowTable, TCL_ONE_WORD_KEYS); + tsdPtr->initialized = 1; } /* @@ -77,7 +74,7 @@ Tk_AttachHWND(tkwin, hwnd) twdPtr->type = TWD_WINDOW; twdPtr->window.winPtr = (TkWindow *) tkwin; } else if (twdPtr->window.handle != NULL) { - entryPtr = Tcl_FindHashEntry(&windowTable, + entryPtr = Tcl_FindHashEntry(&tsdPtr->windowTable, (char *)twdPtr->window.handle); Tcl_DeleteHashEntry(entryPtr); } @@ -87,7 +84,7 @@ Tk_AttachHWND(tkwin, hwnd) */ twdPtr->window.handle = hwnd; - entryPtr = Tcl_CreateHashEntry(&windowTable, (char *)hwnd, &new); + entryPtr = Tcl_CreateHashEntry(&tsdPtr->windowTable, (char *)hwnd, &new); Tcl_SetHashValue(entryPtr, (ClientData)tkwin); return (Window)twdPtr; @@ -115,11 +112,14 @@ Tk_HWNDToWindow(hwnd) HWND hwnd; { Tcl_HashEntry *entryPtr; - if (!initialized) { - Tcl_InitHashTable(&windowTable, TCL_ONE_WORD_KEYS); - initialized = 1; + ThreadSpecificData *tsdPtr = (ThreadSpecificData *) + Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData)); + + if (!tsdPtr->initialized) { + Tcl_InitHashTable(&tsdPtr->windowTable, TCL_ONE_WORD_KEYS); + tsdPtr->initialized = 1; } - entryPtr = Tcl_FindHashEntry(&windowTable, (char*)hwnd); + entryPtr = Tcl_FindHashEntry(&tsdPtr->windowTable, (char*)hwnd); if (entryPtr != NULL) { return (Tk_Window) Tcl_GetHashValue(entryPtr); } @@ -190,7 +190,7 @@ TkpPrintWindowId(buf, window) * The return value is normally TCL_OK; in this case *idPtr * will be set to the X Window id equivalent to string. If * string is improperly formed then TCL_ERROR is returned and - * an error message will be left in interp->result. If the + * an error message will be left in the interp's result. If the * number does not correspond to a Tk Window, then *idPtr will * be set to None. * @@ -295,6 +295,8 @@ XDestroyWindow(display, w) TkWinDrawable *twdPtr = (TkWinDrawable *)w; TkWindow *winPtr = TkWinGetWinPtr(w); HWND hwnd = Tk_GetHWND(w); + ThreadSpecificData *tsdPtr = (ThreadSpecificData *) + Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData)); display->request++; @@ -305,7 +307,7 @@ XDestroyWindow(display, w) TkPointerDeadWindow(winPtr); - entryPtr = Tcl_FindHashEntry(&windowTable, (char*)hwnd); + entryPtr = Tcl_FindHashEntry(&tsdPtr->windowTable, (char*)hwnd); if (entryPtr != NULL) { Tcl_DeleteHashEntry(entryPtr); } |