summaryrefslogtreecommitdiffstats
path: root/generic/tkGC.c
diff options
context:
space:
mode:
authorstanton <stanton>1999-04-16 01:51:06 (GMT)
committerstanton <stanton>1999-04-16 01:51:06 (GMT)
commit03656f44f81469f459031fa3a4a7b09c8bc77712 (patch)
tree31378e81bd58f8c726fc552d6b30cbf3ca07497b /generic/tkGC.c
parent404fc236f34304df53b7e44bc7971d786b87d453 (diff)
downloadtk-03656f44f81469f459031fa3a4a7b09c8bc77712.zip
tk-03656f44f81469f459031fa3a4a7b09c8bc77712.tar.gz
tk-03656f44f81469f459031fa3a4a7b09c8bc77712.tar.bz2
* Merged 8.1 branch into the main trunk
Diffstat (limited to 'generic/tkGC.c')
-rw-r--r--generic/tkGC.c57
1 files changed, 18 insertions, 39 deletions
diff --git a/generic/tkGC.c b/generic/tkGC.c
index dd53e32..b719137 100644
--- a/generic/tkGC.c
+++ b/generic/tkGC.c
@@ -10,11 +10,11 @@
* See the file "license.terms" for information on usage and redistribution
* of this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: tkGC.c,v 1.2 1998/09/14 18:23:11 stanton Exp $
+ * RCS: @(#) $Id: tkGC.c,v 1.3 1999/04/16 01:51:14 stanton Exp $
*/
#include "tkPort.h"
-#include "tk.h"
+#include "tkInt.h"
/*
* One of the following data structures exists for each GC that is
@@ -31,12 +31,6 @@ typedef struct {
* this structure). */
} TkGC;
-/*
- * Hash table to map from a GC's values to a TkGC structure describing
- * a GC with those values (used by Tk_GetGC).
- */
-
-static Tcl_HashTable valueTable;
typedef struct {
XGCValues values; /* Desired values for GC. */
Display *display; /* Display for which GC is valid. */
@@ -45,24 +39,10 @@ typedef struct {
} ValueKey;
/*
- * Hash table for <display + GC> -> TkGC mapping. This table is used by
- * Tk_FreeGC.
- */
-
-static Tcl_HashTable idTable;
-typedef struct {
- Display *display; /* Display for which GC was allocated. */
- GC gc; /* X's identifier for GC. */
-} IdKey;
-
-static int initialized = 0; /* 0 means static structures haven't been
- * initialized yet. */
-
-/*
* Forward declarations for procedures defined in this file:
*/
-static void GCInit _ANSI_ARGS_((void));
+static void GCInit _ANSI_ARGS_((TkDisplay *dispPtr));
/*
*----------------------------------------------------------------------
@@ -98,14 +78,14 @@ Tk_GetGC(tkwin, valueMask, valuePtr)
* in valueMask. */
{
ValueKey valueKey;
- IdKey idKey;
Tcl_HashEntry *valueHashPtr, *idHashPtr;
register TkGC *gcPtr;
int new;
Drawable d, freeDrawable;
+ TkDisplay *dispPtr = ((TkWindow *) tkwin)->dispPtr;
- if (!initialized) {
- GCInit();
+ if (!dispPtr->gcInit) {
+ GCInit(dispPtr);
}
/*
@@ -238,7 +218,8 @@ Tk_GetGC(tkwin, valueMask, valuePtr)
valueKey.display = Tk_Display(tkwin);
valueKey.screenNum = Tk_ScreenNumber(tkwin);
valueKey.depth = Tk_Depth(tkwin);
- valueHashPtr = Tcl_CreateHashEntry(&valueTable, (char *) &valueKey, &new);
+ valueHashPtr = Tcl_CreateHashEntry(&dispPtr->gcValueTable,
+ (char *) &valueKey, &new);
if (!new) {
gcPtr = (TkGC *) Tcl_GetHashValue(valueHashPtr);
gcPtr->refCount++;
@@ -275,9 +256,8 @@ Tk_GetGC(tkwin, valueMask, valuePtr)
gcPtr->display = valueKey.display;
gcPtr->refCount = 1;
gcPtr->valueHashPtr = valueHashPtr;
- idKey.display = valueKey.display;
- idKey.gc = gcPtr->gc;
- idHashPtr = Tcl_CreateHashEntry(&idTable, (char *) &idKey, &new);
+ idHashPtr = Tcl_CreateHashEntry(&dispPtr->gcIdTable,
+ (char *) gcPtr->gc, &new);
if (!new) {
panic("GC already registered in Tk_GetGC");
}
@@ -313,17 +293,15 @@ Tk_FreeGC(display, gc)
Display *display; /* Display for which gc was allocated. */
GC gc; /* Graphics context to be released. */
{
- IdKey idKey;
Tcl_HashEntry *idHashPtr;
register TkGC *gcPtr;
+ TkDisplay *dispPtr = TkGetDisplay(display);
- if (!initialized) {
+ if (!dispPtr->gcInit) {
panic("Tk_FreeGC called before Tk_GetGC");
}
- idKey.display = display;
- idKey.gc = gc;
- idHashPtr = Tcl_FindHashEntry(&idTable, (char *) &idKey);
+ idHashPtr = Tcl_FindHashEntry(&dispPtr->gcIdTable, (char *) gc);
if (idHashPtr == NULL) {
panic("Tk_FreeGC received unknown gc argument");
}
@@ -355,9 +333,10 @@ Tk_FreeGC(display, gc)
*/
static void
-GCInit()
+GCInit(dispPtr)
+ TkDisplay *dispPtr;
{
- initialized = 1;
- Tcl_InitHashTable(&valueTable, sizeof(ValueKey)/sizeof(int));
- Tcl_InitHashTable(&idTable, sizeof(IdKey)/sizeof(int));
+ dispPtr->gcInit = 1;
+ Tcl_InitHashTable(&dispPtr->gcValueTable, sizeof(ValueKey)/sizeof(int));
+ Tcl_InitHashTable(&dispPtr->gcIdTable, TCL_ONE_WORD_KEYS);
}