OSDN Git Service

Please enter the commit message for your changes. Lines starting
[eos/base.git] / util / src / TclTk / tk8.6.12 / unix / tkUnixXId.c
1 /*
2  * tkUnixXId.c --
3  *
4  * Copyright (c) 1993 The Regents of the University of California.
5  * Copyright (c) 1994-1997 Sun Microsystems, Inc.
6  *
7  * See the file "license.terms" for information on usage and redistribution of
8  * this file, and for a DISCLAIMER OF ALL WARRANTIES.
9  */
10
11 #include "tkUnixInt.h"
12
13 \f
14 /*
15  *----------------------------------------------------------------------
16  *
17  * Tk_FreeXId --
18  *
19  *      This function is called to indicate that an X resource identifier is
20  *      now free.
21  *
22  * Results:
23  *      None.
24  *
25  * Side effects:
26  *      The identifier is added to the stack of free identifiers for its
27  *      display, so that it can be re-used.
28  *
29  *----------------------------------------------------------------------
30  */
31
32 void
33 Tk_FreeXId(
34     Display *display,           /* Display for which xid was allocated. */
35     XID xid)                    /* Identifier that is no longer in use. */
36 {
37     /*
38      * This does nothing, because the XC-MISC extension takes care of
39      * freeing XIDs for us.  It has been a standard X11 extension for
40      * about 15 years as of 2008.  Keith Packard and another X.org
41      * developer suggested that we remove the previous code that used:
42      * #define XLIB_ILLEGAL_ACCESS.
43      */
44 }
45
46 \f
47 /*
48  *----------------------------------------------------------------------
49  *
50  * Tk_GetPixmap --
51  *
52  *      Same as the XCreatePixmap function except that it manages resource
53  *      identifiers better.
54  *
55  * Results:
56  *      Returns a new pixmap.
57  *
58  * Side effects:
59  *      None.
60  *
61  *----------------------------------------------------------------------
62  */
63
64 Pixmap
65 Tk_GetPixmap(
66     Display *display,           /* Display for new pixmap. */
67     Drawable d,                 /* Drawable where pixmap will be used. */
68     int width, int height,      /* Dimensions of pixmap. */
69     int depth)                  /* Bits per pixel for pixmap. */
70 {
71     return XCreatePixmap(display, d, (unsigned) width, (unsigned) height,
72             (unsigned) depth);
73 }
74 \f
75 /*
76  *----------------------------------------------------------------------
77  *
78  * Tk_FreePixmap --
79  *
80  *      Same as the XFreePixmap function except that it also marks the
81  *      resource identifier as free.
82  *
83  * Results:
84  *      None.
85  *
86  * Side effects:
87  *      The pixmap is freed in the X server and its resource identifier is
88  *      saved for re-use.
89  *
90  *----------------------------------------------------------------------
91  */
92
93 void
94 Tk_FreePixmap(
95     Display *display,           /* Display for which pixmap was allocated. */
96     Pixmap pixmap)              /* Identifier for pixmap. */
97 {
98     XFreePixmap(display, pixmap);
99 }
100
101 \f
102 /*
103  *----------------------------------------------------------------------
104  *
105  * TkpScanWindowId --
106  *
107  *      Given a string, produce the corresponding Window Id.
108  *
109  * Results:
110  *      The return value is normally TCL_OK; in this case *idPtr will be set
111  *      to the Window value equivalent to string. If string is improperly
112  *      formed then TCL_ERROR is returned and an error message will be left in
113  *      the interp's result.
114  *
115  * Side effects:
116  *      None.
117  *
118  *----------------------------------------------------------------------
119  */
120
121 int
122 TkpScanWindowId(
123     Tcl_Interp *interp,
124     const char *string,
125     Window *idPtr)
126 {
127     int code;
128     Tcl_Obj obj;
129
130     obj.refCount = 1;
131     obj.bytes = (char *) string;        /* DANGER?! */
132     obj.length = strlen(string);
133     obj.typePtr = NULL;
134
135     code = Tcl_GetLongFromObj(interp, &obj, (long *)idPtr);
136
137     if (obj.refCount > 1) {
138         Tcl_Panic("invalid sharing of Tcl_Obj on C stack");
139     }
140     if (obj.typePtr && obj.typePtr->freeIntRepProc) {
141         obj.typePtr->freeIntRepProc(&obj);
142     }
143     return code;
144 }
145 \f
146 /*
147  * Local Variables:
148  * mode: c
149  * c-basic-offset: 4
150  * fill-column: 78
151  * End:
152  */