summaryrefslogtreecommitdiff
path: root/tk/win/tkWinWindow.c
diff options
context:
space:
mode:
Diffstat (limited to 'tk/win/tkWinWindow.c')
-rw-r--r--tk/win/tkWinWindow.c49
1 files changed, 26 insertions, 23 deletions
diff --git a/tk/win/tkWinWindow.c b/tk/win/tkWinWindow.c
index f78dd0b9c74..6980f39bca1 100644
--- a/tk/win/tkWinWindow.c
+++ b/tk/win/tkWinWindow.c
@@ -4,7 +4,7 @@
* 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.
@@ -14,17 +14,12 @@
#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);
}
@@ -799,3 +801,4 @@ TkpWindowWasRecentlyDeleted(win, dispPtr)
{
return 0;
}
+